2016-12-28 22:32:59 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DifferentialRevisionPlanChangesTransaction
|
|
|
|
extends DifferentialRevisionActionTransaction {
|
|
|
|
|
|
|
|
const TRANSACTIONTYPE = 'differential.revision.plan';
|
|
|
|
const ACTIONKEY = 'plan-changes';
|
|
|
|
|
|
|
|
protected function getRevisionActionLabel() {
|
|
|
|
return pht('Plan Changes');
|
|
|
|
}
|
|
|
|
|
2017-09-18 23:14:52 +02:00
|
|
|
protected function getRevisionActionDescription(
|
|
|
|
DifferentialRevision $revision) {
|
2016-12-28 22:32:59 +01:00
|
|
|
return pht(
|
|
|
|
'This revision will be removed from review queues until it is revised.');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getIcon() {
|
|
|
|
return 'fa-headphones';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getColor() {
|
|
|
|
return 'red';
|
|
|
|
}
|
|
|
|
|
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('Planned Changes');
|
|
|
|
}
|
|
|
|
|
2017-01-02 20:36:02 +01:00
|
|
|
public function getCommandKeyword() {
|
|
|
|
return 'planchanges';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCommandAliases() {
|
|
|
|
return array(
|
|
|
|
'rethink',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCommandSummary() {
|
|
|
|
return pht('Plan changes to a revision.');
|
|
|
|
}
|
|
|
|
|
2016-12-28 22:32:59 +01:00
|
|
|
public function generateOldValue($object) {
|
2017-08-11 22:23:41 +02:00
|
|
|
return $object->isChangePlanned();
|
2016-12-28 22:32:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function applyInternalEffects($object, $value) {
|
2017-08-12 00:49:05 +02:00
|
|
|
$status_planned = DifferentialRevisionStatus::CHANGES_PLANNED;
|
|
|
|
$object->setModernRevisionStatus($status_planned);
|
2016-12-28 22:32:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function validateAction($object, PhabricatorUser $viewer) {
|
2017-09-18 23:14:52 +02:00
|
|
|
if ($object->isDraft()) {
|
2018-02-12 22:01:02 +01:00
|
|
|
|
|
|
|
// See PHI346. Until the "Draft" state fully unprototypes, allow drafts
|
|
|
|
// to be moved to "changes planned" via the API. This preserves the
|
|
|
|
// behavior of "arc diff --plan-changes". We still prevent this
|
|
|
|
// transition from the web UI.
|
|
|
|
// TODO: Remove this once drafts leave prototype.
|
|
|
|
|
|
|
|
$editor = $this->getEditor();
|
|
|
|
$type_web = PhabricatorWebContentSource::SOURCECONST;
|
|
|
|
if ($editor->getContentSource()->getSource() == $type_web) {
|
|
|
|
throw new Exception(
|
|
|
|
pht('You can not plan changes to a draft revision.'));
|
|
|
|
}
|
2017-09-18 23:14:52 +02:00
|
|
|
}
|
|
|
|
|
2017-08-04 17:20:20 +02:00
|
|
|
if ($object->isChangePlanned()) {
|
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 plan changes to this this revision because it has '.
|
|
|
|
'already been closed.'));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$this->isViewerRevisionAuthor($object, $viewer)) {
|
|
|
|
throw new Exception(
|
|
|
|
pht(
|
|
|
|
'You can not plan changes to this revision because you do not '.
|
|
|
|
'own it. Only the author of a revision can plan changes to it.'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTitle() {
|
2018-04-03 18:12:08 +02:00
|
|
|
if ($this->isDraftDemotion()) {
|
|
|
|
return pht(
|
|
|
|
'%s returned this revision to the author for changes because remote '.
|
|
|
|
'builds failed.',
|
|
|
|
$this->renderAuthor());
|
|
|
|
} else {
|
|
|
|
return pht(
|
|
|
|
'%s planned changes to this revision.',
|
|
|
|
$this->renderAuthor());
|
|
|
|
}
|
2016-12-28 22:32:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getTitleForFeed() {
|
|
|
|
return pht(
|
|
|
|
'%s planned changes to %s.',
|
|
|
|
$this->renderAuthor(),
|
|
|
|
$this->renderObject());
|
|
|
|
}
|
|
|
|
|
2018-04-03 18:12:08 +02:00
|
|
|
private function isDraftDemotion() {
|
|
|
|
return (bool)$this->getMetadataValue('draft.demote');
|
|
|
|
}
|
|
|
|
|
2018-06-27 18:48:18 +02:00
|
|
|
public function getTransactionTypeForConduit($xaction) {
|
|
|
|
return 'plan-changes';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getFieldValuesForConduit($object, $data) {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
2016-12-28 22:32:59 +01:00
|
|
|
}
|