2016-12-28 22:32:59 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DifferentialRevisionRequestReviewTransaction
|
|
|
|
extends DifferentialRevisionActionTransaction {
|
|
|
|
|
|
|
|
const TRANSACTIONTYPE = 'differential.revision.request';
|
|
|
|
const ACTIONKEY = 'request-review';
|
|
|
|
|
|
|
|
protected function getRevisionActionLabel() {
|
|
|
|
return pht('Request Review');
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getRevisionActionDescription() {
|
|
|
|
return pht('This revision will be returned to reviewers for feedback.');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getColor() {
|
|
|
|
return 'sky';
|
|
|
|
}
|
|
|
|
|
Order actions sensibly within Differential revision comment action groups
Summary:
Ref T11114. See D17114 for some discussion.
For review actions: accept, reject, resign.
For revision actions, order is basically least-severe to most-severe action pairs: plan changes, request review, close, reopen, abandon, reclaim, commandeer.
Test Plan: Viewed revisions as an author and a reviewer, saw sensible action order within action groups.
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T11114
Differential Revision: https://secure.phabricator.com/D17115
2016-12-29 22:36:36 +01:00
|
|
|
protected function getRevisionActionOrder() {
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
2017-01-12 16:40:48 +01:00
|
|
|
public function getActionName() {
|
|
|
|
return pht('Requested Review');
|
|
|
|
}
|
|
|
|
|
2016-12-28 22:32:59 +01:00
|
|
|
public function generateOldValue($object) {
|
2017-08-11 22:23:41 +02:00
|
|
|
return $object->isNeedsReview();
|
2016-12-28 22:32:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function applyInternalEffects($object, $value) {
|
|
|
|
$status_review = ArcanistDifferentialRevisionStatus::NEEDS_REVIEW;
|
|
|
|
$object->setStatus($status_review);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function validateAction($object, PhabricatorUser $viewer) {
|
2017-08-04 17:20:20 +02:00
|
|
|
if ($object->isNeedsReview()) {
|
2016-12-28 22:32:59 +01:00
|
|
|
throw new Exception(
|
|
|
|
pht(
|
|
|
|
'You can not request review of this revision because this '.
|
|
|
|
'revision is already under review and the action would have '.
|
|
|
|
'no effect.'));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($object->isClosed()) {
|
|
|
|
throw new Exception(
|
|
|
|
pht(
|
|
|
|
'You can not request review of this revision because it has '.
|
|
|
|
'already been closed. You can only request review of open '.
|
|
|
|
'revisions.'));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$this->isViewerRevisionAuthor($object, $viewer)) {
|
|
|
|
throw new Exception(
|
|
|
|
pht(
|
|
|
|
'You can not request review of this revision because you are not '.
|
|
|
|
'the author of the revision.'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTitle() {
|
|
|
|
return pht(
|
|
|
|
'%s requested review of this revision.',
|
|
|
|
$this->renderAuthor());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTitleForFeed() {
|
|
|
|
return pht(
|
|
|
|
'%s requested review of %s.',
|
|
|
|
$this->renderAuthor(),
|
|
|
|
$this->renderObject());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|