1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 16:52:41 +01:00

Despecialize most task status handling

Summary: Ref T1812. Moves most specialized status handling into `ManiphestTaskStatus`. The only real missing case is reports.

Test Plan:
Browsed most of the affected interfaces. Changed task status:

{F132697}

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T1812

Differential Revision: https://secure.phabricator.com/D8579
This commit is contained in:
epriestley 2014-03-25 13:47:42 -07:00
parent 750c872839
commit 33bda2d590
13 changed files with 179 additions and 115 deletions

View file

@ -1,8 +1,5 @@
<?php <?php
/**
* @group maniphest
*/
final class ManiphestTaskStatus extends ManiphestConstants { final class ManiphestTaskStatus extends ManiphestConstants {
const STATUS_OPEN = 0; const STATUS_OPEN = 0;
@ -23,7 +20,7 @@ final class ManiphestTaskStatus extends ManiphestConstants {
$duplicate = pht('Duplicate'); $duplicate = pht('Duplicate');
$spite = pht('Spite'); $spite = pht('Spite');
return array( $statuses = array(
self::STATUS_OPEN => $open, self::STATUS_OPEN => $open,
self::STATUS_CLOSED_RESOLVED => $resolved, self::STATUS_CLOSED_RESOLVED => $resolved,
self::STATUS_CLOSED_WONTFIX => $wontfix, self::STATUS_CLOSED_WONTFIX => $wontfix,
@ -31,6 +28,17 @@ final class ManiphestTaskStatus extends ManiphestConstants {
self::STATUS_CLOSED_DUPLICATE => $duplicate, self::STATUS_CLOSED_DUPLICATE => $duplicate,
self::STATUS_CLOSED_SPITE => $spite, self::STATUS_CLOSED_SPITE => $spite,
); );
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
if (!$is_serious) {
$statuses[self::STATUS_CLOSED_SPITE] = pht('Spite');
}
return $statuses;
}
public static function getTaskStatusName($status) {
return idx(self::getTaskStatusMap(), $status, pht('Unknown Status'));
} }
public static function getTaskStatusFullName($status) { public static function getTaskStatusFullName($status) {
@ -103,12 +111,26 @@ final class ManiphestTaskStatus extends ManiphestConstants {
return self::STATUS_OPEN; return self::STATUS_OPEN;
} }
public static function getDefaultClosedStatus() {
return self::STATUS_CLOSED_RESOLVED;
}
public static function getDuplicateStatus() {
return self::STATUS_CLOSED_DUPLICATE;
}
public static function getOpenStatusConstants() { public static function getOpenStatusConstants() {
return array( return array(
self::STATUS_OPEN, self::STATUS_OPEN,
); );
} }
public static function getClosedStatusConstants() {
$all = array_keys(self::getTaskStatusMap());
$open = self::getOpenStatusConstants();
return array_diff($all, $open);
}
public static function isOpenStatus($status) { public static function isOpenStatus($status) {
foreach (self::getOpenStatusConstants() as $constant) { foreach (self::getOpenStatusConstants() as $constant) {
if ($status == $constant) { if ($status == $constant) {
@ -118,6 +140,35 @@ final class ManiphestTaskStatus extends ManiphestConstants {
return false; return false;
} }
public static function isClosedStatus($status) {
return !self::isOpenStatus($status);
}
public static function getStatusActionName($status) {
switch ($status) {
case self::STATUS_CLOSED_SPITE:
return pht('Spited');
}
return null;
}
public static function getStatusColor($status) {
if (self::isOpenStatus($status)) {
return 'green';
}
return 'black';
}
public static function getStatusIcon($status) {
switch ($status) {
case ManiphestTaskStatus::STATUS_CLOSED_SPITE:
return 'dislike';
case ManiphestTaskStatus::STATUS_CLOSED_DUPLICATE:
return 'delete';
}
}
public static function getStatusPrefixMap() { public static function getStatusPrefixMap() {
return array( return array(
'resolve' => self::STATUS_CLOSED_RESOLVED, 'resolve' => self::STATUS_CLOSED_RESOLVED,

View file

@ -151,7 +151,7 @@ final class ManiphestTaskDetailController extends ManiphestController {
$transaction_types = array( $transaction_types = array(
PhabricatorTransactions::TYPE_COMMENT => pht('Comment'), PhabricatorTransactions::TYPE_COMMENT => pht('Comment'),
ManiphestTransaction::TYPE_STATUS => pht('Close Task'), ManiphestTransaction::TYPE_STATUS => pht('Change Status'),
ManiphestTransaction::TYPE_OWNER => pht('Reassign / Claim'), ManiphestTransaction::TYPE_OWNER => pht('Reassign / Claim'),
ManiphestTransaction::TYPE_CCS => pht('Add CCs'), ManiphestTransaction::TYPE_CCS => pht('Add CCs'),
ManiphestTransaction::TYPE_PRIORITY => pht('Change Priority'), ManiphestTransaction::TYPE_PRIORITY => pht('Change Priority'),
@ -180,21 +180,14 @@ final class ManiphestTaskDetailController extends ManiphestController {
} }
} }
if ($task->getStatus() == ManiphestTaskStatus::STATUS_OPEN) { // Don't show an option to change to the current status, or to change to
$resolution_types = array_select_keys( // the duplicate status explicitly.
$resolution_types, unset($resolution_types[$task->getStatus()]);
array( unset($resolution_types[ManiphestTaskStatus::getDuplicateStatus()]);
ManiphestTaskStatus::STATUS_CLOSED_RESOLVED,
ManiphestTaskStatus::STATUS_CLOSED_WONTFIX, // Don't show owner/priority changes for closed tasks, as they don't make
ManiphestTaskStatus::STATUS_CLOSED_INVALID, // much sense.
ManiphestTaskStatus::STATUS_CLOSED_SPITE, if ($task->isClosed()) {
));
} else {
$resolution_types = array(
ManiphestTaskStatus::STATUS_OPEN => 'Reopened',
);
$transaction_types[ManiphestTransaction::TYPE_STATUS] =
'Reopen Task';
unset($transaction_types[ManiphestTransaction::TYPE_PRIORITY]); unset($transaction_types[ManiphestTransaction::TYPE_PRIORITY]);
unset($transaction_types[ManiphestTransaction::TYPE_OWNER]); unset($transaction_types[ManiphestTransaction::TYPE_OWNER]);
} }
@ -215,12 +208,6 @@ final class ManiphestTaskDetailController extends ManiphestController {
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
if ($is_serious) {
// Prevent tasks from being closed "out of spite" in serious business
// installs.
unset($resolution_types[ManiphestTaskStatus::STATUS_CLOSED_SPITE]);
}
$comment_form = new AphrontFormView(); $comment_form = new AphrontFormView();
$comment_form $comment_form
->setUser($user) ->setUser($user)
@ -236,7 +223,7 @@ final class ManiphestTaskDetailController extends ManiphestController {
->setID('transaction-action')) ->setID('transaction-action'))
->appendChild( ->appendChild(
id(new AphrontFormSelectControl()) id(new AphrontFormSelectControl())
->setLabel(pht('Resolution')) ->setLabel(pht('Status'))
->setName('resolution') ->setName('resolution')
->setControlID('resolution') ->setControlID('resolution')
->setControlStyle('display: none') ->setControlStyle('display: none')

View file

@ -147,9 +147,9 @@ final class ManiphestTransactionSaveController extends ManiphestController {
$added_ccs[] = $task->getOwnerPHID(); $added_ccs[] = $task->getOwnerPHID();
break; break;
case ManiphestTransaction::TYPE_STATUS: case ManiphestTransaction::TYPE_STATUS:
$resolution = $request->getStr('resolution');
if (!$task->getOwnerPHID() && if (!$task->getOwnerPHID() &&
$request->getStr('resolution') != ManiphestTaskStatus::isClosedStatus($resolution)) {
ManiphestTaskStatus::STATUS_OPEN) {
// Closing an unassigned task. Assign the user as the owner of // Closing an unassigned task. Assign the user as the owner of
// this task. // this task.
$assign = new ManiphestTransaction(); $assign = new ManiphestTransaction();

View file

@ -82,7 +82,7 @@ final class ManiphestReplyHandler extends PhabricatorMailReplyHandler {
switch ($command) { switch ($command) {
case 'close': case 'close':
$ttype = ManiphestTransaction::TYPE_STATUS; $ttype = ManiphestTransaction::TYPE_STATUS;
$new_value = ManiphestTaskStatus::STATUS_CLOSED_RESOLVED; $new_value = ManiphestTaskStatus::getDefaultClosedStatus();
break; break;
case 'claim': case 'claim':
$ttype = ManiphestTransaction::TYPE_OWNER; $ttype = ManiphestTransaction::TYPE_OWNER;

View file

@ -38,7 +38,7 @@ final class ManiphestPHIDTypeTask extends PhabricatorPHIDType {
$handle->setFullName("T{$id}: {$title}"); $handle->setFullName("T{$id}: {$title}");
$handle->setURI("/T{$id}"); $handle->setURI("/T{$id}");
if (!ManiphestTaskStatus::isOpenStatus($task->getStatus())) { if ($task->isClosed()) {
$handle->setStatus(PhabricatorObjectHandleStatus::STATUS_CLOSED); $handle->setStatus(PhabricatorObjectHandleStatus::STATUS_CLOSED);
} }
} }

View file

@ -349,9 +349,15 @@ final class ManiphestTaskQuery
case self::STATUS_ANY: case self::STATUS_ANY:
return null; return null;
case self::STATUS_OPEN: case self::STATUS_OPEN:
return 'status = 0'; return qsprintf(
$conn,
'status IN (%Ld)',
ManiphestTaskStatus::getOpenStatusConstants());
case self::STATUS_CLOSED: case self::STATUS_CLOSED:
return 'status > 0'; return qsprintf(
$conn,
'status IN (%Ld)',
ManiphestTaskStatus::getClosedStatusConstants());
default: default:
$constant = idx($map, $this->status); $constant = idx($map, $this->status);
if (!$constant) { if (!$constant) {

View file

@ -31,9 +31,9 @@ final class ManiphestSearchIndexer
$task->getDateCreated()); $task->getDateCreated());
$doc->addRelationship( $doc->addRelationship(
(ManiphestTaskStatus::isOpenStatus($task->getStatus())) $task->isClosed()
? PhabricatorSearchRelationship::RELATIONSHIP_OPEN ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED
: PhabricatorSearchRelationship::RELATIONSHIP_CLOSED, : PhabricatorSearchRelationship::RELATIONSHIP_OPEN,
$task->getPHID(), $task->getPHID(),
ManiphestPHIDTypeTask::TYPECONST, ManiphestPHIDTypeTask::TYPECONST,
time()); time());

View file

@ -156,6 +156,9 @@ final class ManiphestTask extends ManiphestDAO
return $result; return $result;
} }
public function isClosed() {
return ManiphestTaskStatus::isClosedStatus($this->getStatus());
}
/* -( Markup Interface )--------------------------------------------------- */ /* -( Markup Interface )--------------------------------------------------- */
@ -247,6 +250,7 @@ final class ManiphestTask extends ManiphestDAO
/* -( PhabricatorTokenReceiverInterface )---------------------------------- */ /* -( PhabricatorTokenReceiverInterface )---------------------------------- */
public function getUsersToNotifyOfTokenGiven() { public function getUsersToNotifyOfTokenGiven() {
// Sort of ambiguous who this was intended for; just let them both know. // Sort of ambiguous who this was intended for; just let them both know.
return array_filter( return array_filter(

View file

@ -139,11 +139,11 @@ final class ManiphestTransaction
} }
case self::TYPE_STATUS: case self::TYPE_STATUS:
if ($new == ManiphestTaskStatus::STATUS_OPEN) { $color = ManiphestTaskStatus::getStatusColor($new);
return 'green'; if ($color !== null) {
} else { return $color;
return 'black';
} }
break;
case self::TYPE_PRIORITY: case self::TYPE_PRIORITY:
if ($old == ManiphestTaskPriority::getDefaultPriority()) { if ($old == ManiphestTaskPriority::getDefaultPriority()) {
@ -168,19 +168,24 @@ final class ManiphestTransaction
return pht('Retitled'); return pht('Retitled');
case self::TYPE_STATUS: case self::TYPE_STATUS:
switch ($new) { if ($old === null) {
case ManiphestTaskStatus::STATUS_OPEN: return pht('Created');
if ($old === null) { }
return pht('Created');
} else { $action = ManiphestTaskStatus::getStatusActionName($new);
return pht('Reopened'); if ($action) {
} return $action;
case ManiphestTaskStatus::STATUS_CLOSED_SPITE: }
return pht('Spited');
case ManiphestTaskStatus::STATUS_CLOSED_DUPLICATE: $old_closed = ManiphestTaskStatus::isClosedStatus($old);
return pht('Merged'); $new_closed = ManiphestTaskStatus::isClosedStatus($new);
default:
return pht('Closed'); if ($new_closed && !$old_closed) {
return pht('Closed');
} else if (!$new_closed && $old_closed) {
return pht('Reopened');
} else {
return pht('Changed Status');
} }
case self::TYPE_DESCRIPTION: case self::TYPE_DESCRIPTION:
@ -238,15 +243,19 @@ final class ManiphestTransaction
return 'edit'; return 'edit';
case self::TYPE_STATUS: case self::TYPE_STATUS:
switch ($new) { if ($old === null) {
case ManiphestTaskStatus::STATUS_OPEN: return 'create';
return 'create'; }
case ManiphestTaskStatus::STATUS_CLOSED_SPITE:
return 'dislike'; $action = ManiphestTaskStatus::getStatusIcon($new);
case ManiphestTaskStatus::STATUS_CLOSED_DUPLICATE: if ($action !== null) {
return 'delete'; return $action;
default: }
return 'check';
if (ManiphestTaskStatus::isClosedStatus($new)) {
return 'check';
} else {
return 'edit';
} }
case self::TYPE_DESCRIPTION: case self::TYPE_DESCRIPTION:
@ -299,35 +308,40 @@ final class ManiphestTransaction
$this->renderHandleLink($author_phid)); $this->renderHandleLink($author_phid));
case self::TYPE_STATUS: case self::TYPE_STATUS:
switch ($new) { if ($old === null) {
case ManiphestTaskStatus::STATUS_OPEN: return pht(
if ($old === null) { '%s created this task.',
return pht( $this->renderHandleLink($author_phid));
'%s created this task.', }
$this->renderHandleLink($author_phid));
} else {
return pht(
'%s reopened this task.',
$this->renderHandleLink($author_phid));
}
case ManiphestTaskStatus::STATUS_CLOSED_SPITE: $old_closed = ManiphestTaskStatus::isClosedStatus($old);
return pht( $new_closed = ManiphestTaskStatus::isClosedStatus($new);
'%s closed this task out of spite.',
$this->renderHandleLink($author_phid)); $old_name = ManiphestTaskStatus::getTaskStatusName($old);
case ManiphestTaskStatus::STATUS_CLOSED_DUPLICATE: $new_name = ManiphestTaskStatus::getTaskStatusName($new);
if ($new_closed && !$old_closed) {
if ($new == ManiphestTaskStatus::getDuplicateStatus()) {
return pht( return pht(
'%s closed this task as a duplicate.', '%s closed this task as a duplicate.',
$this->renderHandleLink($author_phid)); $this->renderHandleLink($author_phid));
default: } else {
$status_name = idx(
ManiphestTaskStatus::getTaskStatusMap(),
$new,
'???');
return pht( return pht(
'%s closed this task as "%s".', '%s closed this task as "%s".',
$this->renderHandleLink($author_phid), $this->renderHandleLink($author_phid),
$status_name); $new_name);
}
} else if (!$new_closed && $old_closed) {
return pht(
'%s reopened this task as "%s".',
$this->renderHandleLink($author_phid),
$new_name);
} else {
return pht(
'%s changed the task status from "%s" to "%s".',
$this->renderHandleLink($author_phid),
$old_name,
$new_name);
} }
case self::TYPE_OWNER: case self::TYPE_OWNER:
@ -488,40 +502,45 @@ final class ManiphestTransaction
$this->renderHandleLink($object_phid)); $this->renderHandleLink($object_phid));
case self::TYPE_STATUS: case self::TYPE_STATUS:
switch ($new) { if ($old === null) {
case ManiphestTaskStatus::STATUS_OPEN: return pht(
if ($old === null) { '%s created %s.',
return pht( $this->renderHandleLink($author_phid),
'%s created %s.', $this->renderHandleLink($object_phid));
$this->renderHandleLink($author_phid), }
$this->renderHandleLink($object_phid));
} else {
return pht(
'%s reopened %s.',
$this->renderHandleLink($author_phid),
$this->renderHandleLink($object_phid));
}
case ManiphestTaskStatus::STATUS_CLOSED_SPITE: $old_closed = ManiphestTaskStatus::isClosedStatus($old);
return pht( $new_closed = ManiphestTaskStatus::isClosedStatus($new);
'%s closed %s out of spite.',
$this->renderHandleLink($author_phid), $old_name = ManiphestTaskStatus::getTaskStatusName($old);
$this->renderHandleLink($object_phid)); $new_name = ManiphestTaskStatus::getTaskStatusName($new);
case ManiphestTaskStatus::STATUS_CLOSED_DUPLICATE:
if ($new_closed && !$old_closed) {
if ($new == ManiphestTaskStatus::getDuplicateStatus()) {
return pht( return pht(
'%s closed %s as a duplicate.', '%s closed %s as a duplicate.',
$this->renderHandleLink($author_phid), $this->renderHandleLink($author_phid),
$this->renderHandleLink($object_phid)); $this->renderHandleLink($object_phid));
default: } else {
$status_name = idx(
ManiphestTaskStatus::getTaskStatusMap(),
$new,
'???');
return pht( return pht(
'%s closed %s as "%s".', '%s closed %s as "%s".',
$this->renderHandleLink($author_phid), $this->renderHandleLink($author_phid),
$this->renderHandleLink($object_phid), $this->renderHandleLink($object_phid),
$status_name); $new_name);
}
} else if (!$new_closed && $old_closed) {
return pht(
'%s reopened %s as "%s".',
$this->renderHandleLink($author_phid),
$this->renderHandleLink($object_phid),
$new_name);
} else {
return pht(
'%s changed the status of %s from "%s" to "%s".',
$this->renderHandleLink($author_phid),
$this->renderHandleLink($object_phid),
$old_name,
$new_name);
} }
case self::TYPE_OWNER: case self::TYPE_OWNER:

View file

@ -58,7 +58,7 @@ final class ManiphestTaskListView extends ManiphestView {
} }
$status = $task->getStatus(); $status = $task->getStatus();
if ($status != ManiphestTaskStatus::STATUS_OPEN) { if ($task->isClosed()) {
$item->setDisabled(true); $item->setDisabled(true);
} }

View file

@ -1,8 +1,5 @@
<?php <?php
/**
* @group maniphest
*/
abstract class ManiphestView extends AphrontView { abstract class ManiphestView extends AphrontView {
public static function renderTagForTask(ManiphestTask $task) { public static function renderTagForTask(ManiphestTask $task) {

View file

@ -178,7 +178,7 @@ final class PhabricatorSearchAttachController
$close_task = id(new ManiphestTransaction()) $close_task = id(new ManiphestTransaction())
->setTransactionType(ManiphestTransaction::TYPE_STATUS) ->setTransactionType(ManiphestTransaction::TYPE_STATUS)
->setNewValue(ManiphestTaskStatus::STATUS_CLOSED_DUPLICATE); ->setNewValue(ManiphestTaskStatus::getDuplicateStatus());
$merge_comment = id(new ManiphestTransaction()) $merge_comment = id(new ManiphestTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_COMMENT) ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)

View file

@ -24,7 +24,7 @@ JX.behavior('maniphest-batch-editor', function(config) {
'add_project': 'Add Projects', 'add_project': 'Add Projects',
'remove_project' : 'Remove Projects', 'remove_project' : 'Remove Projects',
'priority': 'Change Priority', 'priority': 'Change Priority',
'status': 'Open / Close', 'status': 'Change Status',
'add_comment': 'Comment', 'add_comment': 'Comment',
'assign': 'Assign', 'assign': 'Assign',
'add_ccs' : 'Add CCs', 'add_ccs' : 'Add CCs',