Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/differential/xaction/DifferentialRevisionPlanChangesTransaction.php
12256 views
1
<?php
2
3
final class DifferentialRevisionPlanChangesTransaction
4
extends DifferentialRevisionActionTransaction {
5
6
const TRANSACTIONTYPE = 'differential.revision.plan';
7
const ACTIONKEY = 'plan-changes';
8
9
protected function getRevisionActionLabel(
10
DifferentialRevision $revision,
11
PhabricatorUser $viewer) {
12
return pht('Plan Changes');
13
}
14
15
protected function getRevisionActionDescription(
16
DifferentialRevision $revision,
17
PhabricatorUser $viewer) {
18
return pht(
19
'This revision will be removed from review queues until it is revised.');
20
}
21
22
public function getIcon() {
23
return 'fa-headphones';
24
}
25
26
public function getColor() {
27
return 'red';
28
}
29
30
protected function getRevisionActionOrder() {
31
return 200;
32
}
33
34
public function getActionName() {
35
return pht('Planned Changes');
36
}
37
38
public function getCommandKeyword() {
39
return 'planchanges';
40
}
41
42
public function getCommandAliases() {
43
return array(
44
'rethink',
45
);
46
}
47
48
public function getCommandSummary() {
49
return pht('Plan changes to a revision.');
50
}
51
52
public function generateOldValue($object) {
53
return $object->isChangePlanned();
54
}
55
56
public function applyInternalEffects($object, $value) {
57
$status_planned = DifferentialRevisionStatus::CHANGES_PLANNED;
58
$object->setModernRevisionStatus($status_planned);
59
}
60
61
protected function validateAction($object, PhabricatorUser $viewer) {
62
if ($object->isDraft()) {
63
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.
69
70
$editor = $this->getEditor();
71
$type_web = PhabricatorWebContentSource::SOURCECONST;
72
if ($editor->getContentSource()->getSource() == $type_web) {
73
throw new Exception(
74
pht('You can not plan changes to a draft revision.'));
75
}
76
}
77
78
if ($object->isChangePlanned()) {
79
throw new Exception(
80
pht(
81
'You can not request review of this revision because this '.
82
'revision is already under review and the action would have '.
83
'no effect.'));
84
}
85
86
if ($object->isClosed()) {
87
throw new Exception(
88
pht(
89
'You can not plan changes to this this revision because it has '.
90
'already been closed.'));
91
}
92
93
if (!$this->isViewerRevisionAuthor($object, $viewer)) {
94
throw new Exception(
95
pht(
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.'));
98
}
99
}
100
101
public function getTitle() {
102
if ($this->isDraftDemotion()) {
103
return pht(
104
'%s returned this revision to the author for changes because remote '.
105
'builds failed.',
106
$this->renderAuthor());
107
} else {
108
return pht(
109
'%s planned changes to this revision.',
110
$this->renderAuthor());
111
}
112
}
113
114
public function getTitleForFeed() {
115
return pht(
116
'%s planned changes to %s.',
117
$this->renderAuthor(),
118
$this->renderObject());
119
}
120
121
private function isDraftDemotion() {
122
return (bool)$this->getMetadataValue('draft.demote');
123
}
124
125
public function getTransactionTypeForConduit($xaction) {
126
return 'plan-changes';
127
}
128
129
public function getFieldValuesForConduit($object, $data) {
130
return array();
131
}
132
133
}
134
135