@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+179 -115
+55 -4
src/applications/maniphest/constants/ManiphestTaskStatus.php
··· 1 1 <?php 2 2 3 - /** 4 - * @group maniphest 5 - */ 6 3 final class ManiphestTaskStatus extends ManiphestConstants { 7 4 8 5 const STATUS_OPEN = 0; ··· 23 20 $duplicate = pht('Duplicate'); 24 21 $spite = pht('Spite'); 25 22 26 - return array( 23 + $statuses = array( 27 24 self::STATUS_OPEN => $open, 28 25 self::STATUS_CLOSED_RESOLVED => $resolved, 29 26 self::STATUS_CLOSED_WONTFIX => $wontfix, ··· 31 28 self::STATUS_CLOSED_DUPLICATE => $duplicate, 32 29 self::STATUS_CLOSED_SPITE => $spite, 33 30 ); 31 + 32 + $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); 33 + if (!$is_serious) { 34 + $statuses[self::STATUS_CLOSED_SPITE] = pht('Spite'); 35 + } 36 + 37 + return $statuses; 38 + } 39 + 40 + public static function getTaskStatusName($status) { 41 + return idx(self::getTaskStatusMap(), $status, pht('Unknown Status')); 34 42 } 35 43 36 44 public static function getTaskStatusFullName($status) { ··· 103 111 return self::STATUS_OPEN; 104 112 } 105 113 114 + public static function getDefaultClosedStatus() { 115 + return self::STATUS_CLOSED_RESOLVED; 116 + } 117 + 118 + public static function getDuplicateStatus() { 119 + return self::STATUS_CLOSED_DUPLICATE; 120 + } 121 + 106 122 public static function getOpenStatusConstants() { 107 123 return array( 108 124 self::STATUS_OPEN, 109 125 ); 126 + } 127 + 128 + public static function getClosedStatusConstants() { 129 + $all = array_keys(self::getTaskStatusMap()); 130 + $open = self::getOpenStatusConstants(); 131 + return array_diff($all, $open); 110 132 } 111 133 112 134 public static function isOpenStatus($status) { ··· 117 139 } 118 140 return false; 119 141 } 142 + 143 + public static function isClosedStatus($status) { 144 + return !self::isOpenStatus($status); 145 + } 146 + 147 + public static function getStatusActionName($status) { 148 + switch ($status) { 149 + case self::STATUS_CLOSED_SPITE: 150 + return pht('Spited'); 151 + } 152 + return null; 153 + } 154 + 155 + public static function getStatusColor($status) { 156 + if (self::isOpenStatus($status)) { 157 + return 'green'; 158 + } 159 + return 'black'; 160 + } 161 + 162 + public static function getStatusIcon($status) { 163 + switch ($status) { 164 + case ManiphestTaskStatus::STATUS_CLOSED_SPITE: 165 + return 'dislike'; 166 + case ManiphestTaskStatus::STATUS_CLOSED_DUPLICATE: 167 + return 'delete'; 168 + } 169 + } 170 + 120 171 121 172 public static function getStatusPrefixMap() { 122 173 return array(
+10 -23
src/applications/maniphest/controller/ManiphestTaskDetailController.php
··· 151 151 152 152 $transaction_types = array( 153 153 PhabricatorTransactions::TYPE_COMMENT => pht('Comment'), 154 - ManiphestTransaction::TYPE_STATUS => pht('Close Task'), 154 + ManiphestTransaction::TYPE_STATUS => pht('Change Status'), 155 155 ManiphestTransaction::TYPE_OWNER => pht('Reassign / Claim'), 156 156 ManiphestTransaction::TYPE_CCS => pht('Add CCs'), 157 157 ManiphestTransaction::TYPE_PRIORITY => pht('Change Priority'), ··· 180 180 } 181 181 } 182 182 183 - if ($task->getStatus() == ManiphestTaskStatus::STATUS_OPEN) { 184 - $resolution_types = array_select_keys( 185 - $resolution_types, 186 - array( 187 - ManiphestTaskStatus::STATUS_CLOSED_RESOLVED, 188 - ManiphestTaskStatus::STATUS_CLOSED_WONTFIX, 189 - ManiphestTaskStatus::STATUS_CLOSED_INVALID, 190 - ManiphestTaskStatus::STATUS_CLOSED_SPITE, 191 - )); 192 - } else { 193 - $resolution_types = array( 194 - ManiphestTaskStatus::STATUS_OPEN => 'Reopened', 195 - ); 196 - $transaction_types[ManiphestTransaction::TYPE_STATUS] = 197 - 'Reopen Task'; 183 + // Don't show an option to change to the current status, or to change to 184 + // the duplicate status explicitly. 185 + unset($resolution_types[$task->getStatus()]); 186 + unset($resolution_types[ManiphestTaskStatus::getDuplicateStatus()]); 187 + 188 + // Don't show owner/priority changes for closed tasks, as they don't make 189 + // much sense. 190 + if ($task->isClosed()) { 198 191 unset($transaction_types[ManiphestTransaction::TYPE_PRIORITY]); 199 192 unset($transaction_types[ManiphestTransaction::TYPE_OWNER]); 200 193 } ··· 215 208 216 209 $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); 217 210 218 - if ($is_serious) { 219 - // Prevent tasks from being closed "out of spite" in serious business 220 - // installs. 221 - unset($resolution_types[ManiphestTaskStatus::STATUS_CLOSED_SPITE]); 222 - } 223 - 224 211 $comment_form = new AphrontFormView(); 225 212 $comment_form 226 213 ->setUser($user) ··· 236 223 ->setID('transaction-action')) 237 224 ->appendChild( 238 225 id(new AphrontFormSelectControl()) 239 - ->setLabel(pht('Resolution')) 226 + ->setLabel(pht('Status')) 240 227 ->setName('resolution') 241 228 ->setControlID('resolution') 242 229 ->setControlStyle('display: none')
+2 -2
src/applications/maniphest/controller/ManiphestTransactionSaveController.php
··· 147 147 $added_ccs[] = $task->getOwnerPHID(); 148 148 break; 149 149 case ManiphestTransaction::TYPE_STATUS: 150 + $resolution = $request->getStr('resolution'); 150 151 if (!$task->getOwnerPHID() && 151 - $request->getStr('resolution') != 152 - ManiphestTaskStatus::STATUS_OPEN) { 152 + ManiphestTaskStatus::isClosedStatus($resolution)) { 153 153 // Closing an unassigned task. Assign the user as the owner of 154 154 // this task. 155 155 $assign = new ManiphestTransaction();
+1 -1
src/applications/maniphest/mail/ManiphestReplyHandler.php
··· 82 82 switch ($command) { 83 83 case 'close': 84 84 $ttype = ManiphestTransaction::TYPE_STATUS; 85 - $new_value = ManiphestTaskStatus::STATUS_CLOSED_RESOLVED; 85 + $new_value = ManiphestTaskStatus::getDefaultClosedStatus(); 86 86 break; 87 87 case 'claim': 88 88 $ttype = ManiphestTransaction::TYPE_OWNER;
+1 -1
src/applications/maniphest/phid/ManiphestPHIDTypeTask.php
··· 38 38 $handle->setFullName("T{$id}: {$title}"); 39 39 $handle->setURI("/T{$id}"); 40 40 41 - if (!ManiphestTaskStatus::isOpenStatus($task->getStatus())) { 41 + if ($task->isClosed()) { 42 42 $handle->setStatus(PhabricatorObjectHandleStatus::STATUS_CLOSED); 43 43 } 44 44 }
+8 -2
src/applications/maniphest/query/ManiphestTaskQuery.php
··· 349 349 case self::STATUS_ANY: 350 350 return null; 351 351 case self::STATUS_OPEN: 352 - return 'status = 0'; 352 + return qsprintf( 353 + $conn, 354 + 'status IN (%Ld)', 355 + ManiphestTaskStatus::getOpenStatusConstants()); 353 356 case self::STATUS_CLOSED: 354 - return 'status > 0'; 357 + return qsprintf( 358 + $conn, 359 + 'status IN (%Ld)', 360 + ManiphestTaskStatus::getClosedStatusConstants()); 355 361 default: 356 362 $constant = idx($map, $this->status); 357 363 if (!$constant) {
+3 -3
src/applications/maniphest/search/ManiphestSearchIndexer.php
··· 31 31 $task->getDateCreated()); 32 32 33 33 $doc->addRelationship( 34 - (ManiphestTaskStatus::isOpenStatus($task->getStatus())) 35 - ? PhabricatorSearchRelationship::RELATIONSHIP_OPEN 36 - : PhabricatorSearchRelationship::RELATIONSHIP_CLOSED, 34 + $task->isClosed() 35 + ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED 36 + : PhabricatorSearchRelationship::RELATIONSHIP_OPEN, 37 37 $task->getPHID(), 38 38 ManiphestPHIDTypeTask::TYPECONST, 39 39 time());
+4
src/applications/maniphest/storage/ManiphestTask.php
··· 156 156 return $result; 157 157 } 158 158 159 + public function isClosed() { 160 + return ManiphestTaskStatus::isClosedStatus($this->getStatus()); 161 + } 159 162 160 163 161 164 /* -( Markup Interface )--------------------------------------------------- */ ··· 246 249 247 250 248 251 /* -( PhabricatorTokenReceiverInterface )---------------------------------- */ 252 + 249 253 250 254 public function getUsersToNotifyOfTokenGiven() { 251 255 // Sort of ambiguous who this was intended for; just let them both know.
+92 -73
src/applications/maniphest/storage/ManiphestTransaction.php
··· 139 139 } 140 140 141 141 case self::TYPE_STATUS: 142 - if ($new == ManiphestTaskStatus::STATUS_OPEN) { 143 - return 'green'; 144 - } else { 145 - return 'black'; 142 + $color = ManiphestTaskStatus::getStatusColor($new); 143 + if ($color !== null) { 144 + return $color; 146 145 } 146 + break; 147 147 148 148 case self::TYPE_PRIORITY: 149 149 if ($old == ManiphestTaskPriority::getDefaultPriority()) { ··· 168 168 return pht('Retitled'); 169 169 170 170 case self::TYPE_STATUS: 171 - switch ($new) { 172 - case ManiphestTaskStatus::STATUS_OPEN: 173 - if ($old === null) { 174 - return pht('Created'); 175 - } else { 176 - return pht('Reopened'); 177 - } 178 - case ManiphestTaskStatus::STATUS_CLOSED_SPITE: 179 - return pht('Spited'); 180 - case ManiphestTaskStatus::STATUS_CLOSED_DUPLICATE: 181 - return pht('Merged'); 182 - default: 183 - return pht('Closed'); 171 + if ($old === null) { 172 + return pht('Created'); 173 + } 174 + 175 + $action = ManiphestTaskStatus::getStatusActionName($new); 176 + if ($action) { 177 + return $action; 178 + } 179 + 180 + $old_closed = ManiphestTaskStatus::isClosedStatus($old); 181 + $new_closed = ManiphestTaskStatus::isClosedStatus($new); 182 + 183 + if ($new_closed && !$old_closed) { 184 + return pht('Closed'); 185 + } else if (!$new_closed && $old_closed) { 186 + return pht('Reopened'); 187 + } else { 188 + return pht('Changed Status'); 184 189 } 185 190 186 191 case self::TYPE_DESCRIPTION: ··· 238 243 return 'edit'; 239 244 240 245 case self::TYPE_STATUS: 241 - switch ($new) { 242 - case ManiphestTaskStatus::STATUS_OPEN: 243 - return 'create'; 244 - case ManiphestTaskStatus::STATUS_CLOSED_SPITE: 245 - return 'dislike'; 246 - case ManiphestTaskStatus::STATUS_CLOSED_DUPLICATE: 247 - return 'delete'; 248 - default: 249 - return 'check'; 246 + if ($old === null) { 247 + return 'create'; 248 + } 249 + 250 + $action = ManiphestTaskStatus::getStatusIcon($new); 251 + if ($action !== null) { 252 + return $action; 253 + } 254 + 255 + if (ManiphestTaskStatus::isClosedStatus($new)) { 256 + return 'check'; 257 + } else { 258 + return 'edit'; 250 259 } 251 260 252 261 case self::TYPE_DESCRIPTION: ··· 299 308 $this->renderHandleLink($author_phid)); 300 309 301 310 case self::TYPE_STATUS: 302 - switch ($new) { 303 - case ManiphestTaskStatus::STATUS_OPEN: 304 - if ($old === null) { 305 - return pht( 306 - '%s created this task.', 307 - $this->renderHandleLink($author_phid)); 308 - } else { 309 - return pht( 310 - '%s reopened this task.', 311 - $this->renderHandleLink($author_phid)); 312 - } 311 + if ($old === null) { 312 + return pht( 313 + '%s created this task.', 314 + $this->renderHandleLink($author_phid)); 315 + } 316 + 317 + $old_closed = ManiphestTaskStatus::isClosedStatus($old); 318 + $new_closed = ManiphestTaskStatus::isClosedStatus($new); 319 + 320 + $old_name = ManiphestTaskStatus::getTaskStatusName($old); 321 + $new_name = ManiphestTaskStatus::getTaskStatusName($new); 313 322 314 - case ManiphestTaskStatus::STATUS_CLOSED_SPITE: 315 - return pht( 316 - '%s closed this task out of spite.', 317 - $this->renderHandleLink($author_phid)); 318 - case ManiphestTaskStatus::STATUS_CLOSED_DUPLICATE: 323 + if ($new_closed && !$old_closed) { 324 + if ($new == ManiphestTaskStatus::getDuplicateStatus()) { 319 325 return pht( 320 326 '%s closed this task as a duplicate.', 321 327 $this->renderHandleLink($author_phid)); 322 - default: 323 - $status_name = idx( 324 - ManiphestTaskStatus::getTaskStatusMap(), 325 - $new, 326 - '???'); 328 + } else { 327 329 return pht( 328 330 '%s closed this task as "%s".', 329 331 $this->renderHandleLink($author_phid), 330 - $status_name); 332 + $new_name); 333 + } 334 + } else if (!$new_closed && $old_closed) { 335 + return pht( 336 + '%s reopened this task as "%s".', 337 + $this->renderHandleLink($author_phid), 338 + $new_name); 339 + } else { 340 + return pht( 341 + '%s changed the task status from "%s" to "%s".', 342 + $this->renderHandleLink($author_phid), 343 + $old_name, 344 + $new_name); 331 345 } 332 346 333 347 case self::TYPE_OWNER: ··· 488 502 $this->renderHandleLink($object_phid)); 489 503 490 504 case self::TYPE_STATUS: 491 - switch ($new) { 492 - case ManiphestTaskStatus::STATUS_OPEN: 493 - if ($old === null) { 494 - return pht( 495 - '%s created %s.', 496 - $this->renderHandleLink($author_phid), 497 - $this->renderHandleLink($object_phid)); 498 - } else { 499 - return pht( 500 - '%s reopened %s.', 501 - $this->renderHandleLink($author_phid), 502 - $this->renderHandleLink($object_phid)); 503 - } 505 + if ($old === null) { 506 + return pht( 507 + '%s created %s.', 508 + $this->renderHandleLink($author_phid), 509 + $this->renderHandleLink($object_phid)); 510 + } 504 511 505 - case ManiphestTaskStatus::STATUS_CLOSED_SPITE: 506 - return pht( 507 - '%s closed %s out of spite.', 508 - $this->renderHandleLink($author_phid), 509 - $this->renderHandleLink($object_phid)); 510 - case ManiphestTaskStatus::STATUS_CLOSED_DUPLICATE: 512 + $old_closed = ManiphestTaskStatus::isClosedStatus($old); 513 + $new_closed = ManiphestTaskStatus::isClosedStatus($new); 514 + 515 + $old_name = ManiphestTaskStatus::getTaskStatusName($old); 516 + $new_name = ManiphestTaskStatus::getTaskStatusName($new); 517 + 518 + if ($new_closed && !$old_closed) { 519 + if ($new == ManiphestTaskStatus::getDuplicateStatus()) { 511 520 return pht( 512 521 '%s closed %s as a duplicate.', 513 522 $this->renderHandleLink($author_phid), 514 523 $this->renderHandleLink($object_phid)); 515 - default: 516 - $status_name = idx( 517 - ManiphestTaskStatus::getTaskStatusMap(), 518 - $new, 519 - '???'); 524 + } else { 520 525 return pht( 521 526 '%s closed %s as "%s".', 522 527 $this->renderHandleLink($author_phid), 523 528 $this->renderHandleLink($object_phid), 524 - $status_name); 529 + $new_name); 530 + } 531 + } else if (!$new_closed && $old_closed) { 532 + return pht( 533 + '%s reopened %s as "%s".', 534 + $this->renderHandleLink($author_phid), 535 + $this->renderHandleLink($object_phid), 536 + $new_name); 537 + } else { 538 + return pht( 539 + '%s changed the status of %s from "%s" to "%s".', 540 + $this->renderHandleLink($author_phid), 541 + $this->renderHandleLink($object_phid), 542 + $old_name, 543 + $new_name); 525 544 } 526 545 527 546 case self::TYPE_OWNER:
+1 -1
src/applications/maniphest/view/ManiphestTaskListView.php
··· 58 58 } 59 59 60 60 $status = $task->getStatus(); 61 - if ($status != ManiphestTaskStatus::STATUS_OPEN) { 61 + if ($task->isClosed()) { 62 62 $item->setDisabled(true); 63 63 } 64 64
-3
src/applications/maniphest/view/ManiphestView.php
··· 1 1 <?php 2 2 3 - /** 4 - * @group maniphest 5 - */ 6 3 abstract class ManiphestView extends AphrontView { 7 4 8 5 public static function renderTagForTask(ManiphestTask $task) {
+1 -1
src/applications/search/controller/PhabricatorSearchAttachController.php
··· 178 178 179 179 $close_task = id(new ManiphestTransaction()) 180 180 ->setTransactionType(ManiphestTransaction::TYPE_STATUS) 181 - ->setNewValue(ManiphestTaskStatus::STATUS_CLOSED_DUPLICATE); 181 + ->setNewValue(ManiphestTaskStatus::getDuplicateStatus()); 182 182 183 183 $merge_comment = id(new ManiphestTransaction()) 184 184 ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
+1 -1
webroot/rsrc/js/application/maniphest/behavior-batch-editor.js
··· 24 24 'add_project': 'Add Projects', 25 25 'remove_project' : 'Remove Projects', 26 26 'priority': 'Change Priority', 27 - 'status': 'Open / Close', 27 + 'status': 'Change Status', 28 28 'add_comment': 'Comment', 29 29 'assign': 'Assign', 30 30 'add_ccs' : 'Add CCs',