mirror of
https://we.phorge.it/source/phorge.git
synced 2025-04-11 03:48:34 +02:00
Show recent active resources on Drydock blueprint detail, with link to all
Summary: Ref T9252. Currently, Drydock blueprint pages: - show all resources, even if there are a million; - show resources in all states, although destroyed resources are usually uninteresting; - have some junky `$pager` code. Instead, show the few most recent active resources and link to a filtered resource view in ApplicationSearch. Test Plan: - Viewed some blueprints. - Clicked "View All Resources". - Saw all resources. - Used query / crumbs / etc. Reviewers: chad Reviewed By: chad Maniphest Tasks: T9252 Differential Revision: https://secure.phabricator.com/D14157
This commit is contained in:
parent
b441e8b81e
commit
3b2f4c258f
5 changed files with 118 additions and 29 deletions
|
@ -53,6 +53,8 @@ final class PhabricatorDrydockApplication extends PhabricatorApplication {
|
||||||
'' => 'DrydockBlueprintViewController',
|
'' => 'DrydockBlueprintViewController',
|
||||||
'(?P<action>disable|enable)/' =>
|
'(?P<action>disable|enable)/' =>
|
||||||
'DrydockBlueprintDisableController',
|
'DrydockBlueprintDisableController',
|
||||||
|
'resources/(?:query/(?P<queryKey>[^/]+)/)?' =>
|
||||||
|
'DrydockResourceListController',
|
||||||
),
|
),
|
||||||
'create/' => 'DrydockBlueprintCreateController',
|
'create/' => 'DrydockBlueprintCreateController',
|
||||||
'edit/(?:(?P<id>[1-9]\d*)/)?' => 'DrydockBlueprintEditController',
|
'edit/(?:(?P<id>[1-9]\d*)/)?' => 'DrydockBlueprintEditController',
|
||||||
|
|
|
@ -30,24 +30,6 @@ final class DrydockBlueprintViewController extends DrydockBlueprintController {
|
||||||
$actions = $this->buildActionListView($blueprint);
|
$actions = $this->buildActionListView($blueprint);
|
||||||
$properties = $this->buildPropertyListView($blueprint, $actions);
|
$properties = $this->buildPropertyListView($blueprint, $actions);
|
||||||
|
|
||||||
$blueprint_uri = 'blueprint/'.$blueprint->getID().'/';
|
|
||||||
$blueprint_uri = $this->getApplicationURI($blueprint_uri);
|
|
||||||
|
|
||||||
$resources = id(new DrydockResourceQuery())
|
|
||||||
->withBlueprintPHIDs(array($blueprint->getPHID()))
|
|
||||||
->setViewer($viewer)
|
|
||||||
->execute();
|
|
||||||
|
|
||||||
$resource_list = id(new DrydockResourceListView())
|
|
||||||
->setUser($viewer)
|
|
||||||
->setResources($resources)
|
|
||||||
->render();
|
|
||||||
$resource_list->setNoDataString(pht('This blueprint has no resources.'));
|
|
||||||
|
|
||||||
$pager = new PHUIPagerView();
|
|
||||||
$pager->setURI(new PhutilURI($blueprint_uri), 'offset');
|
|
||||||
$pager->setOffset($request->getInt('offset'));
|
|
||||||
|
|
||||||
$crumbs = $this->buildApplicationCrumbs();
|
$crumbs = $this->buildApplicationCrumbs();
|
||||||
$crumbs->addTextCrumb(pht('Blueprint %d', $blueprint->getID()));
|
$crumbs->addTextCrumb(pht('Blueprint %d', $blueprint->getID()));
|
||||||
|
|
||||||
|
@ -67,9 +49,7 @@ final class DrydockBlueprintViewController extends DrydockBlueprintController {
|
||||||
$viewer,
|
$viewer,
|
||||||
$properties);
|
$properties);
|
||||||
|
|
||||||
$resource_box = id(new PHUIObjectBoxView())
|
$resource_box = $this->buildResourceBox($blueprint);
|
||||||
->setHeaderText(pht('Resources'))
|
|
||||||
->setObjectList($resource_list);
|
|
||||||
|
|
||||||
$timeline = $this->buildTransactionTimeline(
|
$timeline = $this->buildTransactionTimeline(
|
||||||
$blueprint,
|
$blueprint,
|
||||||
|
@ -148,4 +128,43 @@ final class DrydockBlueprintViewController extends DrydockBlueprintController {
|
||||||
return $view;
|
return $view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function buildResourceBox(DrydockBlueprint $blueprint) {
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
|
$resources = id(new DrydockResourceQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withBlueprintPHIDs(array($blueprint->getPHID()))
|
||||||
|
->withStatuses(
|
||||||
|
array(
|
||||||
|
DrydockResourceStatus::STATUS_PENDING,
|
||||||
|
DrydockResourceStatus::STATUS_ACTIVE,
|
||||||
|
))
|
||||||
|
->setLimit(100)
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
$resource_list = id(new DrydockResourceListView())
|
||||||
|
->setUser($viewer)
|
||||||
|
->setResources($resources)
|
||||||
|
->render()
|
||||||
|
->setNoDataString(pht('This blueprint has no active resources.'));
|
||||||
|
|
||||||
|
$id = $blueprint->getID();
|
||||||
|
$resources_uri = "blueprint/{$id}/resources/query/all/";
|
||||||
|
$resources_uri = $this->getApplicationURI($resources_uri);
|
||||||
|
|
||||||
|
$resource_header = id(new PHUIHeaderView())
|
||||||
|
->setHeader(pht('Active Resources'))
|
||||||
|
->addActionLink(
|
||||||
|
id(new PHUIButtonView())
|
||||||
|
->setTag('a')
|
||||||
|
->setHref($resources_uri)
|
||||||
|
->setIconFont('fa-search')
|
||||||
|
->setText(pht('View All Resources')));
|
||||||
|
|
||||||
|
return id(new PHUIObjectBoxView())
|
||||||
|
->setHeader($resource_header)
|
||||||
|
->setObjectList($resource_list);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,23 @@
|
||||||
abstract class DrydockResourceController
|
abstract class DrydockResourceController
|
||||||
extends DrydockController {
|
extends DrydockController {
|
||||||
|
|
||||||
|
private $blueprint;
|
||||||
|
|
||||||
|
public function setBlueprint($blueprint) {
|
||||||
|
$this->blueprint = $blueprint;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBlueprint() {
|
||||||
|
return $this->blueprint;
|
||||||
|
}
|
||||||
|
|
||||||
public function buildSideNavView() {
|
public function buildSideNavView() {
|
||||||
$nav = new AphrontSideNavFilterView();
|
$nav = new AphrontSideNavFilterView();
|
||||||
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
|
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
|
||||||
|
|
||||||
id(new DrydockResourceSearchEngine())
|
id(new DrydockResourceSearchEngine())
|
||||||
->setViewer($this->getRequest()->getUser())
|
->setViewer($this->getViewer())
|
||||||
->addNavigationItems($nav->getMenu());
|
->addNavigationItems($nav->getMenu());
|
||||||
|
|
||||||
$nav->selectFilter(null);
|
$nav->selectFilter(null);
|
||||||
|
@ -18,9 +29,26 @@ abstract class DrydockResourceController
|
||||||
|
|
||||||
protected function buildApplicationCrumbs() {
|
protected function buildApplicationCrumbs() {
|
||||||
$crumbs = parent::buildApplicationCrumbs();
|
$crumbs = parent::buildApplicationCrumbs();
|
||||||
|
|
||||||
|
$blueprint = $this->getBlueprint();
|
||||||
|
if ($blueprint) {
|
||||||
|
$id = $blueprint->getID();
|
||||||
|
$crumbs->addTextCrumb(
|
||||||
|
pht('Blueprints'),
|
||||||
|
$this->getApplicationURI('blueprint/'));
|
||||||
|
|
||||||
|
$crumbs->addTextCrumb(
|
||||||
|
$blueprint->getBlueprintName(),
|
||||||
|
$this->getApplicationURI("blueprint/{$id}/"));
|
||||||
|
|
||||||
|
$crumbs->addTextCrumb(
|
||||||
|
pht('Resources'),
|
||||||
|
$this->getApplicationURI("blueprint/{$id}/resources/"));
|
||||||
|
} else {
|
||||||
$crumbs->addTextCrumb(
|
$crumbs->addTextCrumb(
|
||||||
pht('Resources'),
|
pht('Resources'),
|
||||||
$this->getApplicationURI('resource/'));
|
$this->getApplicationURI('resource/'));
|
||||||
|
}
|
||||||
return $crumbs;
|
return $crumbs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,28 @@ final class DrydockResourceListController extends DrydockResourceController {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handleRequest(AphrontRequest $request) {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
$viewer = $request->getViewer();
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
|
$engine = new DrydockResourceSearchEngine();
|
||||||
|
|
||||||
|
$id = $request->getURIData('id');
|
||||||
|
if ($id) {
|
||||||
|
$blueprint = id(new DrydockBlueprintQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withIDs(array($id))
|
||||||
|
->executeOne();
|
||||||
|
if (!$blueprint) {
|
||||||
|
return new Aphront404Response();
|
||||||
|
}
|
||||||
|
$this->setBlueprint($blueprint);
|
||||||
|
$engine->setBlueprint($blueprint);
|
||||||
|
}
|
||||||
|
|
||||||
$querykey = $request->getURIData('queryKey');
|
$querykey = $request->getURIData('queryKey');
|
||||||
|
|
||||||
$controller = id(new PhabricatorApplicationSearchController())
|
$controller = id(new PhabricatorApplicationSearchController())
|
||||||
->setQueryKey($querykey)
|
->setQueryKey($querykey)
|
||||||
->setSearchEngine(new DrydockResourceSearchEngine())
|
->setSearchEngine($engine)
|
||||||
->setNavigation($this->buildSideNavView());
|
->setNavigation($this->buildSideNavView());
|
||||||
|
|
||||||
return $this->delegateToController($controller);
|
return $this->delegateToController($controller);
|
||||||
|
|
|
@ -3,6 +3,17 @@
|
||||||
final class DrydockResourceSearchEngine
|
final class DrydockResourceSearchEngine
|
||||||
extends PhabricatorApplicationSearchEngine {
|
extends PhabricatorApplicationSearchEngine {
|
||||||
|
|
||||||
|
private $blueprint;
|
||||||
|
|
||||||
|
public function setBlueprint(DrydockBlueprint $blueprint) {
|
||||||
|
$this->blueprint = $blueprint;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBlueprint() {
|
||||||
|
return $this->blueprint;
|
||||||
|
}
|
||||||
|
|
||||||
public function getResultTypeDescription() {
|
public function getResultTypeDescription() {
|
||||||
return pht('Drydock Resources');
|
return pht('Drydock Resources');
|
||||||
}
|
}
|
||||||
|
@ -12,7 +23,14 @@ final class DrydockResourceSearchEngine
|
||||||
}
|
}
|
||||||
|
|
||||||
public function newQuery() {
|
public function newQuery() {
|
||||||
return new DrydockResourceQuery();
|
$query = new DrydockResourceQuery();
|
||||||
|
|
||||||
|
$blueprint = $this->getBlueprint();
|
||||||
|
if ($blueprint) {
|
||||||
|
$query->withBlueprintPHIDs(array($blueprint->getPHID()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function buildQueryFromParameters(array $map) {
|
protected function buildQueryFromParameters(array $map) {
|
||||||
|
@ -35,8 +53,14 @@ final class DrydockResourceSearchEngine
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getURI($path) {
|
protected function getURI($path) {
|
||||||
|
$blueprint = $this->getBlueprint();
|
||||||
|
if ($blueprint) {
|
||||||
|
$id = $blueprint->getID();
|
||||||
|
return "/drydock/blueprint/{$id}/resources/".$path;
|
||||||
|
} else {
|
||||||
return '/drydock/resource/'.$path;
|
return '/drydock/resource/'.$path;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected function getBuiltinQueryNames() {
|
protected function getBuiltinQueryNames() {
|
||||||
return array(
|
return array(
|
||||||
|
|
Loading…
Add table
Reference in a new issue