mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 14:00:56 +01:00
Tailor "Restart All Builds" for the complex realities of modern build restart rules
Summary: Fixes T13348. Currently, the Harbormaster UI shows "Restart All Builds", but it really means "Restart Restartable Builds", which is often fewer than "All" builds (because of autobuilds, permissions, and/or configuration). Remove the misleading term "All" and make the workflow preview exactly which builds will and will not be affected, and why. Test Plan: {F6636313} {F6636314} {F6636315} Reviewers: amckinley Reviewed By: amckinley Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13348 Differential Revision: https://secure.phabricator.com/D20679
This commit is contained in:
parent
99c864f5e6
commit
f6621a5fdc
2 changed files with 139 additions and 26 deletions
|
@ -24,26 +24,27 @@ final class HarbormasterBuildableActionController
|
||||||
|
|
||||||
$issuable = array();
|
$issuable = array();
|
||||||
|
|
||||||
foreach ($buildable->getBuilds() as $build) {
|
$builds = $buildable->getBuilds();
|
||||||
|
foreach ($builds as $key => $build) {
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
case HarbormasterBuildCommand::COMMAND_RESTART:
|
case HarbormasterBuildCommand::COMMAND_RESTART:
|
||||||
if ($build->canRestartBuild()) {
|
if ($build->canRestartBuild()) {
|
||||||
$issuable[] = $build;
|
$issuable[$key] = $build;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HarbormasterBuildCommand::COMMAND_PAUSE:
|
case HarbormasterBuildCommand::COMMAND_PAUSE:
|
||||||
if ($build->canPauseBuild()) {
|
if ($build->canPauseBuild()) {
|
||||||
$issuable[] = $build;
|
$issuable[$key] = $build;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HarbormasterBuildCommand::COMMAND_RESUME:
|
case HarbormasterBuildCommand::COMMAND_RESUME:
|
||||||
if ($build->canResumeBuild()) {
|
if ($build->canResumeBuild()) {
|
||||||
$issuable[] = $build;
|
$issuable[$key] = $build;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HarbormasterBuildCommand::COMMAND_ABORT:
|
case HarbormasterBuildCommand::COMMAND_ABORT:
|
||||||
if ($build->canAbortBuild()) {
|
if ($build->canAbortBuild()) {
|
||||||
$issuable[] = $build;
|
$issuable[$key] = $build;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -59,6 +60,14 @@ final class HarbormasterBuildableActionController
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$building = false;
|
||||||
|
foreach ($issuable as $key => $build) {
|
||||||
|
if ($build->isBuilding()) {
|
||||||
|
$building = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$return_uri = '/'.$buildable->getMonogram();
|
$return_uri = '/'.$buildable->getMonogram();
|
||||||
if ($request->isDialogFormPost() && $issuable) {
|
if ($request->isDialogFormPost() && $issuable) {
|
||||||
$editor = id(new HarbormasterBuildableTransactionEditor())
|
$editor = id(new HarbormasterBuildableTransactionEditor())
|
||||||
|
@ -89,34 +98,137 @@ final class HarbormasterBuildableActionController
|
||||||
return id(new AphrontRedirectResponse())->setURI($return_uri);
|
return id(new AphrontRedirectResponse())->setURI($return_uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$width = AphrontDialogView::WIDTH_DEFAULT;
|
||||||
|
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
case HarbormasterBuildCommand::COMMAND_RESTART:
|
case HarbormasterBuildCommand::COMMAND_RESTART:
|
||||||
|
// See T13348. The "Restart Builds" action may restart only a subset
|
||||||
|
// of builds, so show the user a preview of which builds will actually
|
||||||
|
// restart.
|
||||||
|
|
||||||
|
$body = array();
|
||||||
|
|
||||||
if ($issuable) {
|
if ($issuable) {
|
||||||
$title = pht('Really restart builds?');
|
$title = pht('Restart Builds');
|
||||||
|
|
||||||
if ($restricted) {
|
|
||||||
$body = pht(
|
|
||||||
'You only have permission to restart some builds. Progress '.
|
|
||||||
'on builds you have permission to restart will be discarded '.
|
|
||||||
'and they will restart. Side effects of these builds will '.
|
|
||||||
'occur again. Really restart all builds?');
|
|
||||||
} else {
|
|
||||||
$body = pht(
|
|
||||||
'Progress on all builds will be discarded, and all builds will '.
|
|
||||||
'restart. Side effects of the builds will occur again. Really '.
|
|
||||||
'restart all builds?');
|
|
||||||
}
|
|
||||||
|
|
||||||
$submit = pht('Restart Builds');
|
$submit = pht('Restart Builds');
|
||||||
} else {
|
} else {
|
||||||
$title = pht('Unable to Restart Builds');
|
$title = pht('Unable to Restart Builds');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($builds) {
|
||||||
|
$width = AphrontDialogView::WIDTH_FORM;
|
||||||
|
|
||||||
|
$body[] = pht('Builds for this buildable:');
|
||||||
|
|
||||||
|
$rows = array();
|
||||||
|
foreach ($builds as $key => $build) {
|
||||||
|
if (isset($issuable[$key])) {
|
||||||
|
$icon = id(new PHUIIconView())
|
||||||
|
->setIcon('fa-repeat green');
|
||||||
|
$build_note = pht('Will Restart');
|
||||||
|
} else {
|
||||||
|
$icon = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
$build->assertCanRestartBuild();
|
||||||
|
} catch (HarbormasterRestartException $ex) {
|
||||||
|
$icon = id(new PHUIIconView())
|
||||||
|
->setIcon('fa-times red');
|
||||||
|
$build_note = pht(
|
||||||
|
'%s: %s',
|
||||||
|
phutil_tag('strong', array(), pht('Not Restartable')),
|
||||||
|
$ex->getTitle());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$icon) {
|
||||||
|
try {
|
||||||
|
$build->assertCanIssueCommand($viewer, $action);
|
||||||
|
} catch (PhabricatorPolicyException $ex) {
|
||||||
|
$icon = id(new PHUIIconView())
|
||||||
|
->setIcon('fa-lock red');
|
||||||
|
$build_note = pht(
|
||||||
|
'%s: %s',
|
||||||
|
phutil_tag('strong', array(), pht('Not Restartable')),
|
||||||
|
pht('You do not have permission to restart this build.'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$icon) {
|
||||||
|
$icon = id(new PHUIIconView())
|
||||||
|
->setIcon('fa-times red');
|
||||||
|
$build_note = pht('Will Not Restart');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$build_name = phutil_tag(
|
||||||
|
'a',
|
||||||
|
array(
|
||||||
|
'href' => $build->getURI(),
|
||||||
|
'target' => '_blank',
|
||||||
|
),
|
||||||
|
pht('%s %s', $build->getObjectName(), $build->getName()));
|
||||||
|
|
||||||
|
$rows[] = array(
|
||||||
|
$icon,
|
||||||
|
$build_name,
|
||||||
|
$build_note,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$table = id(new AphrontTableView($rows))
|
||||||
|
->setHeaders(
|
||||||
|
array(
|
||||||
|
null,
|
||||||
|
pht('Build'),
|
||||||
|
pht('Action'),
|
||||||
|
))
|
||||||
|
->setColumnClasses(
|
||||||
|
array(
|
||||||
|
null,
|
||||||
|
'pri',
|
||||||
|
'wide',
|
||||||
|
));
|
||||||
|
|
||||||
|
$table = phutil_tag(
|
||||||
|
'div',
|
||||||
|
array(
|
||||||
|
'class' => 'mlt mlb',
|
||||||
|
),
|
||||||
|
$table);
|
||||||
|
|
||||||
|
$body[] = $table;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($issuable) {
|
||||||
|
$warnings = array();
|
||||||
|
|
||||||
if ($restricted) {
|
if ($restricted) {
|
||||||
$body = pht('You do not have permission to restart any builds.');
|
$warnings[] = pht(
|
||||||
|
'You only have permission to restart some builds.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($building) {
|
||||||
|
$warnings[] = pht(
|
||||||
|
'Progress on running builds will be discarded.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$warnings[] = pht(
|
||||||
|
'When a build is restarted, side effects associated with '.
|
||||||
|
'the build may occur again.');
|
||||||
|
|
||||||
|
$body[] = id(new PHUIInfoView())
|
||||||
|
->setSeverity(PHUIInfoView::SEVERITY_WARNING)
|
||||||
|
->setErrors($warnings);
|
||||||
|
|
||||||
|
$body[] = pht('Really restart builds?');
|
||||||
} else {
|
} else {
|
||||||
$body = pht('No builds can be restarted.');
|
if ($restricted) {
|
||||||
|
$body[] = pht('You do not have permission to restart any builds.');
|
||||||
|
} else {
|
||||||
|
$body[] = pht('No builds can be restarted.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case HarbormasterBuildCommand::COMMAND_PAUSE:
|
case HarbormasterBuildCommand::COMMAND_PAUSE:
|
||||||
if ($issuable) {
|
if ($issuable) {
|
||||||
|
@ -193,6 +305,7 @@ final class HarbormasterBuildableActionController
|
||||||
|
|
||||||
$dialog = id(new AphrontDialogView())
|
$dialog = id(new AphrontDialogView())
|
||||||
->setUser($viewer)
|
->setUser($viewer)
|
||||||
|
->setWidth($width)
|
||||||
->setTitle($title)
|
->setTitle($title)
|
||||||
->appendChild($body)
|
->appendChild($body)
|
||||||
->addCancelButton($return_uri);
|
->addCancelButton($return_uri);
|
||||||
|
|
|
@ -128,7 +128,7 @@ final class HarbormasterBuildableViewController
|
||||||
$curtain->addAction(
|
$curtain->addAction(
|
||||||
id(new PhabricatorActionView())
|
id(new PhabricatorActionView())
|
||||||
->setIcon('fa-repeat')
|
->setIcon('fa-repeat')
|
||||||
->setName(pht('Restart All Builds'))
|
->setName(pht('Restart Builds'))
|
||||||
->setHref($this->getApplicationURI($restart_uri))
|
->setHref($this->getApplicationURI($restart_uri))
|
||||||
->setWorkflow(true)
|
->setWorkflow(true)
|
||||||
->setDisabled(!$can_restart || !$can_edit));
|
->setDisabled(!$can_restart || !$can_edit));
|
||||||
|
@ -136,7 +136,7 @@ final class HarbormasterBuildableViewController
|
||||||
$curtain->addAction(
|
$curtain->addAction(
|
||||||
id(new PhabricatorActionView())
|
id(new PhabricatorActionView())
|
||||||
->setIcon('fa-pause')
|
->setIcon('fa-pause')
|
||||||
->setName(pht('Pause All Builds'))
|
->setName(pht('Pause Builds'))
|
||||||
->setHref($this->getApplicationURI($pause_uri))
|
->setHref($this->getApplicationURI($pause_uri))
|
||||||
->setWorkflow(true)
|
->setWorkflow(true)
|
||||||
->setDisabled(!$can_pause || !$can_edit));
|
->setDisabled(!$can_pause || !$can_edit));
|
||||||
|
@ -144,7 +144,7 @@ final class HarbormasterBuildableViewController
|
||||||
$curtain->addAction(
|
$curtain->addAction(
|
||||||
id(new PhabricatorActionView())
|
id(new PhabricatorActionView())
|
||||||
->setIcon('fa-play')
|
->setIcon('fa-play')
|
||||||
->setName(pht('Resume All Builds'))
|
->setName(pht('Resume Builds'))
|
||||||
->setHref($this->getApplicationURI($resume_uri))
|
->setHref($this->getApplicationURI($resume_uri))
|
||||||
->setWorkflow(true)
|
->setWorkflow(true)
|
||||||
->setDisabled(!$can_resume || !$can_edit));
|
->setDisabled(!$can_resume || !$can_edit));
|
||||||
|
@ -152,7 +152,7 @@ final class HarbormasterBuildableViewController
|
||||||
$curtain->addAction(
|
$curtain->addAction(
|
||||||
id(new PhabricatorActionView())
|
id(new PhabricatorActionView())
|
||||||
->setIcon('fa-exclamation-triangle')
|
->setIcon('fa-exclamation-triangle')
|
||||||
->setName(pht('Abort All Builds'))
|
->setName(pht('Abort Builds'))
|
||||||
->setHref($this->getApplicationURI($abort_uri))
|
->setHref($this->getApplicationURI($abort_uri))
|
||||||
->setWorkflow(true)
|
->setWorkflow(true)
|
||||||
->setDisabled(!$can_abort || !$can_edit));
|
->setDisabled(!$can_abort || !$can_edit));
|
||||||
|
|
Loading…
Reference in a new issue