Differential D7892 Diff 17853 src/applications/harbormaster/controller/HarbormasterBuildViewController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/harbormaster/controller/HarbormasterBuildViewController.php
| Show First 20 Lines • Show All 208 Lines • ▼ Show 20 Lines | private function buildActionList(HarbormasterBuild $build) { | ||||
| $viewer = $request->getUser(); | $viewer = $request->getUser(); | ||||
| $id = $build->getID(); | $id = $build->getID(); | ||||
| $list = id(new PhabricatorActionListView()) | $list = id(new PhabricatorActionListView()) | ||||
| ->setUser($viewer) | ->setUser($viewer) | ||||
| ->setObject($build) | ->setObject($build) | ||||
| ->setObjectURI("/build/{$id}"); | ->setObjectURI("/build/{$id}"); | ||||
| $action = | $can_restart = $build->canRestartBuild(); | ||||
| $can_stop = $build->canStopBuild(); | |||||
| $can_resume = $build->canResumeBuild(); | |||||
| $list->addAction( | |||||
| id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
| ->setName(pht('Cancel Build')) | ->setName(pht('Restart Build')) | ||||
| ->setIcon('delete'); | ->setIcon('refresh') | ||||
| switch ($build->getBuildStatus()) { | ->setHref($this->getApplicationURI('/build/restart/'.$id.'/')) | ||||
| case HarbormasterBuild::STATUS_PENDING: | ->setDisabled(!$can_restart) | ||||
| case HarbormasterBuild::STATUS_WAITING: | ->setWorkflow(true)); | ||||
| case HarbormasterBuild::STATUS_BUILDING: | |||||
| $cancel_uri = $this->getApplicationURI('/build/cancel/'.$id.'/'); | $list->addAction( | ||||
| $action | id(new PhabricatorActionView()) | ||||
| ->setHref($cancel_uri) | ->setName(pht('Stop Build')) | ||||
| ->setWorkflow(true); | ->setIcon('delete') | ||||
| break; | ->setHref($this->getApplicationURI('/build/stop/'.$id.'/')) | ||||
| default: | ->setDisabled(!$can_stop) | ||||
| $action | ->setWorkflow(true)); | ||||
| ->setDisabled(true); | |||||
| break; | $list->addAction( | ||||
| } | id(new PhabricatorActionView()) | ||||
| $list->addAction($action); | ->setName(pht('Resume Build')) | ||||
| ->setIcon('start-sandcastle') | |||||
| ->setHref($this->getApplicationURI('/build/resume/'.$id.'/')) | |||||
| ->setDisabled(!$can_resume) | |||||
| ->setWorkflow(true)); | |||||
| return $list; | return $list; | ||||
| } | } | ||||
| private function buildPropertyLists( | private function buildPropertyLists( | ||||
| PHUIObjectBoxView $box, | PHUIObjectBoxView $box, | ||||
| HarbormasterBuild $build, | HarbormasterBuild $build, | ||||
| PhabricatorActionListView $actions) { | PhabricatorActionListView $actions) { | ||||
| Show All 23 Lines | private function buildPropertyLists( | ||||
| $properties->addProperty( | $properties->addProperty( | ||||
| pht('Build Plan'), | pht('Build Plan'), | ||||
| $handles[$build->getBuildPlanPHID()]->renderLink()); | $handles[$build->getBuildPlanPHID()]->renderLink()); | ||||
| } | } | ||||
| private function getStatus(HarbormasterBuild $build) { | private function getStatus(HarbormasterBuild $build) { | ||||
| if ($build->getCancelRequested()) { | if ($build->isStopping()) { | ||||
| return pht('Cancelling'); | return pht('Stopping'); | ||||
| } | } | ||||
| switch ($build->getBuildStatus()) { | switch ($build->getBuildStatus()) { | ||||
| case HarbormasterBuild::STATUS_INACTIVE: | case HarbormasterBuild::STATUS_INACTIVE: | ||||
| return pht('Inactive'); | return pht('Inactive'); | ||||
| case HarbormasterBuild::STATUS_PENDING: | case HarbormasterBuild::STATUS_PENDING: | ||||
| return pht('Pending'); | return pht('Pending'); | ||||
| case HarbormasterBuild::STATUS_WAITING: | case HarbormasterBuild::STATUS_WAITING: | ||||
| return pht('Waiting'); | return pht('Waiting'); | ||||
| case HarbormasterBuild::STATUS_BUILDING: | case HarbormasterBuild::STATUS_BUILDING: | ||||
| return pht('Building'); | return pht('Building'); | ||||
| case HarbormasterBuild::STATUS_PASSED: | case HarbormasterBuild::STATUS_PASSED: | ||||
| return pht('Passed'); | return pht('Passed'); | ||||
| case HarbormasterBuild::STATUS_FAILED: | case HarbormasterBuild::STATUS_FAILED: | ||||
| return pht('Failed'); | return pht('Failed'); | ||||
| case HarbormasterBuild::STATUS_ERROR: | case HarbormasterBuild::STATUS_ERROR: | ||||
| return pht('Unexpected Error'); | return pht('Unexpected Error'); | ||||
| case HarbormasterBuild::STATUS_CANCELLED: | case HarbormasterBuild::STATUS_STOPPED: | ||||
| return pht('Cancelled'); | return pht('Stopped'); | ||||
| default: | default: | ||||
| return pht('Unknown'); | return pht('Unknown'); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||