Differential D21685 Diff 51700 src/applications/harbormaster/controller/HarbormasterBuildViewController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/harbormaster/controller/HarbormasterBuildViewController.php
Show All 26 Lines | public function handleRequest(AphrontRequest $request) { | ||||
$warnings = array(); | $warnings = array(); | ||||
$page_header = id(new PHUIHeaderView()) | $page_header = id(new PHUIHeaderView()) | ||||
->setHeader($title) | ->setHeader($title) | ||||
->setUser($viewer) | ->setUser($viewer) | ||||
->setPolicyObject($build) | ->setPolicyObject($build) | ||||
->setHeaderIcon('fa-cubes'); | ->setHeaderIcon('fa-cubes'); | ||||
$is_restarting = $build->isRestarting(); | $status = $build->getBuildPendingStatusObject(); | ||||
if ($is_restarting) { | $status_icon = $status->getIconIcon(); | ||||
$page_header->setStatus( | $status_color = $status->getIconColor(); | ||||
'fa-exclamation-triangle', 'red', pht('Restarting')); | $status_name = $status->getName(); | ||||
} else if ($build->isPausing()) { | |||||
$page_header->setStatus( | $page_header->setStatus($status_icon, $status_color, $status_name); | ||||
'fa-exclamation-triangle', 'red', pht('Pausing')); | |||||
} else if ($build->isResuming()) { | |||||
$page_header->setStatus( | |||||
'fa-exclamation-triangle', 'red', pht('Resuming')); | |||||
} else if ($build->isAborting()) { | |||||
$page_header->setStatus( | |||||
'fa-exclamation-triangle', 'red', pht('Aborting')); | |||||
} | |||||
$max_generation = (int)$build->getBuildGeneration(); | $max_generation = (int)$build->getBuildGeneration(); | ||||
if ($max_generation === 0) { | if ($max_generation === 0) { | ||||
$min_generation = 0; | $min_generation = 0; | ||||
} else { | } else { | ||||
$min_generation = 1; | $min_generation = 1; | ||||
} | } | ||||
if ($is_restarting) { | if ($build->isRestarting()) { | ||||
$max_generation = $max_generation + 1; | $max_generation = $max_generation + 1; | ||||
} | } | ||||
$generation = $request->getURIData('generation'); | $generation = $request->getURIData('generation'); | ||||
if ($generation === null) { | if ($generation === null) { | ||||
$generation = $max_generation; | $generation = $max_generation; | ||||
} else { | } else { | ||||
$generation = (int)$generation; | $generation = (int)$generation; | ||||
▲ Show 20 Lines • Show All 552 Lines • ▼ Show 20 Lines | private function buildPropertyList(HarbormasterBuild $build) { | ||||
$properties->addProperty( | $properties->addProperty( | ||||
pht('Buildable'), | pht('Buildable'), | ||||
$handles[$build->getBuildablePHID()]->renderLink()); | $handles[$build->getBuildablePHID()]->renderLink()); | ||||
$properties->addProperty( | $properties->addProperty( | ||||
pht('Build Plan'), | pht('Build Plan'), | ||||
$handles[$build->getBuildPlanPHID()]->renderLink()); | $handles[$build->getBuildPlanPHID()]->renderLink()); | ||||
$properties->addProperty( | |||||
pht('Status'), | |||||
$this->getStatus($build)); | |||||
return id(new PHUIObjectBoxView()) | return id(new PHUIObjectBoxView()) | ||||
->setHeaderText(pht('Properties')) | ->setHeaderText(pht('Properties')) | ||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | ||||
->appendChild($properties); | ->appendChild($properties); | ||||
} | } | ||||
private function buildHistoryTable( | private function buildHistoryTable( | ||||
Show All 37 Lines | $table = id(new AphrontTableView($rows)) | ||||
->setRowClasses($rowc); | ->setRowClasses($rowc); | ||||
return id(new PHUIObjectBoxView()) | return id(new PHUIObjectBoxView()) | ||||
->setHeaderText(pht('History')) | ->setHeaderText(pht('History')) | ||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | ||||
->setTable($table); | ->setTable($table); | ||||
} | } | ||||
private function getStatus(HarbormasterBuild $build) { | |||||
$status_view = new PHUIStatusListView(); | |||||
$item = new PHUIStatusItemView(); | |||||
if ($build->isPausing()) { | |||||
$status_name = pht('Pausing'); | |||||
$icon = PHUIStatusItemView::ICON_RIGHT; | |||||
$color = 'dark'; | |||||
} else { | |||||
$status = $build->getBuildStatus(); | |||||
$status_name = | |||||
HarbormasterBuildStatus::getBuildStatusName($status); | |||||
$icon = HarbormasterBuildStatus::getBuildStatusIcon($status); | |||||
$color = HarbormasterBuildStatus::getBuildStatusColor($status); | |||||
} | |||||
$item->setTarget($status_name); | |||||
$item->setIcon($icon, $color); | |||||
$status_view->addItem($item); | |||||
return $status_view; | |||||
} | |||||
private function buildMessages(array $messages) { | private function buildMessages(array $messages) { | ||||
$viewer = $this->getRequest()->getUser(); | $viewer = $this->getRequest()->getUser(); | ||||
if ($messages) { | if ($messages) { | ||||
$handles = id(new PhabricatorHandleQuery()) | $handles = id(new PhabricatorHandleQuery()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->withPHIDs(mpull($messages, 'getAuthorPHID')) | ->withPHIDs(mpull($messages, 'getAuthorPHID')) | ||||
->execute(); | ->execute(); | ||||
▲ Show 20 Lines • Show All 64 Lines • Show Last 20 Lines |