Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/harbormaster/xaction/build/HarbormasterBuildMessagePauseTransaction.php
12264 views
1
<?php
2
3
final class HarbormasterBuildMessagePauseTransaction
4
extends HarbormasterBuildMessageTransaction {
5
6
const TRANSACTIONTYPE = 'message/pause';
7
const MESSAGETYPE = 'pause';
8
9
public function getHarbormasterBuildMessageName() {
10
return pht('Pause Build');
11
}
12
13
public function getHarbormasterBuildableMessageName() {
14
return pht('Pause Builds');
15
}
16
17
public function newConfirmPromptTitle() {
18
return pht('Really pause build?');
19
}
20
21
public function getHarbormasterBuildableMessageEffect() {
22
return pht('Build will pause.');
23
}
24
25
public function newConfirmPromptBody() {
26
return pht(
27
'If you pause this build, work will halt once the current steps '.
28
'complete. You can resume the build later.');
29
}
30
31
32
public function getHarbormasterBuildMessageDescription() {
33
return pht('Pause the build.');
34
}
35
36
public function newBuildableConfirmPromptTitle(
37
array $builds,
38
array $sendable) {
39
return pht(
40
'Really pause %s build(s)?',
41
phutil_count($builds));
42
}
43
44
public function newBuildableConfirmPromptBody(
45
array $builds,
46
array $sendable) {
47
48
if (count($sendable) === count($builds)) {
49
return pht(
50
'If you pause all builds, work will halt once the current steps '.
51
'complete. You can resume the builds later.');
52
} else {
53
return pht(
54
'You can only pause some builds. Once the current steps complete, '.
55
'work will halt on builds you can pause. You can resume the builds '.
56
'later.');
57
}
58
}
59
60
public function getTitle() {
61
return pht(
62
'%s paused this build.',
63
$this->renderAuthor());
64
}
65
66
public function getIcon() {
67
return 'fa-pause';
68
}
69
70
public function getColor() {
71
return 'red';
72
}
73
74
public function applyInternalEffects($object, $value) {
75
$actor = $this->getActor();
76
$build = $object;
77
78
$build->setBuildStatus(HarbormasterBuildStatus::STATUS_PAUSED);
79
}
80
81
protected function newCanApplyMessageAssertion(
82
PhabricatorUser $viewer,
83
HarbormasterBuild $build) {
84
85
if ($build->isAutobuild()) {
86
throw new HarbormasterMessageException(
87
pht('Unable to Pause Build'),
88
pht('You can not pause a build that uses an autoplan.'));
89
}
90
91
if ($build->isPaused()) {
92
throw new HarbormasterMessageException(
93
pht('Unable to Pause Build'),
94
pht('You can not pause this build because it is already paused.'));
95
}
96
97
if ($build->isComplete()) {
98
throw new HarbormasterMessageException(
99
pht('Unable to Pause Build'),
100
pht('You can not pause this build because it has already completed.'));
101
}
102
}
103
104
protected function newCanSendMessageAssertion(
105
PhabricatorUser $viewer,
106
HarbormasterBuild $build) {
107
108
if ($build->isPausing()) {
109
throw new HarbormasterMessageException(
110
pht('Unable to Pause Build'),
111
pht('You can not pause this build because it is already pausing.'));
112
}
113
114
if ($build->isRestarting()) {
115
throw new HarbormasterMessageException(
116
pht('Unable to Pause Build'),
117
pht('You can not pause this build because it is already restarting.'));
118
}
119
120
if ($build->isAborting()) {
121
throw new HarbormasterMessageException(
122
pht('Unable to Pause Build'),
123
pht('You can not pause this build because it is already aborting.'));
124
}
125
}
126
}
127
128