mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
Improve restart/stop/resume UI
Summary: Ref T1049. Improves the UI: - Pending commands, like "stopping", are shown separately from the current status. - Pending commands are shown on the list view. - Builds can be restarted, stopped and resumed from the list view. - Add a missing crumb. Test Plan: {F99022} {F99023} Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T1049 Differential Revision: https://secure.phabricator.com/D7898
This commit is contained in:
parent
6dc582f459
commit
b952b6f619
5 changed files with 102 additions and 42 deletions
|
@ -55,7 +55,7 @@ final class PhabricatorApplicationHarbormaster extends PhabricatorApplication {
|
|||
),
|
||||
'build/' => array(
|
||||
'(?:(?P<id>\d+)/)?' => 'HarbormasterBuildViewController',
|
||||
'(?P<action>stop|resume|restart)/(?:(?P<id>\d+)/)?'
|
||||
'(?P<action>stop|resume|restart)/(?P<id>\d+)/(?:(?P<via>[^/]+)/)?'
|
||||
=> 'HarbormasterBuildActionController',
|
||||
),
|
||||
'plan/' => array(
|
||||
|
|
|
@ -5,10 +5,12 @@ final class HarbormasterBuildActionController
|
|||
|
||||
private $id;
|
||||
private $action;
|
||||
private $via;
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->id = $data['id'];
|
||||
$this->action = $data['action'];
|
||||
$this->via = idx($data, 'via');
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
|
@ -38,7 +40,14 @@ final class HarbormasterBuildActionController
|
|||
return new Aphront400Response();
|
||||
}
|
||||
|
||||
$build_uri = $this->getApplicationURI('/build/'.$build->getID().'/');
|
||||
switch ($this->via) {
|
||||
case 'buildable':
|
||||
$return_uri = $build->getBuildable()->getMonogram();
|
||||
break;
|
||||
default:
|
||||
$return_uri = $this->getApplicationURI('/build/'.$build->getID().'/');
|
||||
break;
|
||||
}
|
||||
|
||||
if ($request->isDialogFormPost() && $can_issue) {
|
||||
|
||||
|
@ -58,7 +67,7 @@ final class HarbormasterBuildActionController
|
|||
'buildID' => $build->getID()
|
||||
));
|
||||
|
||||
return id(new AphrontRedirectResponse())->setURI($build_uri);
|
||||
return id(new AphrontRedirectResponse())->setURI($return_uri);
|
||||
}
|
||||
|
||||
switch ($command) {
|
||||
|
@ -134,7 +143,7 @@ final class HarbormasterBuildActionController
|
|||
->setUser($viewer)
|
||||
->setTitle($title)
|
||||
->appendChild($body)
|
||||
->addCancelButton($build_uri);
|
||||
->addCancelButton($return_uri);
|
||||
|
||||
if ($can_issue) {
|
||||
$dialog->addSubmitButton($submit);
|
||||
|
|
|
@ -30,6 +30,14 @@ final class HarbormasterBuildViewController
|
|||
->setUser($viewer)
|
||||
->setPolicyObject($build);
|
||||
|
||||
if ($build->isRestarting()) {
|
||||
$header->setStatus('warning', 'red', pht('Restarting'));
|
||||
} else if ($build->isStopping()) {
|
||||
$header->setStatus('warning', 'red', pht('Stopping'));
|
||||
} else if ($build->isResuming()) {
|
||||
$header->setStatus('warning', 'red', pht('Resuming'));
|
||||
}
|
||||
|
||||
$box = id(new PHUIObjectBoxView())
|
||||
->setHeader($header);
|
||||
|
||||
|
@ -37,6 +45,9 @@ final class HarbormasterBuildViewController
|
|||
$this->buildPropertyLists($box, $build, $actions);
|
||||
|
||||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs->addTextCrumb(
|
||||
$build->getBuildable()->getMonogram(),
|
||||
'/'.$build->getBuildable()->getMonogram());
|
||||
$crumbs->addTextCrumb($title);
|
||||
|
||||
$build_targets = id(new HarbormasterBuildTargetQuery())
|
||||
|
|
|
@ -38,45 +38,81 @@ final class HarbormasterBuildableViewController
|
|||
->setObjectName(pht('Build %d', $build->getID()))
|
||||
->setHeader($build->getName())
|
||||
->setHref($view_uri);
|
||||
if ($build->isStopping()) {
|
||||
$item->setBarColor('black');
|
||||
$item->addAttribute(pht('Stopping'));
|
||||
} else {
|
||||
switch ($build->getBuildStatus()) {
|
||||
case HarbormasterBuild::STATUS_INACTIVE:
|
||||
$item->setBarColor('grey');
|
||||
$item->addAttribute(pht('Inactive'));
|
||||
break;
|
||||
case HarbormasterBuild::STATUS_PENDING:
|
||||
$item->setBarColor('blue');
|
||||
$item->addAttribute(pht('Pending'));
|
||||
break;
|
||||
case HarbormasterBuild::STATUS_WAITING:
|
||||
$item->setBarColor('violet');
|
||||
$item->addAttribute(pht('Waiting'));
|
||||
break;
|
||||
case HarbormasterBuild::STATUS_BUILDING:
|
||||
$item->setBarColor('yellow');
|
||||
$item->addAttribute(pht('Building'));
|
||||
break;
|
||||
case HarbormasterBuild::STATUS_PASSED:
|
||||
$item->setBarColor('green');
|
||||
$item->addAttribute(pht('Passed'));
|
||||
break;
|
||||
case HarbormasterBuild::STATUS_FAILED:
|
||||
$item->setBarColor('red');
|
||||
$item->addAttribute(pht('Failed'));
|
||||
break;
|
||||
case HarbormasterBuild::STATUS_ERROR:
|
||||
$item->setBarColor('red');
|
||||
$item->addAttribute(pht('Unexpected Error'));
|
||||
break;
|
||||
case HarbormasterBuild::STATUS_STOPPED:
|
||||
$item->setBarColor('black');
|
||||
$item->addAttribute(pht('Stopped'));
|
||||
break;
|
||||
}
|
||||
|
||||
switch ($build->getBuildStatus()) {
|
||||
case HarbormasterBuild::STATUS_INACTIVE:
|
||||
$item->setBarColor('grey');
|
||||
$item->addAttribute(pht('Inactive'));
|
||||
break;
|
||||
case HarbormasterBuild::STATUS_PENDING:
|
||||
$item->setBarColor('blue');
|
||||
$item->addAttribute(pht('Pending'));
|
||||
break;
|
||||
case HarbormasterBuild::STATUS_WAITING:
|
||||
$item->setBarColor('violet');
|
||||
$item->addAttribute(pht('Waiting'));
|
||||
break;
|
||||
case HarbormasterBuild::STATUS_BUILDING:
|
||||
$item->setBarColor('yellow');
|
||||
$item->addAttribute(pht('Building'));
|
||||
break;
|
||||
case HarbormasterBuild::STATUS_PASSED:
|
||||
$item->setBarColor('green');
|
||||
$item->addAttribute(pht('Passed'));
|
||||
break;
|
||||
case HarbormasterBuild::STATUS_FAILED:
|
||||
$item->setBarColor('red');
|
||||
$item->addAttribute(pht('Failed'));
|
||||
break;
|
||||
case HarbormasterBuild::STATUS_ERROR:
|
||||
$item->setBarColor('red');
|
||||
$item->addAttribute(pht('Unexpected Error'));
|
||||
break;
|
||||
case HarbormasterBuild::STATUS_STOPPED:
|
||||
$item->setBarColor('black');
|
||||
$item->addAttribute(pht('Stopped'));
|
||||
break;
|
||||
}
|
||||
|
||||
if ($build->isRestarting()) {
|
||||
$item->addIcon('backward', pht('Restarting'));
|
||||
} else if ($build->isStopping()) {
|
||||
$item->addIcon('stop', pht('Stopping'));
|
||||
} else if ($build->isResuming()) {
|
||||
$item->addIcon('play', pht('Resuming'));
|
||||
}
|
||||
|
||||
$build_id = $build->getID();
|
||||
|
||||
$restart_uri = "build/restart/{$build_id}/buildable/";
|
||||
$resume_uri = "build/resume/{$build_id}/buildable/";
|
||||
$stop_uri = "build/stop/{$build_id}/buildable/";
|
||||
|
||||
$item->addAction(
|
||||
id(new PHUIListItemView())
|
||||
->setIcon('backward')
|
||||
->setName(pht('Restart'))
|
||||
->setHref($this->getApplicationURI($restart_uri))
|
||||
->setWorkflow(true)
|
||||
->setDisabled(!$build->canRestartBuild()));
|
||||
|
||||
if ($build->canResumeBuild()) {
|
||||
$item->addAction(
|
||||
id(new PHUIListItemView())
|
||||
->setIcon('play')
|
||||
->setName(pht('Resume'))
|
||||
->setHref($this->getApplicationURI($resume_uri))
|
||||
->setWorkflow(true));
|
||||
} else {
|
||||
$item->addAction(
|
||||
id(new PHUIListItemView())
|
||||
->setIcon('stop')
|
||||
->setName(pht('Stop'))
|
||||
->setHref($this->getApplicationURI($stop_uri))
|
||||
->setWorkflow(true)
|
||||
->setDisabled(!$build->canStopBuild()));
|
||||
}
|
||||
|
||||
$build_list->addItem($item);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,10 @@ final class HarbormasterBuildable extends HarbormasterDAO
|
|||
->setBuildableStatus(self::STATUS_WHATEVER);
|
||||
}
|
||||
|
||||
public function getMonogram() {
|
||||
return 'B'.$this->getID();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an existing buildable for the object's PHID or creates a
|
||||
* new buildable implicitly if needed.
|
||||
|
|
Loading…
Reference in a new issue