2016-12-29 10:35:47 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DifferentialRevisionAcceptTransaction
|
2016-12-29 13:14:09 -08:00
|
|
|
extends DifferentialRevisionReviewTransaction {
|
2016-12-29 10:35:47 -08:00
|
|
|
|
|
|
|
const TRANSACTIONTYPE = 'differential.revision.accept';
|
|
|
|
const ACTIONKEY = 'accept';
|
|
|
|
|
|
|
|
protected function getRevisionActionLabel() {
|
|
|
|
return pht("Accept Revision \xE2\x9C\x94");
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getRevisionActionDescription() {
|
|
|
|
return pht('These changes will be approved.');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getIcon() {
|
|
|
|
return 'fa-check-circle-o';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getColor() {
|
|
|
|
return 'green';
|
|
|
|
}
|
|
|
|
|
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 13:36:36 -08:00
|
|
|
protected function getRevisionActionOrder() {
|
|
|
|
return 500;
|
|
|
|
}
|
|
|
|
|
2017-01-02 11:36:02 -08:00
|
|
|
public function getCommandKeyword() {
|
|
|
|
$accept_key = 'differential.enable-email-accept';
|
|
|
|
$allow_email_accept = PhabricatorEnv::getEnvConfig($accept_key);
|
|
|
|
if (!$allow_email_accept) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 'accept';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCommandAliases() {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCommandSummary() {
|
|
|
|
return pht('Accept a revision.');
|
|
|
|
}
|
|
|
|
|
2016-12-29 10:35:47 -08:00
|
|
|
public function generateOldValue($object) {
|
|
|
|
$actor = $this->getActor();
|
|
|
|
return $this->isViewerAcceptingReviewer($object, $actor);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function applyExternalEffects($object, $value) {
|
|
|
|
$status = DifferentialReviewerStatus::STATUS_ACCEPTED;
|
|
|
|
$actor = $this->getActor();
|
|
|
|
$this->applyReviewerEffect($object, $actor, $value, $status);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function validateAction($object, PhabricatorUser $viewer) {
|
|
|
|
if ($object->isClosed()) {
|
|
|
|
throw new Exception(
|
|
|
|
pht(
|
|
|
|
'You can not accept this revision because it has already been '.
|
|
|
|
'closed. Only open revisions can be accepted.'));
|
|
|
|
}
|
|
|
|
|
|
|
|
$config_key = 'differential.allow-self-accept';
|
|
|
|
if (!PhabricatorEnv::getEnvConfig($config_key)) {
|
|
|
|
if ($this->isViewerRevisionAuthor($object, $viewer)) {
|
|
|
|
throw new Exception(
|
|
|
|
pht(
|
|
|
|
'You can not accept this revision because you are the revision '.
|
|
|
|
'author. You can only accept revisions you do not own. You can '.
|
|
|
|
'change this behavior by adjusting the "%s" setting in Config.',
|
|
|
|
$config_key));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->isViewerAcceptingReviewer($object, $viewer)) {
|
|
|
|
throw new Exception(
|
|
|
|
pht(
|
|
|
|
'You can not accept this revision because you have already '.
|
|
|
|
'accepted it.'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTitle() {
|
|
|
|
return pht(
|
|
|
|
'%s accepted this revision.',
|
|
|
|
$this->renderAuthor());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTitleForFeed() {
|
|
|
|
return pht(
|
|
|
|
'%s accepted %s.',
|
|
|
|
$this->renderAuthor(),
|
|
|
|
$this->renderObject());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|