@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+101 -41
+1 -1
src/applications/harbormaster/application/PhabricatorApplicationHarbormaster.php
··· 55 55 ), 56 56 'build/' => array( 57 57 '(?:(?P<id>\d+)/)?' => 'HarbormasterBuildViewController', 58 - '(?P<action>stop|resume|restart)/(?:(?P<id>\d+)/)?' 58 + '(?P<action>stop|resume|restart)/(?P<id>\d+)/(?:(?P<via>[^/]+)/)?' 59 59 => 'HarbormasterBuildActionController', 60 60 ), 61 61 'plan/' => array(
+12 -3
src/applications/harbormaster/controller/HarbormasterBuildActionController.php
··· 5 5 6 6 private $id; 7 7 private $action; 8 + private $via; 8 9 9 10 public function willProcessRequest(array $data) { 10 11 $this->id = $data['id']; 11 12 $this->action = $data['action']; 13 + $this->via = idx($data, 'via'); 12 14 } 13 15 14 16 public function processRequest() { ··· 38 40 return new Aphront400Response(); 39 41 } 40 42 41 - $build_uri = $this->getApplicationURI('/build/'.$build->getID().'/'); 43 + switch ($this->via) { 44 + case 'buildable': 45 + $return_uri = $build->getBuildable()->getMonogram(); 46 + break; 47 + default: 48 + $return_uri = $this->getApplicationURI('/build/'.$build->getID().'/'); 49 + break; 50 + } 42 51 43 52 if ($request->isDialogFormPost() && $can_issue) { 44 53 ··· 58 67 'buildID' => $build->getID() 59 68 )); 60 69 61 - return id(new AphrontRedirectResponse())->setURI($build_uri); 70 + return id(new AphrontRedirectResponse())->setURI($return_uri); 62 71 } 63 72 64 73 switch ($command) { ··· 134 143 ->setUser($viewer) 135 144 ->setTitle($title) 136 145 ->appendChild($body) 137 - ->addCancelButton($build_uri); 146 + ->addCancelButton($return_uri); 138 147 139 148 if ($can_issue) { 140 149 $dialog->addSubmitButton($submit);
+11
src/applications/harbormaster/controller/HarbormasterBuildViewController.php
··· 30 30 ->setUser($viewer) 31 31 ->setPolicyObject($build); 32 32 33 + if ($build->isRestarting()) { 34 + $header->setStatus('warning', 'red', pht('Restarting')); 35 + } else if ($build->isStopping()) { 36 + $header->setStatus('warning', 'red', pht('Stopping')); 37 + } else if ($build->isResuming()) { 38 + $header->setStatus('warning', 'red', pht('Resuming')); 39 + } 40 + 33 41 $box = id(new PHUIObjectBoxView()) 34 42 ->setHeader($header); 35 43 ··· 37 45 $this->buildPropertyLists($box, $build, $actions); 38 46 39 47 $crumbs = $this->buildApplicationCrumbs(); 48 + $crumbs->addTextCrumb( 49 + $build->getBuildable()->getMonogram(), 50 + '/'.$build->getBuildable()->getMonogram()); 40 51 $crumbs->addTextCrumb($title); 41 52 42 53 $build_targets = id(new HarbormasterBuildTargetQuery())
+73 -37
src/applications/harbormaster/controller/HarbormasterBuildableViewController.php
··· 38 38 ->setObjectName(pht('Build %d', $build->getID())) 39 39 ->setHeader($build->getName()) 40 40 ->setHref($view_uri); 41 - if ($build->isStopping()) { 42 - $item->setBarColor('black'); 43 - $item->addAttribute(pht('Stopping')); 41 + 42 + switch ($build->getBuildStatus()) { 43 + case HarbormasterBuild::STATUS_INACTIVE: 44 + $item->setBarColor('grey'); 45 + $item->addAttribute(pht('Inactive')); 46 + break; 47 + case HarbormasterBuild::STATUS_PENDING: 48 + $item->setBarColor('blue'); 49 + $item->addAttribute(pht('Pending')); 50 + break; 51 + case HarbormasterBuild::STATUS_WAITING: 52 + $item->setBarColor('violet'); 53 + $item->addAttribute(pht('Waiting')); 54 + break; 55 + case HarbormasterBuild::STATUS_BUILDING: 56 + $item->setBarColor('yellow'); 57 + $item->addAttribute(pht('Building')); 58 + break; 59 + case HarbormasterBuild::STATUS_PASSED: 60 + $item->setBarColor('green'); 61 + $item->addAttribute(pht('Passed')); 62 + break; 63 + case HarbormasterBuild::STATUS_FAILED: 64 + $item->setBarColor('red'); 65 + $item->addAttribute(pht('Failed')); 66 + break; 67 + case HarbormasterBuild::STATUS_ERROR: 68 + $item->setBarColor('red'); 69 + $item->addAttribute(pht('Unexpected Error')); 70 + break; 71 + case HarbormasterBuild::STATUS_STOPPED: 72 + $item->setBarColor('black'); 73 + $item->addAttribute(pht('Stopped')); 74 + break; 75 + } 76 + 77 + if ($build->isRestarting()) { 78 + $item->addIcon('backward', pht('Restarting')); 79 + } else if ($build->isStopping()) { 80 + $item->addIcon('stop', pht('Stopping')); 81 + } else if ($build->isResuming()) { 82 + $item->addIcon('play', pht('Resuming')); 83 + } 84 + 85 + $build_id = $build->getID(); 86 + 87 + $restart_uri = "build/restart/{$build_id}/buildable/"; 88 + $resume_uri = "build/resume/{$build_id}/buildable/"; 89 + $stop_uri = "build/stop/{$build_id}/buildable/"; 90 + 91 + $item->addAction( 92 + id(new PHUIListItemView()) 93 + ->setIcon('backward') 94 + ->setName(pht('Restart')) 95 + ->setHref($this->getApplicationURI($restart_uri)) 96 + ->setWorkflow(true) 97 + ->setDisabled(!$build->canRestartBuild())); 98 + 99 + if ($build->canResumeBuild()) { 100 + $item->addAction( 101 + id(new PHUIListItemView()) 102 + ->setIcon('play') 103 + ->setName(pht('Resume')) 104 + ->setHref($this->getApplicationURI($resume_uri)) 105 + ->setWorkflow(true)); 44 106 } else { 45 - switch ($build->getBuildStatus()) { 46 - case HarbormasterBuild::STATUS_INACTIVE: 47 - $item->setBarColor('grey'); 48 - $item->addAttribute(pht('Inactive')); 49 - break; 50 - case HarbormasterBuild::STATUS_PENDING: 51 - $item->setBarColor('blue'); 52 - $item->addAttribute(pht('Pending')); 53 - break; 54 - case HarbormasterBuild::STATUS_WAITING: 55 - $item->setBarColor('violet'); 56 - $item->addAttribute(pht('Waiting')); 57 - break; 58 - case HarbormasterBuild::STATUS_BUILDING: 59 - $item->setBarColor('yellow'); 60 - $item->addAttribute(pht('Building')); 61 - break; 62 - case HarbormasterBuild::STATUS_PASSED: 63 - $item->setBarColor('green'); 64 - $item->addAttribute(pht('Passed')); 65 - break; 66 - case HarbormasterBuild::STATUS_FAILED: 67 - $item->setBarColor('red'); 68 - $item->addAttribute(pht('Failed')); 69 - break; 70 - case HarbormasterBuild::STATUS_ERROR: 71 - $item->setBarColor('red'); 72 - $item->addAttribute(pht('Unexpected Error')); 73 - break; 74 - case HarbormasterBuild::STATUS_STOPPED: 75 - $item->setBarColor('black'); 76 - $item->addAttribute(pht('Stopped')); 77 - break; 78 - } 107 + $item->addAction( 108 + id(new PHUIListItemView()) 109 + ->setIcon('stop') 110 + ->setName(pht('Stop')) 111 + ->setHref($this->getApplicationURI($stop_uri)) 112 + ->setWorkflow(true) 113 + ->setDisabled(!$build->canStopBuild())); 79 114 } 115 + 80 116 $build_list->addItem($item); 81 117 } 82 118
+4
src/applications/harbormaster/storage/HarbormasterBuildable.php
··· 26 26 ->setBuildableStatus(self::STATUS_WHATEVER); 27 27 } 28 28 29 + public function getMonogram() { 30 + return 'B'.$this->getID(); 31 + } 32 + 29 33 /** 30 34 * Returns an existing buildable for the object's PHID or creates a 31 35 * new buildable implicitly if needed.