Differential D21691 Diff 51704 src/applications/harbormaster/xaction/build/HarbormasterBuildMessageAbortTransaction.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/harbormaster/xaction/build/HarbormasterBuildMessageAbortTransaction.php
<?php | <?php | ||||
final class HarbormasterBuildMessageAbortTransaction | final class HarbormasterBuildMessageAbortTransaction | ||||
extends HarbormasterBuildMessageTransaction { | extends HarbormasterBuildMessageTransaction { | ||||
const TRANSACTIONTYPE = 'message/abort'; | const TRANSACTIONTYPE = 'message/abort'; | ||||
const MESSAGETYPE = 'abort'; | |||||
public function getMessageType() { | public function getHarbormasterBuildMessageName() { | ||||
return 'abort'; | return pht('Abort Build'); | ||||
} | |||||
public function getHarbormasterBuildableMessageName() { | |||||
return pht('Abort Builds'); | |||||
} | |||||
public function newConfirmPromptTitle() { | |||||
return pht('Really abort build?'); | |||||
} | |||||
public function getHarbormasterBuildableMessageEffect() { | |||||
return pht('Build will abort.'); | |||||
} | |||||
public function newConfirmPromptBody() { | |||||
return pht( | |||||
'Progress on this build will be discarded. Really abort build?'); | |||||
} | |||||
public function newBuildableConfirmPromptTitle( | |||||
array $builds, | |||||
array $sendable) { | |||||
return pht( | |||||
'Really abort %s build(s)?', | |||||
phutil_count($builds)); | |||||
} | |||||
public function newBuildableConfirmPromptBody( | |||||
array $builds, | |||||
array $sendable) { | |||||
if (count($sendable) === count($builds)) { | |||||
return pht( | |||||
'If you abort all builds, work will halt immediately. Work '. | |||||
'will be discarded, and builds must be completely restarted.'); | |||||
} else { | |||||
return pht( | |||||
'You can only abort some builds. Work will halt immediately on '. | |||||
'builds you can abort. Progress will be discarded, and builds must '. | |||||
'be completely restarted if you want them to complete.'); | |||||
} | |||||
} | } | ||||
public function getTitle() { | public function getTitle() { | ||||
return pht( | return pht( | ||||
'%s aborted this build.', | '%s aborted this build.', | ||||
$this->renderAuthor()); | $this->renderAuthor()); | ||||
} | } | ||||
Show All 14 Lines | final class HarbormasterBuildMessageAbortTransaction | ||||
public function applyExternalEffects($object, $value) { | public function applyExternalEffects($object, $value) { | ||||
$actor = $this->getActor(); | $actor = $this->getActor(); | ||||
$build = $object; | $build = $object; | ||||
$build->releaseAllArtifacts($actor); | $build->releaseAllArtifacts($actor); | ||||
} | } | ||||
protected function newCanApplyMessageAssertion( | |||||
PhabricatorUser $viewer, | |||||
HarbormasterBuild $build) { | |||||
if ($build->isAutobuild()) { | |||||
throw new HarbormasterRestartException( | |||||
pht('Unable to Abort Build'), | |||||
pht( | |||||
'You can not abort a build that uses an autoplan.')); | |||||
} | |||||
if ($build->isComplete()) { | |||||
throw new HarbormasterRestartException( | |||||
pht('Unable to Abort Build'), | |||||
pht( | |||||
'You can not abort this biuld because it is already complete.')); | |||||
} | |||||
} | |||||
protected function newCanSendMessageAssertion( | |||||
PhabricatorUser $viewer, | |||||
HarbormasterBuild $build) { | |||||
if ($build->isAborting()) { | |||||
throw new HarbormasterRestartException( | |||||
pht('Unable to Abort Build'), | |||||
pht( | |||||
'You can not abort this build because it is already aborting.')); | |||||
} | |||||
} | |||||
} | } |