3 final class DifferentialRevisionPlanChangesTransaction
4 extends DifferentialRevisionActionTransaction
{
6 const TRANSACTIONTYPE
= 'differential.revision.plan';
7 const ACTIONKEY
= 'plan-changes';
9 protected function getRevisionActionLabel(
10 DifferentialRevision
$revision,
11 PhabricatorUser
$viewer) {
12 return pht('Plan Changes');
15 protected function getRevisionActionDescription(
16 DifferentialRevision
$revision,
17 PhabricatorUser
$viewer) {
19 'This revision will be removed from review queues until it is revised.');
22 public function getIcon() {
23 return 'fa-headphones';
26 public function getColor() {
30 protected function getRevisionActionOrder() {
34 public function getActionName() {
35 return pht('Planned Changes');
38 public function getCommandKeyword() {
42 public function getCommandAliases() {
48 public function getCommandSummary() {
49 return pht('Plan changes to a revision.');
52 public function generateOldValue($object) {
53 return $object->isChangePlanned();
56 public function applyInternalEffects($object, $value) {
57 $status_planned = DifferentialRevisionStatus
::CHANGES_PLANNED
;
58 $object->setModernRevisionStatus($status_planned);
61 protected function validateAction($object, PhabricatorUser
$viewer) {
62 if ($object->isDraft()) {
64 // See PHI346. Until the "Draft" state fully unprototypes, allow drafts
65 // to be moved to "changes planned" via the API. This preserves the
66 // behavior of "arc diff --plan-changes". We still prevent this
67 // transition from the web UI.
68 // TODO: Remove this once drafts leave prototype.
70 $editor = $this->getEditor();
71 $type_web = PhabricatorWebContentSource
::SOURCECONST
;
72 if ($editor->getContentSource()->getSource() == $type_web) {
74 pht('You can not plan changes to a draft revision.'));
78 if ($object->isChangePlanned()) {
81 'You can not request review of this revision because this '.
82 'revision is already under review and the action would have '.
86 if ($object->isClosed()) {
89 'You can not plan changes to this this revision because it has '.
90 'already been closed.'));
93 if (!$this->isViewerRevisionAuthor($object, $viewer)) {
96 'You can not plan changes to this revision because you do not '.
97 'own it. Only the author of a revision can plan changes to it.'));
101 public function getTitle() {
102 if ($this->isDraftDemotion()) {
104 '%s returned this revision to the author for changes because remote '.
106 $this->renderAuthor());
109 '%s planned changes to this revision.',
110 $this->renderAuthor());
114 public function getTitleForFeed() {
116 '%s planned changes to %s.',
117 $this->renderAuthor(),
118 $this->renderObject());
121 private function isDraftDemotion() {
122 return (bool)$this->getMetadataValue('draft.demote');
125 public function getTransactionTypeForConduit($xaction) {
126 return 'plan-changes';
129 public function getFieldValuesForConduit($object, $data) {