Path: blob/master/src/applications/harbormaster/xaction/build/HarbormasterBuildMessagePauseTransaction.php
12264 views
<?php12final class HarbormasterBuildMessagePauseTransaction3extends HarbormasterBuildMessageTransaction {45const TRANSACTIONTYPE = 'message/pause';6const MESSAGETYPE = 'pause';78public function getHarbormasterBuildMessageName() {9return pht('Pause Build');10}1112public function getHarbormasterBuildableMessageName() {13return pht('Pause Builds');14}1516public function newConfirmPromptTitle() {17return pht('Really pause build?');18}1920public function getHarbormasterBuildableMessageEffect() {21return pht('Build will pause.');22}2324public function newConfirmPromptBody() {25return pht(26'If you pause this build, work will halt once the current steps '.27'complete. You can resume the build later.');28}293031public function getHarbormasterBuildMessageDescription() {32return pht('Pause the build.');33}3435public function newBuildableConfirmPromptTitle(36array $builds,37array $sendable) {38return pht(39'Really pause %s build(s)?',40phutil_count($builds));41}4243public function newBuildableConfirmPromptBody(44array $builds,45array $sendable) {4647if (count($sendable) === count($builds)) {48return pht(49'If you pause all builds, work will halt once the current steps '.50'complete. You can resume the builds later.');51} else {52return pht(53'You can only pause some builds. Once the current steps complete, '.54'work will halt on builds you can pause. You can resume the builds '.55'later.');56}57}5859public function getTitle() {60return pht(61'%s paused this build.',62$this->renderAuthor());63}6465public function getIcon() {66return 'fa-pause';67}6869public function getColor() {70return 'red';71}7273public function applyInternalEffects($object, $value) {74$actor = $this->getActor();75$build = $object;7677$build->setBuildStatus(HarbormasterBuildStatus::STATUS_PAUSED);78}7980protected function newCanApplyMessageAssertion(81PhabricatorUser $viewer,82HarbormasterBuild $build) {8384if ($build->isAutobuild()) {85throw new HarbormasterMessageException(86pht('Unable to Pause Build'),87pht('You can not pause a build that uses an autoplan.'));88}8990if ($build->isPaused()) {91throw new HarbormasterMessageException(92pht('Unable to Pause Build'),93pht('You can not pause this build because it is already paused.'));94}9596if ($build->isComplete()) {97throw new HarbormasterMessageException(98pht('Unable to Pause Build'),99pht('You can not pause this build because it has already completed.'));100}101}102103protected function newCanSendMessageAssertion(104PhabricatorUser $viewer,105HarbormasterBuild $build) {106107if ($build->isPausing()) {108throw new HarbormasterMessageException(109pht('Unable to Pause Build'),110pht('You can not pause this build because it is already pausing.'));111}112113if ($build->isRestarting()) {114throw new HarbormasterMessageException(115pht('Unable to Pause Build'),116pht('You can not pause this build because it is already restarting.'));117}118119if ($build->isAborting()) {120throw new HarbormasterMessageException(121pht('Unable to Pause Build'),122pht('You can not pause this build because it is already aborting.'));123}124}125}126127128