mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-04 10:58:25 +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. Side effects of the build will occur again. Really '.
|
||||||
'restart build?');
|
'restart build?');
|
||||||
$submit = pht('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 {
|
} else {
|
||||||
$title = pht('Unable to Restart Build');
|
$title = pht('Unable to Restart Build');
|
||||||
if ($build->isRestarting()) {
|
if ($build->isRestarting()) {
|
||||||
|
@ -135,8 +140,7 @@ final class HarbormasterBuildActionController
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$dialog = id(new AphrontDialogView())
|
$dialog = $this->newDialog()
|
||||||
->setUser($viewer)
|
|
||||||
->setTitle($title)
|
->setTitle($title)
|
||||||
->appendChild($body)
|
->appendChild($body)
|
||||||
->addCancelButton($return_uri);
|
->addCancelButton($return_uri);
|
||||||
|
@ -145,7 +149,7 @@ final class HarbormasterBuildActionController
|
||||||
$dialog->addSubmitButton($submit);
|
$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_VIEWABLE = 'view';
|
||||||
const RUNNABLE_IF_EDITABLE = 'edit';
|
const RUNNABLE_IF_EDITABLE = 'edit';
|
||||||
|
|
||||||
|
const BEHAVIOR_RESTARTABLE = 'restartable';
|
||||||
|
const RESTARTABLE_ALWAYS = 'always';
|
||||||
|
const RESTARTABLE_NEVER = 'never';
|
||||||
|
|
||||||
public function setKey($key) {
|
public function setKey($key) {
|
||||||
$this->key = $key;
|
$this->key = $key;
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -225,14 +229,14 @@ final class HarbormasterBuildPlanBehavior
|
||||||
|
|
||||||
$restart_options = array(
|
$restart_options = array(
|
||||||
id(new HarbormasterBuildPlanBehaviorOption())
|
id(new HarbormasterBuildPlanBehaviorOption())
|
||||||
->setKey('always')
|
->setKey(self::RESTARTABLE_ALWAYS)
|
||||||
->setIcon('fa-repeat green')
|
->setIcon('fa-repeat green')
|
||||||
->setName(pht('Always'))
|
->setName(pht('Always'))
|
||||||
->setIsDefault(true)
|
->setIsDefault(true)
|
||||||
->setDescription(
|
->setDescription(
|
||||||
pht('The build may be restarted.')),
|
pht('The build may be restarted.')),
|
||||||
id(new HarbormasterBuildPlanBehaviorOption())
|
id(new HarbormasterBuildPlanBehaviorOption())
|
||||||
->setKey('never')
|
->setKey(self::RESTARTABLE_NEVER)
|
||||||
->setIcon('fa-times red')
|
->setIcon('fa-times red')
|
||||||
->setName(pht('Never'))
|
->setName(pht('Never'))
|
||||||
->setDescription(
|
->setDescription(
|
||||||
|
@ -317,7 +321,7 @@ final class HarbormasterBuildPlanBehavior
|
||||||
->setName(pht('Affects Buildable'))
|
->setName(pht('Affects Buildable'))
|
||||||
->setOptions($aggregate_options),
|
->setOptions($aggregate_options),
|
||||||
id(new self())
|
id(new self())
|
||||||
->setKey('restartable')
|
->setKey(self::BEHAVIOR_RESTARTABLE)
|
||||||
->setEditInstructions(
|
->setEditInstructions(
|
||||||
pht(
|
pht(
|
||||||
'Usually, builds may be restarted. This may be useful if you '.
|
'Usually, builds may be restarted. This may be useful if you '.
|
||||||
|
|
|
@ -215,6 +215,11 @@ final class HarbormasterBuild extends HarbormasterDAO
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$plan = $this->getBuildPlan();
|
||||||
|
if (!$plan->canRestartBuildPlan()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return !$this->isRestarting();
|
return !$this->isRestarting();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -175,6 +175,16 @@ final class HarbormasterBuildPlan extends HarbormasterDAO
|
||||||
$capability);
|
$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 )----------------------------------- */
|
/* -( PhabricatorSubscribableInterface )----------------------------------- */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue