mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-11 17:32:41 +01:00
38626dce64
Summary: This removes all calls to addSpacer and the method. We were applying it inconsistently and it was causing spacing issues with redesigning the sidenav. My feeling is we can recreate the space in CSS if the design dictates, which would apply it consistently. Test Plan: Go to Applications, click on every application. Reviewers: epriestley, btrahan Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D4420
163 lines
4.2 KiB
PHP
163 lines
4.2 KiB
PHP
<?php
|
|
|
|
abstract class DrydockController extends PhabricatorController {
|
|
|
|
final protected function buildSideNav($selected) {
|
|
$nav = new AphrontSideNavFilterView();
|
|
$nav->setBaseURI(new PhutilURI('/drydock/'));
|
|
$nav->addFilter('resource', 'Resources');
|
|
$nav->addFilter('lease', 'Leases');
|
|
$nav->addFilter('log', 'Logs');
|
|
|
|
$nav->selectFilter($selected, 'resource');
|
|
|
|
return $nav;
|
|
}
|
|
|
|
public function buildApplicationMenu() {
|
|
return $this->buildSideNav(null)->getMenu();
|
|
}
|
|
|
|
protected function buildLogTableView(array $logs) {
|
|
assert_instances_of($logs, 'DrydockLog');
|
|
|
|
$user = $this->getRequest()->getUser();
|
|
|
|
$rows = array();
|
|
foreach ($logs as $log) {
|
|
$resource_uri = '/resource/'.$log->getResourceID().'/';
|
|
$resource_uri = $this->getApplicationURI($resource_uri);
|
|
|
|
$lease_uri = '/lease/'.$log->getLeaseID().'/';
|
|
$lease_uri = $this->getApplicationURI($lease_uri);
|
|
|
|
$rows[] = array(
|
|
phutil_render_tag(
|
|
'a',
|
|
array(
|
|
'href' => $resource_uri,
|
|
),
|
|
phutil_escape_html($log->getResourceID())),
|
|
phutil_render_tag(
|
|
'a',
|
|
array(
|
|
'href' => $lease_uri,
|
|
),
|
|
phutil_escape_html($log->getLeaseID())),
|
|
phutil_escape_html($log->getMessage()),
|
|
phabricator_date($log->getEpoch(), $user),
|
|
);
|
|
}
|
|
|
|
$table = new AphrontTableView($rows);
|
|
$table->setDeviceReadyTable(true);
|
|
$table->setHeaders(
|
|
array(
|
|
'Resource',
|
|
'Lease',
|
|
'Message',
|
|
'Date',
|
|
));
|
|
$table->setShortHeaders(
|
|
array(
|
|
'R',
|
|
'L',
|
|
'Message',
|
|
'',
|
|
));
|
|
$table->setColumnClasses(
|
|
array(
|
|
'',
|
|
'',
|
|
'wide',
|
|
'',
|
|
));
|
|
|
|
return $table;
|
|
}
|
|
|
|
protected function buildLeaseListView(array $leases) {
|
|
assert_instances_of($leases, 'DrydockLease');
|
|
|
|
$user = $this->getRequest()->getUser();
|
|
$view = new PhabricatorObjectItemListView();
|
|
|
|
foreach ($leases as $lease) {
|
|
$item = id(new PhabricatorObjectItemView())
|
|
->setHeader($lease->getLeaseName())
|
|
->setHref($this->getApplicationURI('/lease/'.$lease->getID().'/'));
|
|
|
|
if ($lease->hasAttachedResource()) {
|
|
$resource = $lease->getResource();
|
|
|
|
$resource_href = '/resource/'.$resource->getID().'/';
|
|
$resource_href = $this->getApplicationURI($resource_href);
|
|
|
|
$resource_name = $resource->getName();
|
|
|
|
$item->addAttribute(
|
|
phutil_render_tag(
|
|
'a',
|
|
array(
|
|
'href' => $resource_href,
|
|
),
|
|
phutil_escape_html($resource_name)));
|
|
}
|
|
|
|
$status = DrydockLeaseStatus::getNameForStatus($lease->getStatus());
|
|
$item->addAttribute(phutil_escape_html($status));
|
|
|
|
$date_created = phabricator_date($lease->getDateCreated(), $user);
|
|
$item->addAttribute(pht('Created on %s', $date_created));
|
|
|
|
if ($lease->isActive()) {
|
|
$item->setBarColor('green');
|
|
} else {
|
|
$item->setBarColor('red');
|
|
}
|
|
|
|
$view->addItem($item);
|
|
}
|
|
|
|
return $view;
|
|
}
|
|
|
|
protected function buildResourceListView(array $resources) {
|
|
assert_instances_of($resources, 'DrydockResource');
|
|
|
|
$user = $this->getRequest()->getUser();
|
|
$view = new PhabricatorObjectItemListView();
|
|
|
|
foreach ($resources as $resource) {
|
|
$name = pht('Resource %d', $resource->getID()).': '.$resource->getName();
|
|
|
|
$item = id(new PhabricatorObjectItemView())
|
|
->setHref($this->getApplicationURI('/resource/'.$resource->getID().'/'))
|
|
->setHeader($name);
|
|
|
|
$status = DrydockResourceStatus::getNameForStatus($resource->getStatus());
|
|
$item->addAttribute($status);
|
|
|
|
switch ($resource->getStatus()) {
|
|
case DrydockResourceStatus::STATUS_PENDING:
|
|
$item->setBarColor('yellow');
|
|
break;
|
|
case DrydockResourceStatus::STATUS_OPEN:
|
|
$item->setBarColor('green');
|
|
break;
|
|
case DrydockResourceStatus::STATUS_DESTROYED:
|
|
$item->setBarColor('black');
|
|
break;
|
|
default:
|
|
$item->setBarColor('red');
|
|
break;
|
|
}
|
|
|
|
$view->addItem($item);
|
|
}
|
|
|
|
return $view;
|
|
}
|
|
|
|
|
|
}
|