mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
Move Drydock object list rendering to SearchEngine
Summary: Ref T4986. Allows the Drydock search engines to render as panels. Test Plan: Viewed affected interfaces in Drydock. Created panels from each engine. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4986 Differential Revision: https://secure.phabricator.com/D9103
This commit is contained in:
parent
4a7499f230
commit
38f5894b58
14 changed files with 247 additions and 190 deletions
|
@ -661,6 +661,7 @@ phutil_register_library_map(array(
|
||||||
'DrydockLease' => 'applications/drydock/storage/DrydockLease.php',
|
'DrydockLease' => 'applications/drydock/storage/DrydockLease.php',
|
||||||
'DrydockLeaseController' => 'applications/drydock/controller/DrydockLeaseController.php',
|
'DrydockLeaseController' => 'applications/drydock/controller/DrydockLeaseController.php',
|
||||||
'DrydockLeaseListController' => 'applications/drydock/controller/DrydockLeaseListController.php',
|
'DrydockLeaseListController' => 'applications/drydock/controller/DrydockLeaseListController.php',
|
||||||
|
'DrydockLeaseListView' => 'applications/drydock/view/DrydockLeaseListView.php',
|
||||||
'DrydockLeaseQuery' => 'applications/drydock/query/DrydockLeaseQuery.php',
|
'DrydockLeaseQuery' => 'applications/drydock/query/DrydockLeaseQuery.php',
|
||||||
'DrydockLeaseReleaseController' => 'applications/drydock/controller/DrydockLeaseReleaseController.php',
|
'DrydockLeaseReleaseController' => 'applications/drydock/controller/DrydockLeaseReleaseController.php',
|
||||||
'DrydockLeaseSearchEngine' => 'applications/drydock/query/DrydockLeaseSearchEngine.php',
|
'DrydockLeaseSearchEngine' => 'applications/drydock/query/DrydockLeaseSearchEngine.php',
|
||||||
|
@ -671,6 +672,7 @@ phutil_register_library_map(array(
|
||||||
'DrydockLog' => 'applications/drydock/storage/DrydockLog.php',
|
'DrydockLog' => 'applications/drydock/storage/DrydockLog.php',
|
||||||
'DrydockLogController' => 'applications/drydock/controller/DrydockLogController.php',
|
'DrydockLogController' => 'applications/drydock/controller/DrydockLogController.php',
|
||||||
'DrydockLogListController' => 'applications/drydock/controller/DrydockLogListController.php',
|
'DrydockLogListController' => 'applications/drydock/controller/DrydockLogListController.php',
|
||||||
|
'DrydockLogListView' => 'applications/drydock/view/DrydockLogListView.php',
|
||||||
'DrydockLogQuery' => 'applications/drydock/query/DrydockLogQuery.php',
|
'DrydockLogQuery' => 'applications/drydock/query/DrydockLogQuery.php',
|
||||||
'DrydockLogSearchEngine' => 'applications/drydock/query/DrydockLogSearchEngine.php',
|
'DrydockLogSearchEngine' => 'applications/drydock/query/DrydockLogSearchEngine.php',
|
||||||
'DrydockManagementCloseWorkflow' => 'applications/drydock/management/DrydockManagementCloseWorkflow.php',
|
'DrydockManagementCloseWorkflow' => 'applications/drydock/management/DrydockManagementCloseWorkflow.php',
|
||||||
|
@ -687,6 +689,7 @@ phutil_register_library_map(array(
|
||||||
'DrydockResourceCloseController' => 'applications/drydock/controller/DrydockResourceCloseController.php',
|
'DrydockResourceCloseController' => 'applications/drydock/controller/DrydockResourceCloseController.php',
|
||||||
'DrydockResourceController' => 'applications/drydock/controller/DrydockResourceController.php',
|
'DrydockResourceController' => 'applications/drydock/controller/DrydockResourceController.php',
|
||||||
'DrydockResourceListController' => 'applications/drydock/controller/DrydockResourceListController.php',
|
'DrydockResourceListController' => 'applications/drydock/controller/DrydockResourceListController.php',
|
||||||
|
'DrydockResourceListView' => 'applications/drydock/view/DrydockResourceListView.php',
|
||||||
'DrydockResourceQuery' => 'applications/drydock/query/DrydockResourceQuery.php',
|
'DrydockResourceQuery' => 'applications/drydock/query/DrydockResourceQuery.php',
|
||||||
'DrydockResourceSearchEngine' => 'applications/drydock/query/DrydockResourceSearchEngine.php',
|
'DrydockResourceSearchEngine' => 'applications/drydock/query/DrydockResourceSearchEngine.php',
|
||||||
'DrydockResourceStatus' => 'applications/drydock/constants/DrydockResourceStatus.php',
|
'DrydockResourceStatus' => 'applications/drydock/constants/DrydockResourceStatus.php',
|
||||||
|
@ -3305,11 +3308,8 @@ phutil_register_library_map(array(
|
||||||
1 => 'PhabricatorPolicyInterface',
|
1 => 'PhabricatorPolicyInterface',
|
||||||
),
|
),
|
||||||
'DrydockLeaseController' => 'DrydockController',
|
'DrydockLeaseController' => 'DrydockController',
|
||||||
'DrydockLeaseListController' =>
|
'DrydockLeaseListController' => 'DrydockLeaseController',
|
||||||
array(
|
'DrydockLeaseListView' => 'AphrontView',
|
||||||
0 => 'DrydockLeaseController',
|
|
||||||
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
|
|
||||||
),
|
|
||||||
'DrydockLeaseQuery' => 'DrydockQuery',
|
'DrydockLeaseQuery' => 'DrydockQuery',
|
||||||
'DrydockLeaseReleaseController' => 'DrydockLeaseController',
|
'DrydockLeaseReleaseController' => 'DrydockLeaseController',
|
||||||
'DrydockLeaseSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
'DrydockLeaseSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||||
|
@ -3323,11 +3323,8 @@ phutil_register_library_map(array(
|
||||||
1 => 'PhabricatorPolicyInterface',
|
1 => 'PhabricatorPolicyInterface',
|
||||||
),
|
),
|
||||||
'DrydockLogController' => 'DrydockController',
|
'DrydockLogController' => 'DrydockController',
|
||||||
'DrydockLogListController' =>
|
'DrydockLogListController' => 'DrydockLogController',
|
||||||
array(
|
'DrydockLogListView' => 'AphrontView',
|
||||||
0 => 'DrydockLogController',
|
|
||||||
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
|
|
||||||
),
|
|
||||||
'DrydockLogQuery' => 'DrydockQuery',
|
'DrydockLogQuery' => 'DrydockQuery',
|
||||||
'DrydockLogSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
'DrydockLogSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||||
'DrydockManagementCloseWorkflow' => 'DrydockManagementWorkflow',
|
'DrydockManagementCloseWorkflow' => 'DrydockManagementWorkflow',
|
||||||
|
@ -3347,11 +3344,8 @@ phutil_register_library_map(array(
|
||||||
),
|
),
|
||||||
'DrydockResourceCloseController' => 'DrydockResourceController',
|
'DrydockResourceCloseController' => 'DrydockResourceController',
|
||||||
'DrydockResourceController' => 'DrydockController',
|
'DrydockResourceController' => 'DrydockController',
|
||||||
'DrydockResourceListController' =>
|
'DrydockResourceListController' => 'DrydockResourceController',
|
||||||
array(
|
'DrydockResourceListView' => 'AphrontView',
|
||||||
0 => 'DrydockResourceController',
|
|
||||||
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
|
|
||||||
),
|
|
||||||
'DrydockResourceQuery' => 'DrydockQuery',
|
'DrydockResourceQuery' => 'DrydockQuery',
|
||||||
'DrydockResourceSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
'DrydockResourceSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||||
'DrydockResourceStatus' => 'DrydockConstants',
|
'DrydockResourceStatus' => 'DrydockConstants',
|
||||||
|
|
|
@ -38,7 +38,10 @@ final class DrydockBlueprintViewController extends DrydockBlueprintController {
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
$resource_list = $this->buildResourceListView($resources);
|
$resource_list = id(new DrydockResourceListView())
|
||||||
|
->setUser($viewer)
|
||||||
|
->setResources($resources)
|
||||||
|
->render();
|
||||||
$resource_list->setNoDataString(pht('This blueprint has no resources.'));
|
$resource_list->setNoDataString(pht('This blueprint has no resources.'));
|
||||||
|
|
||||||
$pager = new AphrontPagerView();
|
$pager = new AphrontPagerView();
|
||||||
|
|
|
@ -8,145 +8,4 @@ abstract class DrydockController extends PhabricatorController {
|
||||||
return $this->buildSideNavView()->getMenu();
|
return $this->buildSideNavView()->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_tag(
|
|
||||||
'a',
|
|
||||||
array(
|
|
||||||
'href' => $resource_uri,
|
|
||||||
),
|
|
||||||
$log->getResourceID()),
|
|
||||||
phutil_tag(
|
|
||||||
'a',
|
|
||||||
array(
|
|
||||||
'href' => $lease_uri,
|
|
||||||
),
|
|
||||||
$log->getLeaseID()),
|
|
||||||
$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');
|
|
||||||
|
|
||||||
$viewer = $this->getRequest()->getUser();
|
|
||||||
$view = new PHUIObjectItemListView();
|
|
||||||
|
|
||||||
foreach ($leases as $lease) {
|
|
||||||
$item = id(new PHUIObjectItemView())
|
|
||||||
->setUser($viewer)
|
|
||||||
->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_tag(
|
|
||||||
'a',
|
|
||||||
array(
|
|
||||||
'href' => $resource_href,
|
|
||||||
),
|
|
||||||
$resource_name));
|
|
||||||
}
|
|
||||||
|
|
||||||
$status = DrydockLeaseStatus::getNameForStatus($lease->getStatus());
|
|
||||||
$item->addAttribute($status);
|
|
||||||
$item->setEpoch($lease->getDateCreated());
|
|
||||||
|
|
||||||
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 PHUIObjectItemListView();
|
|
||||||
|
|
||||||
foreach ($resources as $resource) {
|
|
||||||
$name = pht('Resource %d', $resource->getID()).': '.$resource->getName();
|
|
||||||
|
|
||||||
$item = id(new PHUIObjectItemView())
|
|
||||||
->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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class DrydockLeaseListController extends DrydockLeaseController
|
final class DrydockLeaseListController extends DrydockLeaseController {
|
||||||
implements PhabricatorApplicationSearchResultsControllerInterface {
|
|
||||||
|
|
||||||
private $queryKey;
|
private $queryKey;
|
||||||
|
|
||||||
|
@ -23,12 +22,4 @@ final class DrydockLeaseListController extends DrydockLeaseController
|
||||||
return $this->delegateToController($controller);
|
return $this->delegateToController($controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function renderResultsList(
|
|
||||||
array $leases,
|
|
||||||
PhabricatorSavedQuery $query) {
|
|
||||||
assert_instances_of($leases, 'DrydockLease');
|
|
||||||
|
|
||||||
return $this->buildLeaseListView($leases);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,10 @@ final class DrydockLeaseViewController extends DrydockLeaseController {
|
||||||
->withLeaseIDs(array($lease->getID()))
|
->withLeaseIDs(array($lease->getID()))
|
||||||
->executeWithOffsetPager($pager);
|
->executeWithOffsetPager($pager);
|
||||||
|
|
||||||
$log_table = $this->buildLogTableView($logs);
|
$log_table = id(new DrydockLogListView())
|
||||||
|
->setUser($viewer)
|
||||||
|
->setLogs($logs)
|
||||||
|
->render();
|
||||||
$log_table->appendChild($pager);
|
$log_table->appendChild($pager);
|
||||||
|
|
||||||
$crumbs = $this->buildApplicationCrumbs();
|
$crumbs = $this->buildApplicationCrumbs();
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class DrydockLogListController extends DrydockLogController
|
final class DrydockLogListController extends DrydockLogController {
|
||||||
implements PhabricatorApplicationSearchResultsControllerInterface {
|
|
||||||
|
|
||||||
private $queryKey;
|
private $queryKey;
|
||||||
|
|
||||||
|
@ -23,12 +22,4 @@ final class DrydockLogListController extends DrydockLogController
|
||||||
return $this->delegateToController($controller);
|
return $this->delegateToController($controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function renderResultsList(
|
|
||||||
array $logs,
|
|
||||||
PhabricatorSavedQuery $query) {
|
|
||||||
assert_instances_of($logs, 'DrydockLog');
|
|
||||||
|
|
||||||
return $this->buildLogTableView($logs);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class DrydockResourceListController extends DrydockResourceController
|
final class DrydockResourceListController extends DrydockResourceController {
|
||||||
implements PhabricatorApplicationSearchResultsControllerInterface {
|
|
||||||
|
|
||||||
private $queryKey;
|
private $queryKey;
|
||||||
|
|
||||||
|
@ -23,12 +22,4 @@ final class DrydockResourceListController extends DrydockResourceController
|
||||||
return $this->delegateToController($controller);
|
return $this->delegateToController($controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function renderResultsList(
|
|
||||||
array $resources,
|
|
||||||
PhabricatorSavedQuery $query) {
|
|
||||||
assert_instances_of($resources, 'DrydockResource');
|
|
||||||
|
|
||||||
return $this->buildResourceListView($resources);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,10 @@ final class DrydockResourceViewController extends DrydockResourceController {
|
||||||
->withResourceIDs(array($resource->getID()))
|
->withResourceIDs(array($resource->getID()))
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
$lease_list = $this->buildLeaseListView($leases);
|
$lease_list = id(new DrydockLeaseListView())
|
||||||
|
->setUser($viewer)
|
||||||
|
->setLeases($leases)
|
||||||
|
->render();
|
||||||
$lease_list->setNoDataString(pht('This resource has no leases.'));
|
$lease_list->setNoDataString(pht('This resource has no leases.'));
|
||||||
|
|
||||||
$pager = new AphrontPagerView();
|
$pager = new AphrontPagerView();
|
||||||
|
@ -48,7 +51,10 @@ final class DrydockResourceViewController extends DrydockResourceController {
|
||||||
->withResourceIDs(array($resource->getID()))
|
->withResourceIDs(array($resource->getID()))
|
||||||
->executeWithOffsetPager($pager);
|
->executeWithOffsetPager($pager);
|
||||||
|
|
||||||
$log_table = $this->buildLogTableView($logs);
|
$log_table = id(new DrydockLogListView())
|
||||||
|
->setUser($viewer)
|
||||||
|
->setLogs($logs)
|
||||||
|
->render();
|
||||||
$log_table->appendChild($pager);
|
$log_table->appendChild($pager);
|
||||||
|
|
||||||
$crumbs = $this->buildApplicationCrumbs();
|
$crumbs = $this->buildApplicationCrumbs();
|
||||||
|
|
|
@ -3,6 +3,10 @@
|
||||||
final class DrydockLeaseSearchEngine
|
final class DrydockLeaseSearchEngine
|
||||||
extends PhabricatorApplicationSearchEngine {
|
extends PhabricatorApplicationSearchEngine {
|
||||||
|
|
||||||
|
public function getApplicationClassName() {
|
||||||
|
return 'PhabricatorApplicationDrydock';
|
||||||
|
}
|
||||||
|
|
||||||
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
||||||
$saved = new PhabricatorSavedQuery();
|
$saved = new PhabricatorSavedQuery();
|
||||||
|
|
||||||
|
@ -78,4 +82,15 @@ final class DrydockLeaseSearchEngine
|
||||||
return parent::buildSavedQueryFromBuiltin($query_key);
|
return parent::buildSavedQueryFromBuiltin($query_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function renderResultList(
|
||||||
|
array $leases,
|
||||||
|
PhabricatorSavedQuery $saved,
|
||||||
|
array $handles) {
|
||||||
|
|
||||||
|
return id(new DrydockLeaseListView())
|
||||||
|
->setUser($this->requireViewer())
|
||||||
|
->setLeases($leases)
|
||||||
|
->render();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,10 @@
|
||||||
final class DrydockLogSearchEngine
|
final class DrydockLogSearchEngine
|
||||||
extends PhabricatorApplicationSearchEngine {
|
extends PhabricatorApplicationSearchEngine {
|
||||||
|
|
||||||
|
public function getApplicationClassName() {
|
||||||
|
return 'PhabricatorApplicationDrydock';
|
||||||
|
}
|
||||||
|
|
||||||
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
||||||
$saved = new PhabricatorSavedQuery();
|
$saved = new PhabricatorSavedQuery();
|
||||||
|
|
||||||
|
@ -45,4 +49,15 @@ final class DrydockLogSearchEngine
|
||||||
return parent::buildSavedQueryFromBuiltin($query_key);
|
return parent::buildSavedQueryFromBuiltin($query_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function renderResultList(
|
||||||
|
array $logs,
|
||||||
|
PhabricatorSavedQuery $query,
|
||||||
|
array $handles) {
|
||||||
|
|
||||||
|
return id(new DrydockLogListView())
|
||||||
|
->setUser($this->requireViewer())
|
||||||
|
->setLogs($logs)
|
||||||
|
->render();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,10 @@
|
||||||
final class DrydockResourceSearchEngine
|
final class DrydockResourceSearchEngine
|
||||||
extends PhabricatorApplicationSearchEngine {
|
extends PhabricatorApplicationSearchEngine {
|
||||||
|
|
||||||
|
public function getApplicationClassName() {
|
||||||
|
return 'PhabricatorApplicationDrydock';
|
||||||
|
}
|
||||||
|
|
||||||
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
||||||
$saved = new PhabricatorSavedQuery();
|
$saved = new PhabricatorSavedQuery();
|
||||||
|
|
||||||
|
@ -77,4 +81,15 @@ final class DrydockResourceSearchEngine
|
||||||
return parent::buildSavedQueryFromBuiltin($query_key);
|
return parent::buildSavedQueryFromBuiltin($query_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function renderResultList(
|
||||||
|
array $resources,
|
||||||
|
PhabricatorSavedQuery $query,
|
||||||
|
array $handles) {
|
||||||
|
|
||||||
|
return id(new DrydockResourceListView())
|
||||||
|
->setUser($this->requireViewer())
|
||||||
|
->setResources($resources)
|
||||||
|
->render();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
56
src/applications/drydock/view/DrydockLeaseListView.php
Normal file
56
src/applications/drydock/view/DrydockLeaseListView.php
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class DrydockLeaseListView extends AphrontView {
|
||||||
|
|
||||||
|
private $leases;
|
||||||
|
|
||||||
|
public function setLeases(array $leases) {
|
||||||
|
assert_instances_of($leases, 'DrydockLease');
|
||||||
|
$this->leases = $leases;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render() {
|
||||||
|
$leases = $this->leases;
|
||||||
|
$viewer = $this->getUser();
|
||||||
|
|
||||||
|
$view = new PHUIObjectItemListView();
|
||||||
|
|
||||||
|
foreach ($leases as $lease) {
|
||||||
|
$item = id(new PHUIObjectItemView())
|
||||||
|
->setUser($viewer)
|
||||||
|
->setHeader($lease->getLeaseName())
|
||||||
|
->setHref('/drydock/lease/'.$lease->getID().'/');
|
||||||
|
|
||||||
|
if ($lease->hasAttachedResource()) {
|
||||||
|
$resource = $lease->getResource();
|
||||||
|
|
||||||
|
$resource_href = '/drydock/resource/'.$resource->getID().'/';
|
||||||
|
$resource_name = $resource->getName();
|
||||||
|
|
||||||
|
$item->addAttribute(
|
||||||
|
phutil_tag(
|
||||||
|
'a',
|
||||||
|
array(
|
||||||
|
'href' => $resource_href,
|
||||||
|
),
|
||||||
|
$resource_name));
|
||||||
|
}
|
||||||
|
|
||||||
|
$status = DrydockLeaseStatus::getNameForStatus($lease->getStatus());
|
||||||
|
$item->addAttribute($status);
|
||||||
|
$item->setEpoch($lease->getDateCreated());
|
||||||
|
|
||||||
|
if ($lease->isActive()) {
|
||||||
|
$item->setBarColor('green');
|
||||||
|
} else {
|
||||||
|
$item->setBarColor('red');
|
||||||
|
}
|
||||||
|
|
||||||
|
$view->addItem($item);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $view;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
69
src/applications/drydock/view/DrydockLogListView.php
Normal file
69
src/applications/drydock/view/DrydockLogListView.php
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class DrydockLogListView extends AphrontView {
|
||||||
|
|
||||||
|
private $logs;
|
||||||
|
|
||||||
|
public function setLogs(array $logs) {
|
||||||
|
assert_instances_of($logs, 'DrydockLog');
|
||||||
|
$this->logs = $logs;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render() {
|
||||||
|
$logs = $this->logs;
|
||||||
|
$viewer = $this->getUser();
|
||||||
|
|
||||||
|
$view = new PHUIObjectItemListView();
|
||||||
|
|
||||||
|
$rows = array();
|
||||||
|
foreach ($logs as $log) {
|
||||||
|
$resource_uri = '/drydock/resource/'.$log->getResourceID().'/';
|
||||||
|
$lease_uri = '/drydock/lease/'.$log->getLeaseID().'/';
|
||||||
|
|
||||||
|
$rows[] = array(
|
||||||
|
phutil_tag(
|
||||||
|
'a',
|
||||||
|
array(
|
||||||
|
'href' => $resource_uri,
|
||||||
|
),
|
||||||
|
$log->getResourceID()),
|
||||||
|
phutil_tag(
|
||||||
|
'a',
|
||||||
|
array(
|
||||||
|
'href' => $lease_uri,
|
||||||
|
),
|
||||||
|
$log->getLeaseID()),
|
||||||
|
$log->getMessage(),
|
||||||
|
phabricator_date($log->getEpoch(), $viewer),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
49
src/applications/drydock/view/DrydockResourceListView.php
Normal file
49
src/applications/drydock/view/DrydockResourceListView.php
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class DrydockResourceListView extends AphrontView {
|
||||||
|
|
||||||
|
private $resources;
|
||||||
|
|
||||||
|
public function setResources(array $resources) {
|
||||||
|
assert_instances_of($resources, 'DrydockResource');
|
||||||
|
$this->resources = $resources;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render() {
|
||||||
|
$resources = $this->resources;
|
||||||
|
$viewer = $this->getUser();
|
||||||
|
|
||||||
|
$view = new PHUIObjectItemListView();
|
||||||
|
foreach ($resources as $resource) {
|
||||||
|
$name = pht('Resource %d', $resource->getID()).': '.$resource->getName();
|
||||||
|
|
||||||
|
$item = id(new PHUIObjectItemView())
|
||||||
|
->setHref('/drydock/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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue