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

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
This commit is contained in:
epriestley 2020-07-09 12:23:31 -07:00
parent 73c4240415
commit b21b73b8dd
11 changed files with 64 additions and 27 deletions

View file

@ -6,12 +6,15 @@ final class DifferentialRevisionAbandonTransaction
const TRANSACTIONTYPE = 'differential.revision.abandon';
const ACTIONKEY = 'abandon';
protected function getRevisionActionLabel() {
protected function getRevisionActionLabel(
DifferentialRevision $revision,
PhabricatorUser $viewer) {
return pht('Abandon Revision');
}
protected function getRevisionActionDescription(
DifferentialRevision $revision) {
DifferentialRevision $revision,
PhabricatorUser $viewer) {
return pht('This revision will be abandoned and closed.');
}

View file

@ -6,12 +6,15 @@ final class DifferentialRevisionAcceptTransaction
const TRANSACTIONTYPE = 'differential.revision.accept';
const ACTIONKEY = 'accept';
protected function getRevisionActionLabel() {
protected function getRevisionActionLabel(
DifferentialRevision $revision,
PhabricatorUser $viewer) {
return pht('Accept Revision');
}
protected function getRevisionActionDescription(
DifferentialRevision $revision) {
DifferentialRevision $revision,
PhabricatorUser $viewer) {
return pht('These changes will be approved.');
}

View file

@ -17,7 +17,9 @@ abstract class DifferentialRevisionActionTransaction
}
abstract protected function validateAction($object, PhabricatorUser $viewer);
abstract protected function getRevisionActionLabel();
abstract protected function getRevisionActionLabel(
DifferentialRevision $revision,
PhabricatorUser $viewer);
protected function validateOptionValue($object, $actor, array $value) {
return null;
@ -53,12 +55,14 @@ abstract class DifferentialRevisionActionTransaction
}
protected function getRevisionActionDescription(
DifferentialRevision $revision) {
DifferentialRevision $revision,
PhabricatorUser $viewer) {
return null;
}
protected function getRevisionActionSubmitButtonText(
DifferentialRevision $revision) {
DifferentialRevision $revision,
PhabricatorUser $viewer) {
return null;
}
@ -105,17 +109,19 @@ abstract class DifferentialRevisionActionTransaction
->setValue(true);
if ($this->isActionAvailable($revision, $viewer)) {
$label = $this->getRevisionActionLabel();
$label = $this->getRevisionActionLabel($revision, $viewer);
if ($label !== null) {
$field->setCommentActionLabel($label);
$description = $this->getRevisionActionDescription($revision);
$description = $this->getRevisionActionDescription($revision, $viewer);
$field->setActionDescription($description);
$group_key = $this->getRevisionActionGroupKey();
$field->setCommentActionGroupKey($group_key);
$button_text = $this->getRevisionActionSubmitButtonText($revision);
$button_text = $this->getRevisionActionSubmitButtonText(
$revision,
$viewer);
$field->setActionSubmitButtonText($button_text);
// Currently, every revision action conflicts with every other

View file

@ -6,12 +6,15 @@ final class DifferentialRevisionCloseTransaction
const TRANSACTIONTYPE = 'differential.revision.close';
const ACTIONKEY = 'close';
protected function getRevisionActionLabel() {
protected function getRevisionActionLabel(
DifferentialRevision $revision,
PhabricatorUser $viewer) {
return pht('Close Revision');
}
protected function getRevisionActionDescription(
DifferentialRevision $revision) {
DifferentialRevision $revision,
PhabricatorUser $viewer) {
return pht('This revision will be closed.');
}

View file

@ -6,12 +6,15 @@ final class DifferentialRevisionCommandeerTransaction
const TRANSACTIONTYPE = 'differential.revision.commandeer';
const ACTIONKEY = 'commandeer';
protected function getRevisionActionLabel() {
protected function getRevisionActionLabel(
DifferentialRevision $revision,
PhabricatorUser $viewer) {
return pht('Commandeer Revision');
}
protected function getRevisionActionDescription(
DifferentialRevision $revision) {
DifferentialRevision $revision,
PhabricatorUser $viewer) {
return pht('You will take control of this revision and become its author.');
}

View file

@ -6,12 +6,15 @@ final class DifferentialRevisionPlanChangesTransaction
const TRANSACTIONTYPE = 'differential.revision.plan';
const ACTIONKEY = 'plan-changes';
protected function getRevisionActionLabel() {
protected function getRevisionActionLabel(
DifferentialRevision $revision,
PhabricatorUser $viewer) {
return pht('Plan Changes');
}
protected function getRevisionActionDescription(
DifferentialRevision $revision) {
DifferentialRevision $revision,
PhabricatorUser $viewer) {
return pht(
'This revision will be removed from review queues until it is revised.');
}

View file

@ -6,12 +6,15 @@ final class DifferentialRevisionReclaimTransaction
const TRANSACTIONTYPE = 'differential.revision.reclaim';
const ACTIONKEY = 'reclaim';
protected function getRevisionActionLabel() {
protected function getRevisionActionLabel(
DifferentialRevision $revision,
PhabricatorUser $viewer) {
return pht('Reclaim Revision');
}
protected function getRevisionActionDescription(
DifferentialRevision $revision) {
DifferentialRevision $revision,
PhabricatorUser $viewer) {
return pht('This revision will be reclaimed and reopened.');
}

View file

@ -6,12 +6,15 @@ final class DifferentialRevisionRejectTransaction
const TRANSACTIONTYPE = 'differential.revision.reject';
const ACTIONKEY = 'reject';
protected function getRevisionActionLabel() {
protected function getRevisionActionLabel(
DifferentialRevision $revision,
PhabricatorUser $viewer) {
return pht('Request Changes');
}
protected function getRevisionActionDescription(
DifferentialRevision $revision) {
DifferentialRevision $revision,
PhabricatorUser $viewer) {
return pht('This revision will be returned to the author for updates.');
}

View file

@ -6,12 +6,15 @@ final class DifferentialRevisionReopenTransaction
const TRANSACTIONTYPE = 'differential.revision.reopen';
const ACTIONKEY = 'reopen';
protected function getRevisionActionLabel() {
protected function getRevisionActionLabel(
DifferentialRevision $revision,
PhabricatorUser $viewer) {
return pht('Reopen Revision');
}
protected function getRevisionActionDescription(
DifferentialRevision $revision) {
DifferentialRevision $revision,
PhabricatorUser $viewer) {
return pht('This revision will be reopened for review.');
}

View file

@ -6,12 +6,15 @@ final class DifferentialRevisionRequestReviewTransaction
const TRANSACTIONTYPE = 'differential.revision.request';
const ACTIONKEY = 'request-review';
protected function getRevisionActionLabel() {
protected function getRevisionActionLabel(
DifferentialRevision $revision,
PhabricatorUser $viewer) {
return pht('Request Review');
}
protected function getRevisionActionDescription(
DifferentialRevision $revision) {
DifferentialRevision $revision,
PhabricatorUser $viewer) {
if ($revision->isDraft()) {
return pht('This revision will be submitted to reviewers for feedback.');
} else {
@ -20,7 +23,8 @@ final class DifferentialRevisionRequestReviewTransaction
}
protected function getRevisionActionSubmitButtonText(
DifferentialRevision $revision) {
DifferentialRevision $revision,
PhabricatorUser $viewer) {
// See PHI975. When the action stack will promote the revision out of
// draft, change the button text from "Submit Quietly".

View file

@ -6,12 +6,15 @@ final class DifferentialRevisionResignTransaction
const TRANSACTIONTYPE = 'differential.revision.resign';
const ACTIONKEY = 'resign';
protected function getRevisionActionLabel() {
protected function getRevisionActionLabel(
DifferentialRevision $revision,
PhabricatorUser $viewer) {
return pht('Resign as Reviewer');
}
protected function getRevisionActionDescription(
DifferentialRevision $revision) {
DifferentialRevision $revision,
PhabricatorUser $viewer) {
return pht('You will resign as a reviewer for this change.');
}