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

Restore "Close" and "Reopen" actions to Differential on EditEngine

Summary:
Ref T11114. This restores these actions as selectable in the comment area.

This does not implement one special rule ("Closing a revision in response to a commit is OK from any status.") but I have a note about that separately.

Test Plan: Closed and reopened revisions.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11114

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

+151 -1
+4
src/__phutil_library_map__.php
··· 511 511 'DifferentialRevisionAuthorHeraldField' => 'applications/differential/herald/DifferentialRevisionAuthorHeraldField.php', 512 512 'DifferentialRevisionAuthorProjectsHeraldField' => 'applications/differential/herald/DifferentialRevisionAuthorProjectsHeraldField.php', 513 513 'DifferentialRevisionCloseDetailsController' => 'applications/differential/controller/DifferentialRevisionCloseDetailsController.php', 514 + 'DifferentialRevisionCloseTransaction' => 'applications/differential/xaction/DifferentialRevisionCloseTransaction.php', 514 515 'DifferentialRevisionContentAddedHeraldField' => 'applications/differential/herald/DifferentialRevisionContentAddedHeraldField.php', 515 516 'DifferentialRevisionContentHeraldField' => 'applications/differential/herald/DifferentialRevisionContentHeraldField.php', 516 517 'DifferentialRevisionContentRemovedHeraldField' => 'applications/differential/herald/DifferentialRevisionContentRemovedHeraldField.php', ··· 544 545 'DifferentialRevisionReclaimTransaction' => 'applications/differential/xaction/DifferentialRevisionReclaimTransaction.php', 545 546 'DifferentialRevisionRelationship' => 'applications/differential/relationships/DifferentialRevisionRelationship.php', 546 547 'DifferentialRevisionRelationshipSource' => 'applications/search/relationship/DifferentialRevisionRelationshipSource.php', 548 + 'DifferentialRevisionReopenTransaction' => 'applications/differential/xaction/DifferentialRevisionReopenTransaction.php', 547 549 'DifferentialRevisionRepositoryHeraldField' => 'applications/differential/herald/DifferentialRevisionRepositoryHeraldField.php', 548 550 'DifferentialRevisionRepositoryProjectsHeraldField' => 'applications/differential/herald/DifferentialRevisionRepositoryProjectsHeraldField.php', 549 551 'DifferentialRevisionRepositoryTransaction' => 'applications/differential/xaction/DifferentialRevisionRepositoryTransaction.php', ··· 5180 5182 'DifferentialRevisionAuthorHeraldField' => 'DifferentialRevisionHeraldField', 5181 5183 'DifferentialRevisionAuthorProjectsHeraldField' => 'DifferentialRevisionHeraldField', 5182 5184 'DifferentialRevisionCloseDetailsController' => 'DifferentialController', 5185 + 'DifferentialRevisionCloseTransaction' => 'DifferentialRevisionActionTransaction', 5183 5186 'DifferentialRevisionContentAddedHeraldField' => 'DifferentialRevisionHeraldField', 5184 5187 'DifferentialRevisionContentHeraldField' => 'DifferentialRevisionHeraldField', 5185 5188 'DifferentialRevisionContentRemovedHeraldField' => 'DifferentialRevisionHeraldField', ··· 5213 5216 'DifferentialRevisionReclaimTransaction' => 'DifferentialRevisionActionTransaction', 5214 5217 'DifferentialRevisionRelationship' => 'PhabricatorObjectRelationship', 5215 5218 'DifferentialRevisionRelationshipSource' => 'PhabricatorObjectRelationshipSource', 5219 + 'DifferentialRevisionReopenTransaction' => 'DifferentialRevisionActionTransaction', 5216 5220 'DifferentialRevisionRepositoryHeraldField' => 'DifferentialRevisionHeraldField', 5217 5221 'DifferentialRevisionRepositoryProjectsHeraldField' => 'DifferentialRevisionHeraldField', 5218 5222 'DifferentialRevisionRepositoryTransaction' => 'DifferentialRevisionTransactionType',
+1 -1
src/applications/differential/xaction/DifferentialRevisionAbandonTransaction.php
··· 45 45 pht( 46 46 'You can not abandon this revision because you are not the '. 47 47 'author. You can only abandon revisions you own. You can change '. 48 - 'this behavior by adjusting the "%s" setting in Config', 48 + 'this behavior by adjusting the "%s" setting in Config.', 49 49 $config_key)); 50 50 } 51 51 }
+78
src/applications/differential/xaction/DifferentialRevisionCloseTransaction.php
··· 1 + <?php 2 + 3 + final class DifferentialRevisionCloseTransaction 4 + extends DifferentialRevisionActionTransaction { 5 + 6 + const TRANSACTIONTYPE = 'differential.revision.close'; 7 + const ACTIONKEY = 'close'; 8 + 9 + protected function getRevisionActionLabel() { 10 + return pht('Close Revision'); 11 + } 12 + 13 + protected function getRevisionActionDescription() { 14 + return pht('This revision will be closed.'); 15 + } 16 + 17 + public function getIcon() { 18 + return 'fa-check'; 19 + } 20 + 21 + public function getColor() { 22 + return 'indigo'; 23 + } 24 + 25 + public function generateOldValue($object) { 26 + return $object->isClosed(); 27 + } 28 + 29 + public function applyInternalEffects($object, $value) { 30 + $status_closed = ArcanistDifferentialRevisionStatus::CLOSED; 31 + $status_accepted = ArcanistDifferentialRevisionStatus::ACCEPTED; 32 + 33 + $old_status = $object->getStatus(); 34 + 35 + $object->setStatus($status_closed); 36 + 37 + $was_accepted = ($old_status == $status_accepted); 38 + 39 + $object->setProperty( 40 + DifferentialRevision::PROPERTY_CLOSED_FROM_ACCEPTED, 41 + $was_accepted); 42 + } 43 + 44 + protected function validateAction($object, PhabricatorUser $viewer) { 45 + if ($object->isClosed()) { 46 + throw new Exception( 47 + pht( 48 + 'You can not close this revision because it has already been '. 49 + 'closed. Only open revisions can be closed.')); 50 + } 51 + 52 + $config_key = 'differential.always-allow-close'; 53 + if (!PhabricatorEnv::getEnvConfig($config_key)) { 54 + if (!$this->isViewerRevisionAuthor($object, $viewer)) { 55 + throw new Exception( 56 + pht( 57 + 'You can not close this revision because you are not the '. 58 + 'author. You can only close revisions you own. You can change '. 59 + 'this behavior by adjusting the "%s" setting in Config.', 60 + $config_key)); 61 + } 62 + } 63 + } 64 + 65 + public function getTitle() { 66 + return pht( 67 + '%s closed this revision.', 68 + $this->renderAuthor()); 69 + } 70 + 71 + public function getTitleForFeed() { 72 + return pht( 73 + '%s closed %s.', 74 + $this->renderAuthor(), 75 + $this->renderObject()); 76 + } 77 + 78 + }
+68
src/applications/differential/xaction/DifferentialRevisionReopenTransaction.php
··· 1 + <?php 2 + 3 + final class DifferentialRevisionReopenTransaction 4 + extends DifferentialRevisionActionTransaction { 5 + 6 + const TRANSACTIONTYPE = 'differential.revision.reopen'; 7 + const ACTIONKEY = 'reopen'; 8 + 9 + protected function getRevisionActionLabel() { 10 + return pht('Reopen Revision'); 11 + } 12 + 13 + protected function getRevisionActionDescription() { 14 + return pht('This revision will be reopened for review.'); 15 + } 16 + 17 + public function getIcon() { 18 + return 'fa-bullhorn'; 19 + } 20 + 21 + public function getColor() { 22 + return 'sky'; 23 + } 24 + 25 + public function generateOldValue($object) { 26 + return !$object->isClosed(); 27 + } 28 + 29 + public function applyInternalEffects($object, $value) { 30 + $object->setStatus(ArcanistDifferentialRevisionStatus::NEEDS_REVIEW); 31 + } 32 + 33 + protected function validateAction($object, PhabricatorUser $viewer) { 34 + // Note that we're testing for "Closed", exactly, not just any closed 35 + // status. 36 + $status_closed = ArcanistDifferentialRevisionStatus::CLOSED; 37 + if ($object->getStatus() != $status_closed) { 38 + throw new Exception( 39 + pht( 40 + 'You can not reopen this revision because it is not closed. '. 41 + 'Only closed revisions can be reopened.')); 42 + } 43 + 44 + $config_key = 'differential.allow-reopen'; 45 + if (!PhabricatorEnv::getEnvConfig($config_key)) { 46 + throw new Exception( 47 + pht( 48 + 'You can not reopen this revision because configuration prevents '. 49 + 'any revision from being reopened. You can change this behavior '. 50 + 'by adjusting the "%s" setting in Config.', 51 + $config_key)); 52 + } 53 + } 54 + 55 + public function getTitle() { 56 + return pht( 57 + '%s reopened this revision.', 58 + $this->renderAuthor()); 59 + } 60 + 61 + public function getTitleForFeed() { 62 + return pht( 63 + '%s reopened %s.', 64 + $this->renderAuthor(), 65 + $this->renderObject()); 66 + } 67 + 68 + }