mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-11 15:21:03 +01:00
Make the new Build Plan behavior "Restartable" work
Summary: Ref T13258. Implements the "Restartable" behavior, to control whether a build may be restarted or not. This is fairly straightforward because there are already other existing reasons that a build may not be able to be restarted. Test Plan: Restarted a build. Marked it as not restartable, saw "Restart" action become disabled. Tried to restart it anyway, got a useful error message. Reviewers: amckinley Reviewed By: amckinley Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13258 Differential Revision: https://secure.phabricator.com/D20230
This commit is contained in:
parent
ee0ad4703e
commit
578de333df
4 changed files with 29 additions and 6 deletions
|
@ -64,6 +64,11 @@ final class HarbormasterBuildActionController
|
|||
'restart. Side effects of the build will occur again. Really '.
|
||||
'restart build?');
|
||||
$submit = pht('Restart Build');
|
||||
} else if (!$build->getBuildPlan()->canRestartBuildPlan()) {
|
||||
$title = pht('Not Restartable');
|
||||
$body = pht(
|
||||
'The build plan for this build is not restartable, so you '.
|
||||
'can not restart the build.');
|
||||
} else {
|
||||
$title = pht('Unable to Restart Build');
|
||||
if ($build->isRestarting()) {
|
||||
|
@ -135,8 +140,7 @@ final class HarbormasterBuildActionController
|
|||
break;
|
||||
}
|
||||
|
||||
$dialog = id(new AphrontDialogView())
|
||||
->setUser($viewer)
|
||||
$dialog = $this->newDialog()
|
||||
->setTitle($title)
|
||||
->appendChild($body)
|
||||
->addCancelButton($return_uri);
|
||||
|
@ -145,7 +149,7 @@ final class HarbormasterBuildActionController
|
|||
$dialog->addSubmitButton($submit);
|
||||
}
|
||||
|
||||
return id(new AphrontDialogResponse())->setDialog($dialog);
|
||||
return $dialog;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,6 +13,10 @@ final class HarbormasterBuildPlanBehavior
|
|||
const RUNNABLE_IF_VIEWABLE = 'view';
|
||||
const RUNNABLE_IF_EDITABLE = 'edit';
|
||||
|
||||
const BEHAVIOR_RESTARTABLE = 'restartable';
|
||||
const RESTARTABLE_ALWAYS = 'always';
|
||||
const RESTARTABLE_NEVER = 'never';
|
||||
|
||||
public function setKey($key) {
|
||||
$this->key = $key;
|
||||
return $this;
|
||||
|
@ -225,14 +229,14 @@ final class HarbormasterBuildPlanBehavior
|
|||
|
||||
$restart_options = array(
|
||||
id(new HarbormasterBuildPlanBehaviorOption())
|
||||
->setKey('always')
|
||||
->setKey(self::RESTARTABLE_ALWAYS)
|
||||
->setIcon('fa-repeat green')
|
||||
->setName(pht('Always'))
|
||||
->setIsDefault(true)
|
||||
->setDescription(
|
||||
pht('The build may be restarted.')),
|
||||
id(new HarbormasterBuildPlanBehaviorOption())
|
||||
->setKey('never')
|
||||
->setKey(self::RESTARTABLE_NEVER)
|
||||
->setIcon('fa-times red')
|
||||
->setName(pht('Never'))
|
||||
->setDescription(
|
||||
|
@ -317,7 +321,7 @@ final class HarbormasterBuildPlanBehavior
|
|||
->setName(pht('Affects Buildable'))
|
||||
->setOptions($aggregate_options),
|
||||
id(new self())
|
||||
->setKey('restartable')
|
||||
->setKey(self::BEHAVIOR_RESTARTABLE)
|
||||
->setEditInstructions(
|
||||
pht(
|
||||
'Usually, builds may be restarted. This may be useful if you '.
|
||||
|
|
|
@ -215,6 +215,11 @@ final class HarbormasterBuild extends HarbormasterDAO
|
|||
return false;
|
||||
}
|
||||
|
||||
$plan = $this->getBuildPlan();
|
||||
if (!$plan->canRestartBuildPlan()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !$this->isRestarting();
|
||||
}
|
||||
|
||||
|
|
|
@ -175,6 +175,16 @@ final class HarbormasterBuildPlan extends HarbormasterDAO
|
|||
$capability);
|
||||
}
|
||||
|
||||
public function canRestartBuildPlan() {
|
||||
$restartable = HarbormasterBuildPlanBehavior::BEHAVIOR_RESTARTABLE;
|
||||
$is_restartable = HarbormasterBuildPlanBehavior::RESTARTABLE_ALWAYS;
|
||||
|
||||
$option = HarbormasterBuildPlanBehavior::getBehavior($restartable)
|
||||
->getPlanOption($this);
|
||||
|
||||
return ($option->getKey() === $is_restartable);
|
||||
}
|
||||
|
||||
|
||||
/* -( PhabricatorSubscribableInterface )----------------------------------- */
|
||||
|
||||
|
|
Loading…
Reference in a new issue