1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 06:42:42 +01:00

Align most revision actions to the new "Draft" state

Summary:
Ref T2543. Most actions are not available for drafts.

Authors can "Request Review" (move out of draft to become a normal revision) or "Abandon".

Non-authors can't do anything (maybe we'll let them do something later -- like "Commandeer"? -- if there's a good reason).

Test Plan: Viewed a draft revision as an author and non-author, saw fewer actions available.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T2543

Differential Revision: https://secure.phabricator.com/D18626
This commit is contained in:
epriestley 2017-09-18 14:14:52 -07:00
parent 5112dac491
commit c7af663523
11 changed files with 48 additions and 13 deletions

View file

@ -10,7 +10,8 @@ final class DifferentialRevisionAbandonTransaction
return pht('Abandon Revision');
}
protected function getRevisionActionDescription() {
protected function getRevisionActionDescription(
DifferentialRevision $revision) {
return pht('This revision will be abandoned and closed.');
}

View file

@ -10,7 +10,8 @@ final class DifferentialRevisionAcceptTransaction
return pht("Accept Revision \xE2\x9C\x94");
}
protected function getRevisionActionDescription() {
protected function getRevisionActionDescription(
DifferentialRevision $revision) {
return pht('These changes will be approved.');
}

View file

@ -52,7 +52,8 @@ abstract class DifferentialRevisionActionTransaction
return DifferentialRevisionEditEngine::ACTIONGROUP_REVISION;
}
protected function getRevisionActionDescription() {
protected function getRevisionActionDescription(
DifferentialRevision $revision) {
return null;
}
@ -103,7 +104,7 @@ abstract class DifferentialRevisionActionTransaction
if ($label !== null) {
$field->setCommentActionLabel($label);
$description = $this->getRevisionActionDescription();
$description = $this->getRevisionActionDescription($revision);
$field->setActionDescription($description);
$group_key = $this->getRevisionActionGroupKey();

View file

@ -10,7 +10,8 @@ final class DifferentialRevisionCloseTransaction
return pht('Close Revision');
}
protected function getRevisionActionDescription() {
protected function getRevisionActionDescription(
DifferentialRevision $revision) {
return pht('This revision will be closed.');
}

View file

@ -10,7 +10,8 @@ final class DifferentialRevisionCommandeerTransaction
return pht('Commandeer Revision');
}
protected function getRevisionActionDescription() {
protected function getRevisionActionDescription(
DifferentialRevision $revision) {
return pht('You will take control of this revision and become its author.');
}
@ -65,6 +66,11 @@ final class DifferentialRevisionCommandeerTransaction
'been closed. You can only commandeer open revisions.'));
}
if ($object->isDraft()) {
throw new Exception(
pht('You can not commandeer a draft revision.'));
}
if ($this->isViewerRevisionAuthor($object, $viewer)) {
throw new Exception(
pht(

View file

@ -10,7 +10,8 @@ final class DifferentialRevisionPlanChangesTransaction
return pht('Plan Changes');
}
protected function getRevisionActionDescription() {
protected function getRevisionActionDescription(
DifferentialRevision $revision) {
return pht(
'This revision will be removed from review queues until it is revised.');
}
@ -55,6 +56,11 @@ final class DifferentialRevisionPlanChangesTransaction
}
protected function validateAction($object, PhabricatorUser $viewer) {
if ($object->isDraft()) {
throw new Exception(
pht('You can not plan changes to a draft revision.'));
}
if ($object->isChangePlanned()) {
throw new Exception(
pht(

View file

@ -10,7 +10,8 @@ final class DifferentialRevisionReclaimTransaction
return pht('Reclaim Revision');
}
protected function getRevisionActionDescription() {
protected function getRevisionActionDescription(
DifferentialRevision $revision) {
return pht('This revision will be reclaimed and reopened.');
}

View file

@ -10,7 +10,8 @@ final class DifferentialRevisionRejectTransaction
return pht("Request Changes \xE2\x9C\x98");
}
protected function getRevisionActionDescription() {
protected function getRevisionActionDescription(
DifferentialRevision $revision) {
return pht('This revision will be returned to the author for updates.');
}
@ -72,6 +73,11 @@ final class DifferentialRevisionRejectTransaction
'not own.'));
}
if ($object->isDraft()) {
throw new Exception(
pht('You can not request changes to a draft revision.'));
}
if ($this->isViewerFullyRejected($object, $viewer)) {
throw new Exception(
pht(

View file

@ -10,7 +10,8 @@ final class DifferentialRevisionReopenTransaction
return pht('Reopen Revision');
}
protected function getRevisionActionDescription() {
protected function getRevisionActionDescription(
DifferentialRevision $revision) {
return pht('This revision will be reopened for review.');
}

View file

@ -10,8 +10,13 @@ final class DifferentialRevisionRequestReviewTransaction
return pht('Request Review');
}
protected function getRevisionActionDescription() {
return pht('This revision will be returned to reviewers for feedback.');
protected function getRevisionActionDescription(
DifferentialRevision $revision) {
if ($revision->isDraft()) {
return pht('This revision will be submitted to reviewers for feedback.');
} else {
return pht('This revision will be returned to reviewers for feedback.');
}
}
public function getColor() {

View file

@ -10,7 +10,8 @@ final class DifferentialRevisionResignTransaction
return pht('Resign as Reviewer');
}
protected function getRevisionActionDescription() {
protected function getRevisionActionDescription(
DifferentialRevision $revision) {
return pht('You will resign as a reviewer for this change.');
}
@ -63,6 +64,11 @@ final class DifferentialRevisionResignTransaction
'been closed. You can only resign from open revisions.'));
}
if ($object->isDraft()) {
throw new Exception(
pht('You can not resign from a draft revision.'));
}
$resigned = DifferentialReviewerStatus::STATUS_RESIGNED;
if ($this->getViewerReviewerStatus($object, $viewer) == $resigned) {
throw new Exception(