1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 14:52:41 +01:00

Provide a Drydock "Console" controller

Summary:
Ref T2015. After introducing ApplicationSearch, the left nav turned into a soupy mess. Split the major sections into four separate areas, and unify them with a simple console.

This also reverts all the prefix stuff, since the results were awful and I don't anticipate it ever being the best solution to any UX problem.

Test Plan:
Browsed blueprints, resources, leases and logs.

Here's the new console:

{F93279}

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2015

Differential Revision: https://secure.phabricator.com/D7833
This commit is contained in:
epriestley 2013-12-26 12:30:36 -08:00
parent 9c9a9a919e
commit 5fdd800bb6
21 changed files with 234 additions and 75 deletions

View file

@ -636,6 +636,7 @@ phutil_register_library_map(array(
'DrydockAllocatorWorker' => 'applications/drydock/worker/DrydockAllocatorWorker.php',
'DrydockApacheWebrootInterface' => 'applications/drydock/interface/webroot/DrydockApacheWebrootInterface.php',
'DrydockBlueprint' => 'applications/drydock/storage/DrydockBlueprint.php',
'DrydockBlueprintController' => 'applications/drydock/controller/DrydockBlueprintController.php',
'DrydockBlueprintCreateController' => 'applications/drydock/controller/DrydockBlueprintCreateController.php',
'DrydockBlueprintEditController' => 'applications/drydock/controller/DrydockBlueprintEditController.php',
'DrydockBlueprintImplementation' => 'applications/drydock/blueprint/DrydockBlueprintImplementation.php',
@ -645,12 +646,14 @@ phutil_register_library_map(array(
'DrydockBlueprintSearchEngine' => 'applications/drydock/query/DrydockBlueprintSearchEngine.php',
'DrydockBlueprintViewController' => 'applications/drydock/controller/DrydockBlueprintViewController.php',
'DrydockCommandInterface' => 'applications/drydock/interface/command/DrydockCommandInterface.php',
'DrydockConsoleController' => 'applications/drydock/controller/DrydockConsoleController.php',
'DrydockConstants' => 'applications/drydock/constants/DrydockConstants.php',
'DrydockController' => 'applications/drydock/controller/DrydockController.php',
'DrydockDAO' => 'applications/drydock/storage/DrydockDAO.php',
'DrydockFilesystemInterface' => 'applications/drydock/interface/filesystem/DrydockFilesystemInterface.php',
'DrydockInterface' => 'applications/drydock/interface/DrydockInterface.php',
'DrydockLease' => 'applications/drydock/storage/DrydockLease.php',
'DrydockLeaseController' => 'applications/drydock/controller/DrydockLeaseController.php',
'DrydockLeaseListController' => 'applications/drydock/controller/DrydockLeaseListController.php',
'DrydockLeaseQuery' => 'applications/drydock/query/DrydockLeaseQuery.php',
'DrydockLeaseReleaseController' => 'applications/drydock/controller/DrydockLeaseReleaseController.php',
@ -660,6 +663,7 @@ phutil_register_library_map(array(
'DrydockLocalCommandInterface' => 'applications/drydock/interface/command/DrydockLocalCommandInterface.php',
'DrydockLocalHostBlueprintImplementation' => 'applications/drydock/blueprint/DrydockLocalHostBlueprintImplementation.php',
'DrydockLog' => 'applications/drydock/storage/DrydockLog.php',
'DrydockLogController' => 'applications/drydock/controller/DrydockLogController.php',
'DrydockLogListController' => 'applications/drydock/controller/DrydockLogListController.php',
'DrydockLogQuery' => 'applications/drydock/query/DrydockLogQuery.php',
'DrydockLogSearchEngine' => 'applications/drydock/query/DrydockLogSearchEngine.php',
@ -675,6 +679,7 @@ phutil_register_library_map(array(
'DrydockPreallocatedHostBlueprintImplementation' => 'applications/drydock/blueprint/DrydockPreallocatedHostBlueprintImplementation.php',
'DrydockResource' => 'applications/drydock/storage/DrydockResource.php',
'DrydockResourceCloseController' => 'applications/drydock/controller/DrydockResourceCloseController.php',
'DrydockResourceController' => 'applications/drydock/controller/DrydockResourceController.php',
'DrydockResourceListController' => 'applications/drydock/controller/DrydockResourceListController.php',
'DrydockResourceQuery' => 'applications/drydock/query/DrydockResourceQuery.php',
'DrydockResourceSearchEngine' => 'applications/drydock/query/DrydockResourceSearchEngine.php',
@ -3043,17 +3048,19 @@ phutil_register_library_map(array(
0 => 'DrydockDAO',
1 => 'PhabricatorPolicyInterface',
),
'DrydockBlueprintCreateController' => 'DrydockController',
'DrydockBlueprintEditController' => 'DrydockController',
'DrydockBlueprintController' => 'DrydockController',
'DrydockBlueprintCreateController' => 'DrydockBlueprintController',
'DrydockBlueprintEditController' => 'DrydockBlueprintController',
'DrydockBlueprintListController' =>
array(
0 => 'DrydockController',
0 => 'DrydockBlueprintController',
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
),
'DrydockBlueprintQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'DrydockBlueprintSearchEngine' => 'PhabricatorApplicationSearchEngine',
'DrydockBlueprintViewController' => 'DrydockController',
'DrydockBlueprintViewController' => 'DrydockBlueprintController',
'DrydockCommandInterface' => 'DrydockInterface',
'DrydockConsoleController' => 'DrydockController',
'DrydockController' => 'PhabricatorController',
'DrydockDAO' => 'PhabricatorLiskDAO',
'DrydockFilesystemInterface' => 'DrydockInterface',
@ -3062,16 +3069,17 @@ phutil_register_library_map(array(
0 => 'DrydockDAO',
1 => 'PhabricatorPolicyInterface',
),
'DrydockLeaseController' => 'DrydockController',
'DrydockLeaseListController' =>
array(
0 => 'DrydockController',
0 => 'DrydockLeaseController',
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
),
'DrydockLeaseQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'DrydockLeaseReleaseController' => 'DrydockController',
'DrydockLeaseReleaseController' => 'DrydockLeaseController',
'DrydockLeaseSearchEngine' => 'PhabricatorApplicationSearchEngine',
'DrydockLeaseStatus' => 'DrydockConstants',
'DrydockLeaseViewController' => 'DrydockController',
'DrydockLeaseViewController' => 'DrydockLeaseController',
'DrydockLocalCommandInterface' => 'DrydockCommandInterface',
'DrydockLocalHostBlueprintImplementation' => 'DrydockBlueprintImplementation',
'DrydockLog' =>
@ -3079,9 +3087,10 @@ phutil_register_library_map(array(
0 => 'DrydockDAO',
1 => 'PhabricatorPolicyInterface',
),
'DrydockLogController' => 'DrydockController',
'DrydockLogListController' =>
array(
0 => 'DrydockController',
0 => 'DrydockLogController',
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
),
'DrydockLogQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
@ -3101,16 +3110,17 @@ phutil_register_library_map(array(
0 => 'DrydockDAO',
1 => 'PhabricatorPolicyInterface',
),
'DrydockResourceCloseController' => 'DrydockController',
'DrydockResourceCloseController' => 'DrydockResourceController',
'DrydockResourceController' => 'DrydockController',
'DrydockResourceListController' =>
array(
0 => 'DrydockController',
0 => 'DrydockResourceController',
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
),
'DrydockResourceQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'DrydockResourceSearchEngine' => 'PhabricatorApplicationSearchEngine',
'DrydockResourceStatus' => 'DrydockConstants',
'DrydockResourceViewController' => 'DrydockController',
'DrydockResourceViewController' => 'DrydockResourceController',
'DrydockSFTPFilesystemInterface' => 'DrydockFilesystemInterface',
'DrydockSSHCommandInterface' => 'DrydockCommandInterface',
'DrydockWebrootInterface' => 'DrydockInterface',

View file

@ -33,7 +33,7 @@ final class PhabricatorApplicationDrydock extends PhabricatorApplication {
public function getRoutes() {
return array(
'/drydock/' => array(
'' => 'DrydockResourceListController',
'' => 'DrydockConsoleController',
'blueprint/' => array(
'(?:query/(?P<queryKey>[^/]+)/)?' => 'DrydockBlueprintListController',
'(?P<id>[1-9]\d*)/' => 'DrydockBlueprintViewController',

View file

@ -0,0 +1,27 @@
<?php
abstract class DrydockBlueprintController
extends DrydockController {
public function buildSideNavView() {
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
id(new DrydockBlueprintSearchEngine())
->setViewer($this->getRequest()->getUser())
->addNavigationItems($nav->getMenu());
$nav->selectFilter(null);
return $nav;
}
public function buildApplicationCrumbs() {
$crumbs = parent::buildApplicationCrumbs();
$crumbs->addTextCrumb(
pht('Blueprints'),
$this->getApplicationURI('blueprint/'));
return $crumbs;
}
}

View file

@ -1,10 +1,7 @@
<?php
final class DrydockBlueprintCreateController
extends DrydockController {
public function willProcessRequest(array $data) {
}
extends DrydockBlueprintController {
public function processRequest() {
$request = $this->getRequest();

View file

@ -1,6 +1,6 @@
<?php
final class DrydockBlueprintEditController extends DrydockController {
final class DrydockBlueprintEditController extends DrydockBlueprintController {
private $id;

View file

@ -1,6 +1,6 @@
<?php
final class DrydockBlueprintListController extends DrydockController
final class DrydockBlueprintListController extends DrydockBlueprintController
implements PhabricatorApplicationSearchResultsControllerInterface {
private $queryKey;
@ -18,7 +18,7 @@ final class DrydockBlueprintListController extends DrydockController
$controller = id(new PhabricatorApplicationSearchController($request))
->setQueryKey($this->queryKey)
->setSearchEngine(new DrydockBlueprintSearchEngine())
->setNavigation($this->buildSideNav());
->setNavigation($this->buildSideNavView());
return $this->delegateToController($controller);
}

View file

@ -1,6 +1,6 @@
<?php
final class DrydockBlueprintViewController extends DrydockController {
final class DrydockBlueprintViewController extends DrydockBlueprintController {
private $id;

View file

@ -0,0 +1,80 @@
<?php
final class DrydockConsoleController extends DrydockController {
public function shouldAllowPublic() {
return true;
}
public function buildSideNavView() {
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
// These are only used on mobile.
$nav->addFilter('blueprint', pht('Blueprints'));
$nav->addFilter('resource', pht('Resources'));
$nav->addFilter('lease', pht('Leases'));
$nav->addFilter('log', pht('Logs'));
$nav->selectFilter(null);
return $nav;
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$menu = id(new PHUIObjectItemListView())
->setUser($viewer);
$menu->addItem(
id(new PHUIObjectItemView())
->setHeader(pht('Blueprints'))
->setHref($this->getApplicationURI('blueprint/'))
->addAttribute(
pht(
'Configure blueprints so Drydock can build resources, like '.
'hosts and working copies.')));
$menu->addItem(
id(new PHUIObjectItemView())
->setHeader(pht('Resources'))
->setHref($this->getApplicationURI('resource/'))
->addAttribute(
pht(
'View and manage resources Drydock has built, like hosts.')));
$menu->addItem(
id(new PHUIObjectItemView())
->setHeader(pht('Leases'))
->setHref($this->getApplicationURI('lease/'))
->addAttribute(
pht(
'Manage leases on resources.')));
$menu->addItem(
id(new PHUIObjectItemView())
->setHeader(pht('Logs'))
->setHref($this->getApplicationURI('log/'))
->addAttribute(
pht(
'View logs.')));
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Console'));
return $this->buildApplicationPage(
array(
$crumbs,
$menu,
),
array(
'title' => pht('Drydock Console'),
'device' => true,
));
}
}

View file

@ -2,33 +2,10 @@
abstract class DrydockController extends PhabricatorController {
final protected function buildSideNav($selected = null) {
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI('/drydock/'));
id(new DrydockBlueprintSearchEngine())
->setViewer($this->getRequest()->getUser())
->addNavigationItems($nav->getMenu(), pht('Blueprints'));
id(new DrydockLeaseSearchEngine())
->setViewer($this->getRequest()->getUser())
->addNavigationItems($nav->getMenu(), pht('Leases'));
id(new DrydockResourceSearchEngine())
->setViewer($this->getRequest()->getUser())
->addNavigationItems($nav->getMenu(), pht('Resources'));
id(new DrydockLogSearchEngine())
->setViewer($this->getRequest()->getUser())
->addNavigationItems($nav->getMenu(), pht('Logs'));
$nav->selectFilter($selected, 'resource');
return $nav;
}
abstract function buildSideNavView();
public function buildApplicationMenu() {
return $this->buildSideNav(null)->getMenu();
return $this->buildSideNavView()->getMenu();
}
protected function buildLogTableView(array $logs) {

View file

@ -0,0 +1,27 @@
<?php
abstract class DrydockLeaseController
extends DrydockController {
public function buildSideNavView() {
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
id(new DrydockLeaseSearchEngine())
->setViewer($this->getRequest()->getUser())
->addNavigationItems($nav->getMenu());
$nav->selectFilter(null);
return $nav;
}
public function buildApplicationCrumbs() {
$crumbs = parent::buildApplicationCrumbs();
$crumbs->addTextCrumb(
pht('Leases'),
$this->getApplicationURI('lease/'));
return $crumbs;
}
}

View file

@ -1,6 +1,6 @@
<?php
final class DrydockLeaseListController extends DrydockController
final class DrydockLeaseListController extends DrydockLeaseController
implements PhabricatorApplicationSearchResultsControllerInterface {
private $queryKey;
@ -18,7 +18,7 @@ final class DrydockLeaseListController extends DrydockController
$controller = id(new PhabricatorApplicationSearchController($request))
->setQueryKey($this->queryKey)
->setSearchEngine(new DrydockLeaseSearchEngine())
->setNavigation($this->buildSideNav());
->setNavigation($this->buildSideNavView());
return $this->delegateToController($controller);
}

View file

@ -1,6 +1,6 @@
<?php
final class DrydockLeaseReleaseController extends DrydockController {
final class DrydockLeaseReleaseController extends DrydockLeaseController {
private $id;

View file

@ -1,6 +1,6 @@
<?php
final class DrydockLeaseViewController extends DrydockController {
final class DrydockLeaseViewController extends DrydockLeaseController {
private $id;

View file

@ -0,0 +1,27 @@
<?php
abstract class DrydockLogController
extends DrydockController {
public function buildSideNavView() {
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
id(new DrydockLogSearchEngine())
->setViewer($this->getRequest()->getUser())
->addNavigationItems($nav->getMenu());
$nav->selectFilter(null);
return $nav;
}
public function buildApplicationCrumbs() {
$crumbs = parent::buildApplicationCrumbs();
$crumbs->addTextCrumb(
pht('Logs'),
$this->getApplicationURI('log/'));
return $crumbs;
}
}

View file

@ -1,6 +1,6 @@
<?php
final class DrydockLogListController extends DrydockController
final class DrydockLogListController extends DrydockLogController
implements PhabricatorApplicationSearchResultsControllerInterface {
private $queryKey;
@ -18,7 +18,7 @@ final class DrydockLogListController extends DrydockController
$controller = id(new PhabricatorApplicationSearchController($request))
->setQueryKey($this->queryKey)
->setSearchEngine(new DrydockLogSearchEngine())
->setNavigation($this->buildSideNav());
->setNavigation($this->buildSideNavView());
return $this->delegateToController($controller);
}

View file

@ -1,6 +1,6 @@
<?php
final class DrydockResourceCloseController extends DrydockController {
final class DrydockResourceCloseController extends DrydockResourceController {
private $id;

View file

@ -0,0 +1,27 @@
<?php
abstract class DrydockResourceController
extends DrydockController {
public function buildSideNavView() {
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
id(new DrydockResourceSearchEngine())
->setViewer($this->getRequest()->getUser())
->addNavigationItems($nav->getMenu());
$nav->selectFilter(null);
return $nav;
}
public function buildApplicationCrumbs() {
$crumbs = parent::buildApplicationCrumbs();
$crumbs->addTextCrumb(
pht('Resources'),
$this->getApplicationURI('resource/'));
return $crumbs;
}
}

View file

@ -1,6 +1,6 @@
<?php
final class DrydockResourceListController extends DrydockController
final class DrydockResourceListController extends DrydockResourceController
implements PhabricatorApplicationSearchResultsControllerInterface {
private $queryKey;
@ -18,7 +18,7 @@ final class DrydockResourceListController extends DrydockController
$controller = id(new PhabricatorApplicationSearchController($request))
->setQueryKey($this->queryKey)
->setSearchEngine(new DrydockResourceSearchEngine())
->setNavigation($this->buildSideNav());
->setNavigation($this->buildSideNavView());
return $this->delegateToController($controller);
}

View file

@ -1,6 +1,6 @@
<?php
final class DrydockResourceViewController extends DrydockController {
final class DrydockResourceViewController extends DrydockResourceController {
private $id;

View file

@ -154,8 +154,8 @@ final class PhabricatorApplicationSearchController
}
$nav->selectFilter(
$engine->getNavPrefix().'query/'.$saved_query->getQueryKey(),
$engine->getNavPrefix().'query/advanced');
'query/'.$saved_query->getQueryKey(),
'query/advanced');
$form = id(new AphrontFormView())
->setUser($user);

View file

@ -107,40 +107,27 @@ abstract class PhabricatorApplicationSearchEngine {
->setEngineClassName(get_class($this));
}
public function getNavPrefix() {
return get_class($this).':';
}
public function addNavigationItems(PHUIListView $menu, $label = null) {
public function addNavigationItems(PHUIListView $menu) {
$viewer = $this->requireViewer();
$menu->newLabel(coalesce($label, pht('Queries')));
$menu->newLabel(pht('Queries'));
$named_queries = $this->loadEnabledNamedQueries();
$prefix = $this->getNavPrefix();
foreach ($named_queries as $query) {
$key = $query->getQueryKey();
$uri = $this->getQueryResultsPageURI($key);
$menu->newLink(
$query->getQueryName(),
$uri,
$prefix.'query/'.$key);
$menu->newLink($query->getQueryName(), $uri, 'query/'.$key);
}
if ($viewer->isLoggedIn()) {
$manage_uri = $this->getQueryManagementURI();
$menu->newLink(
pht('Edit Queries...'),
$manage_uri,
$prefix.'query/edit');
$menu->newLink(pht('Edit Queries...'), $manage_uri, 'query/edit');
}
$menu->newLabel(pht('Search'));
$advanced_uri = $this->getQueryResultsPageURI('advanced');
$menu->newLink(
pht('Advanced Search'),
$advanced_uri, $prefix.'query/advanced');
$menu->newLink(pht('Advanced Search'), $advanced_uri, 'query/advanced');
return $this;
}