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

Expand Revision transaction API to allow actions to vary more broadly based on the viewer and revision state

Summary:
See PHI1810. Build toward support for "Request Review" by non-authors on drafts, to forcefully pull a revision out of draft.

Currently, some action strings can't vary based on revision state or the current viewer, so this "pull out of draft" action would have to either: say "Request Review"; or be a totally separate action.

Neither seem great, so allow the labels and messages to vary based on the viewer and revision state.

Test Plan: Grepped for affected symbols, see followup changes.

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

+64 -27
+5 -2
src/applications/differential/xaction/DifferentialRevisionAbandonTransaction.php
··· 6 6 const TRANSACTIONTYPE = 'differential.revision.abandon'; 7 7 const ACTIONKEY = 'abandon'; 8 8 9 - protected function getRevisionActionLabel() { 9 + protected function getRevisionActionLabel( 10 + DifferentialRevision $revision, 11 + PhabricatorUser $viewer) { 10 12 return pht('Abandon Revision'); 11 13 } 12 14 13 15 protected function getRevisionActionDescription( 14 - DifferentialRevision $revision) { 16 + DifferentialRevision $revision, 17 + PhabricatorUser $viewer) { 15 18 return pht('This revision will be abandoned and closed.'); 16 19 } 17 20
+5 -2
src/applications/differential/xaction/DifferentialRevisionAcceptTransaction.php
··· 6 6 const TRANSACTIONTYPE = 'differential.revision.accept'; 7 7 const ACTIONKEY = 'accept'; 8 8 9 - protected function getRevisionActionLabel() { 9 + protected function getRevisionActionLabel( 10 + DifferentialRevision $revision, 11 + PhabricatorUser $viewer) { 10 12 return pht('Accept Revision'); 11 13 } 12 14 13 15 protected function getRevisionActionDescription( 14 - DifferentialRevision $revision) { 16 + DifferentialRevision $revision, 17 + PhabricatorUser $viewer) { 15 18 return pht('These changes will be approved.'); 16 19 } 17 20
+12 -6
src/applications/differential/xaction/DifferentialRevisionActionTransaction.php
··· 17 17 } 18 18 19 19 abstract protected function validateAction($object, PhabricatorUser $viewer); 20 - abstract protected function getRevisionActionLabel(); 20 + abstract protected function getRevisionActionLabel( 21 + DifferentialRevision $revision, 22 + PhabricatorUser $viewer); 21 23 22 24 protected function validateOptionValue($object, $actor, array $value) { 23 25 return null; ··· 53 55 } 54 56 55 57 protected function getRevisionActionDescription( 56 - DifferentialRevision $revision) { 58 + DifferentialRevision $revision, 59 + PhabricatorUser $viewer) { 57 60 return null; 58 61 } 59 62 60 63 protected function getRevisionActionSubmitButtonText( 61 - DifferentialRevision $revision) { 64 + DifferentialRevision $revision, 65 + PhabricatorUser $viewer) { 62 66 return null; 63 67 } 64 68 ··· 105 109 ->setValue(true); 106 110 107 111 if ($this->isActionAvailable($revision, $viewer)) { 108 - $label = $this->getRevisionActionLabel(); 112 + $label = $this->getRevisionActionLabel($revision, $viewer); 109 113 if ($label !== null) { 110 114 $field->setCommentActionLabel($label); 111 115 112 - $description = $this->getRevisionActionDescription($revision); 116 + $description = $this->getRevisionActionDescription($revision, $viewer); 113 117 $field->setActionDescription($description); 114 118 115 119 $group_key = $this->getRevisionActionGroupKey(); 116 120 $field->setCommentActionGroupKey($group_key); 117 121 118 - $button_text = $this->getRevisionActionSubmitButtonText($revision); 122 + $button_text = $this->getRevisionActionSubmitButtonText( 123 + $revision, 124 + $viewer); 119 125 $field->setActionSubmitButtonText($button_text); 120 126 121 127 // Currently, every revision action conflicts with every other
+5 -2
src/applications/differential/xaction/DifferentialRevisionCloseTransaction.php
··· 6 6 const TRANSACTIONTYPE = 'differential.revision.close'; 7 7 const ACTIONKEY = 'close'; 8 8 9 - protected function getRevisionActionLabel() { 9 + protected function getRevisionActionLabel( 10 + DifferentialRevision $revision, 11 + PhabricatorUser $viewer) { 10 12 return pht('Close Revision'); 11 13 } 12 14 13 15 protected function getRevisionActionDescription( 14 - DifferentialRevision $revision) { 16 + DifferentialRevision $revision, 17 + PhabricatorUser $viewer) { 15 18 return pht('This revision will be closed.'); 16 19 } 17 20
+5 -2
src/applications/differential/xaction/DifferentialRevisionCommandeerTransaction.php
··· 6 6 const TRANSACTIONTYPE = 'differential.revision.commandeer'; 7 7 const ACTIONKEY = 'commandeer'; 8 8 9 - protected function getRevisionActionLabel() { 9 + protected function getRevisionActionLabel( 10 + DifferentialRevision $revision, 11 + PhabricatorUser $viewer) { 10 12 return pht('Commandeer Revision'); 11 13 } 12 14 13 15 protected function getRevisionActionDescription( 14 - DifferentialRevision $revision) { 16 + DifferentialRevision $revision, 17 + PhabricatorUser $viewer) { 15 18 return pht('You will take control of this revision and become its author.'); 16 19 } 17 20
+5 -2
src/applications/differential/xaction/DifferentialRevisionPlanChangesTransaction.php
··· 6 6 const TRANSACTIONTYPE = 'differential.revision.plan'; 7 7 const ACTIONKEY = 'plan-changes'; 8 8 9 - protected function getRevisionActionLabel() { 9 + protected function getRevisionActionLabel( 10 + DifferentialRevision $revision, 11 + PhabricatorUser $viewer) { 10 12 return pht('Plan Changes'); 11 13 } 12 14 13 15 protected function getRevisionActionDescription( 14 - DifferentialRevision $revision) { 16 + DifferentialRevision $revision, 17 + PhabricatorUser $viewer) { 15 18 return pht( 16 19 'This revision will be removed from review queues until it is revised.'); 17 20 }
+5 -2
src/applications/differential/xaction/DifferentialRevisionReclaimTransaction.php
··· 6 6 const TRANSACTIONTYPE = 'differential.revision.reclaim'; 7 7 const ACTIONKEY = 'reclaim'; 8 8 9 - protected function getRevisionActionLabel() { 9 + protected function getRevisionActionLabel( 10 + DifferentialRevision $revision, 11 + PhabricatorUser $viewer) { 10 12 return pht('Reclaim Revision'); 11 13 } 12 14 13 15 protected function getRevisionActionDescription( 14 - DifferentialRevision $revision) { 16 + DifferentialRevision $revision, 17 + PhabricatorUser $viewer) { 15 18 return pht('This revision will be reclaimed and reopened.'); 16 19 } 17 20
+5 -2
src/applications/differential/xaction/DifferentialRevisionRejectTransaction.php
··· 6 6 const TRANSACTIONTYPE = 'differential.revision.reject'; 7 7 const ACTIONKEY = 'reject'; 8 8 9 - protected function getRevisionActionLabel() { 9 + protected function getRevisionActionLabel( 10 + DifferentialRevision $revision, 11 + PhabricatorUser $viewer) { 10 12 return pht('Request Changes'); 11 13 } 12 14 13 15 protected function getRevisionActionDescription( 14 - DifferentialRevision $revision) { 16 + DifferentialRevision $revision, 17 + PhabricatorUser $viewer) { 15 18 return pht('This revision will be returned to the author for updates.'); 16 19 } 17 20
+5 -2
src/applications/differential/xaction/DifferentialRevisionReopenTransaction.php
··· 6 6 const TRANSACTIONTYPE = 'differential.revision.reopen'; 7 7 const ACTIONKEY = 'reopen'; 8 8 9 - protected function getRevisionActionLabel() { 9 + protected function getRevisionActionLabel( 10 + DifferentialRevision $revision, 11 + PhabricatorUser $viewer) { 10 12 return pht('Reopen Revision'); 11 13 } 12 14 13 15 protected function getRevisionActionDescription( 14 - DifferentialRevision $revision) { 16 + DifferentialRevision $revision, 17 + PhabricatorUser $viewer) { 15 18 return pht('This revision will be reopened for review.'); 16 19 } 17 20
+7 -3
src/applications/differential/xaction/DifferentialRevisionRequestReviewTransaction.php
··· 6 6 const TRANSACTIONTYPE = 'differential.revision.request'; 7 7 const ACTIONKEY = 'request-review'; 8 8 9 - protected function getRevisionActionLabel() { 9 + protected function getRevisionActionLabel( 10 + DifferentialRevision $revision, 11 + PhabricatorUser $viewer) { 10 12 return pht('Request Review'); 11 13 } 12 14 13 15 protected function getRevisionActionDescription( 14 - DifferentialRevision $revision) { 16 + DifferentialRevision $revision, 17 + PhabricatorUser $viewer) { 15 18 if ($revision->isDraft()) { 16 19 return pht('This revision will be submitted to reviewers for feedback.'); 17 20 } else { ··· 20 23 } 21 24 22 25 protected function getRevisionActionSubmitButtonText( 23 - DifferentialRevision $revision) { 26 + DifferentialRevision $revision, 27 + PhabricatorUser $viewer) { 24 28 25 29 // See PHI975. When the action stack will promote the revision out of 26 30 // draft, change the button text from "Submit Quietly".
+5 -2
src/applications/differential/xaction/DifferentialRevisionResignTransaction.php
··· 6 6 const TRANSACTIONTYPE = 'differential.revision.resign'; 7 7 const ACTIONKEY = 'resign'; 8 8 9 - protected function getRevisionActionLabel() { 9 + protected function getRevisionActionLabel( 10 + DifferentialRevision $revision, 11 + PhabricatorUser $viewer) { 10 12 return pht('Resign as Reviewer'); 11 13 } 12 14 13 15 protected function getRevisionActionDescription( 14 - DifferentialRevision $revision) { 16 + DifferentialRevision $revision, 17 + PhabricatorUser $viewer) { 15 18 return pht('You will resign as a reviewer for this change.'); 16 19 } 17 20