@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.

Modularize the Differential "status" transaction and move away from ArcanistDifferentialRevisionStatus

Summary:
Ref T2543. Converts the TYPE_STATUS transaction (used to render "This revision now requires changes to proceed.", "This revision is accepted and ready to land.", etc) to ModularTransactions.

Also, continue consolidating all the status-related information (here, more colors and icons) into a single place. By the end of this, we may learn that NEEDS_REVIEW uses //every// color.

Test Plan:
Reviewed old status transactions (unchanged) and created new ones (looked the same as the old ones).

(I plan to migrate all of these a few diffs from now, around when I change the storage format.)

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T2543

Differential Revision: https://secure.phabricator.com/D18410

+116 -51
+2
src/__phutil_library_map__.php
··· 575 575 'DifferentialRevisionStatus' => 'applications/differential/constants/DifferentialRevisionStatus.php', 576 576 'DifferentialRevisionStatusDatasource' => 'applications/differential/typeahead/DifferentialRevisionStatusDatasource.php', 577 577 'DifferentialRevisionStatusFunctionDatasource' => 'applications/differential/typeahead/DifferentialRevisionStatusFunctionDatasource.php', 578 + 'DifferentialRevisionStatusTransaction' => 'applications/differential/xaction/DifferentialRevisionStatusTransaction.php', 578 579 'DifferentialRevisionSummaryHeraldField' => 'applications/differential/herald/DifferentialRevisionSummaryHeraldField.php', 579 580 'DifferentialRevisionSummaryTransaction' => 'applications/differential/xaction/DifferentialRevisionSummaryTransaction.php', 580 581 'DifferentialRevisionTestPlanTransaction' => 'applications/differential/xaction/DifferentialRevisionTestPlanTransaction.php', ··· 5571 5572 'DifferentialRevisionStatus' => 'Phobject', 5572 5573 'DifferentialRevisionStatusDatasource' => 'PhabricatorTypeaheadDatasource', 5573 5574 'DifferentialRevisionStatusFunctionDatasource' => 'PhabricatorTypeaheadCompositeDatasource', 5575 + 'DifferentialRevisionStatusTransaction' => 'DifferentialRevisionTransactionType', 5574 5576 'DifferentialRevisionSummaryHeraldField' => 'DifferentialRevisionHeraldField', 5575 5577 'DifferentialRevisionSummaryTransaction' => 'DifferentialRevisionTransactionType', 5576 5578 'DifferentialRevisionTestPlanTransaction' => 'DifferentialRevisionTransactionType',
+18
src/applications/differential/constants/DifferentialRevisionStatus.php
··· 32 32 return idx($this->spec, 'color.tag', 'bluegrey'); 33 33 } 34 34 35 + public function getTimelineIcon() { 36 + return idx($this->spec, 'icon.timeline'); 37 + } 38 + 39 + public function getTimelineColor() { 40 + return idx($this->spec, 'color.timeline'); 41 + } 42 + 35 43 public function getANSIColor() { 36 44 return idx($this->spec, 'color.ansi'); 37 45 } ··· 56 64 return ($this->key === self::NEEDS_REVIEW); 57 65 } 58 66 67 + public function isNeedsRevision() { 68 + return ($this->key === self::NEEDS_REVISION); 69 + } 70 + 59 71 public function isPublished() { 60 72 return ($this->key === self::PUBLISHED); 61 73 } ··· 116 128 'name' => pht('Needs Review'), 117 129 'legacy' => 0, 118 130 'icon' => 'fa-code', 131 + 'icon.timeline' => 'fa-undo', 119 132 'closed' => false, 120 133 'color.icon' => 'grey', 121 134 'color.tag' => 'bluegrey', 122 135 'color.ansi' => 'magenta', 136 + 'color.timeline' => 'orange', 123 137 ), 124 138 self::NEEDS_REVISION => array( 125 139 'name' => pht('Needs Revision'), 126 140 'legacy' => 1, 127 141 'icon' => 'fa-refresh', 142 + 'icon.timeline' => 'fa-times', 128 143 'closed' => false, 129 144 'color.icon' => 'red', 130 145 'color.tag' => 'red', 131 146 'color.ansi' => 'red', 147 + 'color.timeline' => 'red', 132 148 ), 133 149 self::CHANGES_PLANNED => array( 134 150 'name' => pht('Changes Planned'), ··· 143 159 'name' => pht('Accepted'), 144 160 'legacy' => 2, 145 161 'icon' => 'fa-check', 162 + 'icon.timeline' => 'fa-check', 146 163 'closed' => $close_on_accept, 147 164 'color.icon' => 'green', 148 165 'color.tag' => 'green', 149 166 'color.ansi' => 'green', 167 + 'color.timeline' => 'green', 150 168 ), 151 169 self::PUBLISHED => array( 152 170 'name' => pht('Closed'),
+2 -2
src/applications/differential/editor/DifferentialTransactionEditor.php
··· 71 71 72 72 $types[] = DifferentialTransaction::TYPE_ACTION; 73 73 $types[] = DifferentialTransaction::TYPE_INLINE; 74 - $types[] = DifferentialTransaction::TYPE_STATUS; 75 74 $types[] = DifferentialTransaction::TYPE_UPDATE; 76 75 77 76 return $types; ··· 606 605 607 606 if ($new_status !== null && ($new_status != $old_status)) { 608 607 $xaction = id(new DifferentialTransaction()) 609 - ->setTransactionType(DifferentialTransaction::TYPE_STATUS) 608 + ->setTransactionType( 609 + DifferentialRevisionStatusTransaction::TRANSACTIONTYPE) 610 610 ->setOldValue($old_status) 611 611 ->setNewValue($new_status); 612 612
+20 -49
src/applications/differential/storage/DifferentialTransaction.php
··· 8 8 const TYPE_INLINE = 'differential:inline'; 9 9 const TYPE_UPDATE = 'differential:update'; 10 10 const TYPE_ACTION = 'differential:action'; 11 - const TYPE_STATUS = 'differential:status'; 12 11 13 12 const MAILTAG_REVIEWERS = 'differential-reviewers'; 14 13 const MAILTAG_CLOSED = 'differential-committed'; ··· 40 39 case 'differential:repository': 41 40 return new DifferentialRevisionRepositoryTransaction(); 42 41 } 42 + } 43 + 44 + if ($xaction_type == 'differential:status') { 45 + return new DifferentialRevisionStatusTransaction(); 43 46 } 44 47 45 48 return parent::newFallbackModularTransactionType(); ··· 305 308 return DifferentialAction::getBasicStoryText($new, $author_handle); 306 309 } 307 310 break; 308 - case self::TYPE_STATUS: 309 - switch ($this->getNewValue()) { 310 - case ArcanistDifferentialRevisionStatus::ACCEPTED: 311 - return pht('This revision is now accepted and ready to land.'); 312 - case ArcanistDifferentialRevisionStatus::NEEDS_REVISION: 313 - return pht('This revision now requires changes to proceed.'); 314 - case ArcanistDifferentialRevisionStatus::NEEDS_REVIEW: 315 - return pht('This revision now requires review to proceed.'); 316 - } 317 311 } 318 312 319 313 return parent::getTitle(); ··· 457 451 $object_link); 458 452 } 459 453 break; 460 - case self::TYPE_STATUS: 461 - switch ($this->getNewValue()) { 462 - case ArcanistDifferentialRevisionStatus::ACCEPTED: 463 - return pht( 464 - '%s is now accepted and ready to land.', 465 - $object_link); 466 - case ArcanistDifferentialRevisionStatus::NEEDS_REVISION: 467 - return pht( 468 - '%s now requires changes to proceed.', 469 - $object_link); 470 - case ArcanistDifferentialRevisionStatus::NEEDS_REVIEW: 471 - return pht( 472 - '%s now requires review to proceed.', 473 - $object_link); 474 - } 475 454 } 476 455 477 456 return parent::getTitleForFeed(); ··· 483 462 return 'fa-comment'; 484 463 case self::TYPE_UPDATE: 485 464 return 'fa-refresh'; 486 - case self::TYPE_STATUS: 487 - switch ($this->getNewValue()) { 488 - case ArcanistDifferentialRevisionStatus::ACCEPTED: 489 - return 'fa-check'; 490 - case ArcanistDifferentialRevisionStatus::NEEDS_REVISION: 491 - return 'fa-times'; 492 - case ArcanistDifferentialRevisionStatus::NEEDS_REVIEW: 493 - return 'fa-undo'; 494 - } 495 - break; 496 465 case self::TYPE_ACTION: 497 466 switch ($this->getNewValue()) { 498 467 case DifferentialAction::ACTION_CLOSE: ··· 530 499 // Never group status changes with other types of actions, they're indirect 531 500 // and don't make sense when combined with direct actions. 532 501 533 - $type_status = self::TYPE_STATUS; 534 - 535 - if ($this->getTransactionType() == $type_status) { 502 + if ($this->isStatusTransaction($this)) { 536 503 return false; 537 504 } 538 505 539 506 foreach ($group as $xaction) { 540 - if ($xaction->getTransactionType() == $type_status) { 507 + if ($this->isStatusTransaction($xaction)) { 541 508 return false; 542 509 } 543 510 } ··· 545 512 return parent::shouldDisplayGroupWith($group); 546 513 } 547 514 515 + private function isStatusTransaction($xaction) { 516 + $old_status = 'differential:status'; 517 + if ($xaction->getTransactionType() == $old_status) { 518 + return true; 519 + } 520 + 521 + $new_status = DifferentialRevisionStatusTransaction::TRANSACTIONTYPE; 522 + if ($xaction->getTransactionType() == $new_status) { 523 + return true; 524 + } 525 + 526 + return false; 527 + } 528 + 548 529 549 530 public function getColor() { 550 531 switch ($this->getTransactionType()) { 551 532 case self::TYPE_UPDATE: 552 533 return PhabricatorTransactions::COLOR_SKY; 553 - case self::TYPE_STATUS: 554 - switch ($this->getNewValue()) { 555 - case ArcanistDifferentialRevisionStatus::ACCEPTED: 556 - return PhabricatorTransactions::COLOR_GREEN; 557 - case ArcanistDifferentialRevisionStatus::NEEDS_REVISION: 558 - return PhabricatorTransactions::COLOR_RED; 559 - case ArcanistDifferentialRevisionStatus::NEEDS_REVIEW: 560 - return PhabricatorTransactions::COLOR_ORANGE; 561 - } 562 - break; 563 534 case self::TYPE_ACTION: 564 535 switch ($this->getNewValue()) { 565 536 case DifferentialAction::ACTION_CLOSE:
+74
src/applications/differential/xaction/DifferentialRevisionStatusTransaction.php
··· 1 + <?php 2 + 3 + final class DifferentialRevisionStatusTransaction 4 + extends DifferentialRevisionTransactionType { 5 + 6 + const TRANSACTIONTYPE = 'differential.revision.status'; 7 + 8 + public function generateOldValue($object) { 9 + return $object->getStatus(); 10 + } 11 + 12 + public function applyInternalEffects($object, $value) { 13 + $object->setStatus($value); 14 + } 15 + 16 + public function getTitle() { 17 + $new = $this->getNewValue(); 18 + $status = DifferentialRevisionStatus::newForLegacyStatus($new); 19 + 20 + if ($status->isAccepted()) { 21 + return pht('This revision is now accepted and ready to land.'); 22 + } 23 + 24 + if ($status->isNeedsRevision()) { 25 + return pht('This revision now requires changes to proceed.'); 26 + } 27 + 28 + if ($status->isNeedsReview()) { 29 + return pht('This revision now requires review to proceed.'); 30 + } 31 + 32 + return null; 33 + } 34 + 35 + public function getTitleForFeed() { 36 + $status = $this->newStatusObject(); 37 + 38 + if ($status->isAccepted()) { 39 + return pht( 40 + '%s is now accepted and ready to land.', 41 + $this->renderObject()); 42 + } 43 + 44 + if ($status->isNeedsRevision()) { 45 + return pht( 46 + '%s now requires changes to proceed.', 47 + $this->renderObject()); 48 + } 49 + 50 + if ($status->isNeedsReview()) { 51 + return pht( 52 + '%s now requires review to proceed.', 53 + $this->renderObject()); 54 + } 55 + 56 + return null; 57 + } 58 + 59 + public function getIcon() { 60 + $status = $this->newStatusObject(); 61 + return $status->getTimelineIcon(); 62 + } 63 + 64 + public function getColor() { 65 + $status = $this->newStatusObject(); 66 + return $status->getTimelineColor(); 67 + } 68 + 69 + private function newStatusObject() { 70 + $new = $this->getNewValue(); 71 + return DifferentialRevisionStatus::newForLegacyStatus($new); 72 + } 73 + 74 + }