mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-10 23:01:04 +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(
|
'build/' => array(
|
||||||
'(?:(?P<id>\d+)/)?' => 'HarbormasterBuildViewController',
|
'(?:(?P<id>\d+)/)?' => 'HarbormasterBuildViewController',
|
||||||
'(?P<action>stop|resume|restart)/(?:(?P<id>\d+)/)?'
|
'(?P<action>stop|resume|restart)/(?P<id>\d+)/(?:(?P<via>[^/]+)/)?'
|
||||||
=> 'HarbormasterBuildActionController',
|
=> 'HarbormasterBuildActionController',
|
||||||
),
|
),
|
||||||
'plan/' => array(
|
'plan/' => array(
|
||||||
|
|
|
@ -5,10 +5,12 @@ final class HarbormasterBuildActionController
|
||||||
|
|
||||||
private $id;
|
private $id;
|
||||||
private $action;
|
private $action;
|
||||||
|
private $via;
|
||||||
|
|
||||||
public function willProcessRequest(array $data) {
|
public function willProcessRequest(array $data) {
|
||||||
$this->id = $data['id'];
|
$this->id = $data['id'];
|
||||||
$this->action = $data['action'];
|
$this->action = $data['action'];
|
||||||
|
$this->via = idx($data, 'via');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function processRequest() {
|
public function processRequest() {
|
||||||
|
@ -38,7 +40,14 @@ final class HarbormasterBuildActionController
|
||||||
return new Aphront400Response();
|
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) {
|
if ($request->isDialogFormPost() && $can_issue) {
|
||||||
|
|
||||||
|
@ -58,7 +67,7 @@ final class HarbormasterBuildActionController
|
||||||
'buildID' => $build->getID()
|
'buildID' => $build->getID()
|
||||||
));
|
));
|
||||||
|
|
||||||
return id(new AphrontRedirectResponse())->setURI($build_uri);
|
return id(new AphrontRedirectResponse())->setURI($return_uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($command) {
|
switch ($command) {
|
||||||
|
@ -134,7 +143,7 @@ final class HarbormasterBuildActionController
|
||||||
->setUser($viewer)
|
->setUser($viewer)
|
||||||
->setTitle($title)
|
->setTitle($title)
|
||||||
->appendChild($body)
|
->appendChild($body)
|
||||||
->addCancelButton($build_uri);
|
->addCancelButton($return_uri);
|
||||||
|
|
||||||
if ($can_issue) {
|
if ($can_issue) {
|
||||||
$dialog->addSubmitButton($submit);
|
$dialog->addSubmitButton($submit);
|
||||||
|
|
|
@ -30,6 +30,14 @@ final class HarbormasterBuildViewController
|
||||||
->setUser($viewer)
|
->setUser($viewer)
|
||||||
->setPolicyObject($build);
|
->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())
|
$box = id(new PHUIObjectBoxView())
|
||||||
->setHeader($header);
|
->setHeader($header);
|
||||||
|
|
||||||
|
@ -37,6 +45,9 @@ final class HarbormasterBuildViewController
|
||||||
$this->buildPropertyLists($box, $build, $actions);
|
$this->buildPropertyLists($box, $build, $actions);
|
||||||
|
|
||||||
$crumbs = $this->buildApplicationCrumbs();
|
$crumbs = $this->buildApplicationCrumbs();
|
||||||
|
$crumbs->addTextCrumb(
|
||||||
|
$build->getBuildable()->getMonogram(),
|
||||||
|
'/'.$build->getBuildable()->getMonogram());
|
||||||
$crumbs->addTextCrumb($title);
|
$crumbs->addTextCrumb($title);
|
||||||
|
|
||||||
$build_targets = id(new HarbormasterBuildTargetQuery())
|
$build_targets = id(new HarbormasterBuildTargetQuery())
|
||||||
|
|
|
@ -38,45 +38,81 @@ final class HarbormasterBuildableViewController
|
||||||
->setObjectName(pht('Build %d', $build->getID()))
|
->setObjectName(pht('Build %d', $build->getID()))
|
||||||
->setHeader($build->getName())
|
->setHeader($build->getName())
|
||||||
->setHref($view_uri);
|
->setHref($view_uri);
|
||||||
if ($build->isStopping()) {
|
|
||||||
$item->setBarColor('black');
|
switch ($build->getBuildStatus()) {
|
||||||
$item->addAttribute(pht('Stopping'));
|
case HarbormasterBuild::STATUS_INACTIVE:
|
||||||
} else {
|
$item->setBarColor('grey');
|
||||||
switch ($build->getBuildStatus()) {
|
$item->addAttribute(pht('Inactive'));
|
||||||
case HarbormasterBuild::STATUS_INACTIVE:
|
break;
|
||||||
$item->setBarColor('grey');
|
case HarbormasterBuild::STATUS_PENDING:
|
||||||
$item->addAttribute(pht('Inactive'));
|
$item->setBarColor('blue');
|
||||||
break;
|
$item->addAttribute(pht('Pending'));
|
||||||
case HarbormasterBuild::STATUS_PENDING:
|
break;
|
||||||
$item->setBarColor('blue');
|
case HarbormasterBuild::STATUS_WAITING:
|
||||||
$item->addAttribute(pht('Pending'));
|
$item->setBarColor('violet');
|
||||||
break;
|
$item->addAttribute(pht('Waiting'));
|
||||||
case HarbormasterBuild::STATUS_WAITING:
|
break;
|
||||||
$item->setBarColor('violet');
|
case HarbormasterBuild::STATUS_BUILDING:
|
||||||
$item->addAttribute(pht('Waiting'));
|
$item->setBarColor('yellow');
|
||||||
break;
|
$item->addAttribute(pht('Building'));
|
||||||
case HarbormasterBuild::STATUS_BUILDING:
|
break;
|
||||||
$item->setBarColor('yellow');
|
case HarbormasterBuild::STATUS_PASSED:
|
||||||
$item->addAttribute(pht('Building'));
|
$item->setBarColor('green');
|
||||||
break;
|
$item->addAttribute(pht('Passed'));
|
||||||
case HarbormasterBuild::STATUS_PASSED:
|
break;
|
||||||
$item->setBarColor('green');
|
case HarbormasterBuild::STATUS_FAILED:
|
||||||
$item->addAttribute(pht('Passed'));
|
$item->setBarColor('red');
|
||||||
break;
|
$item->addAttribute(pht('Failed'));
|
||||||
case HarbormasterBuild::STATUS_FAILED:
|
break;
|
||||||
$item->setBarColor('red');
|
case HarbormasterBuild::STATUS_ERROR:
|
||||||
$item->addAttribute(pht('Failed'));
|
$item->setBarColor('red');
|
||||||
break;
|
$item->addAttribute(pht('Unexpected Error'));
|
||||||
case HarbormasterBuild::STATUS_ERROR:
|
break;
|
||||||
$item->setBarColor('red');
|
case HarbormasterBuild::STATUS_STOPPED:
|
||||||
$item->addAttribute(pht('Unexpected Error'));
|
$item->setBarColor('black');
|
||||||
break;
|
$item->addAttribute(pht('Stopped'));
|
||||||
case HarbormasterBuild::STATUS_STOPPED:
|
break;
|
||||||
$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);
|
$build_list->addItem($item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,10 @@ final class HarbormasterBuildable extends HarbormasterDAO
|
||||||
->setBuildableStatus(self::STATUS_WHATEVER);
|
->setBuildableStatus(self::STATUS_WHATEVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getMonogram() {
|
||||||
|
return 'B'.$this->getID();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an existing buildable for the object's PHID or creates a
|
* Returns an existing buildable for the object's PHID or creates a
|
||||||
* new buildable implicitly if needed.
|
* new buildable implicitly if needed.
|
||||||
|
|
Loading…
Reference in a new issue