Page MenuHomePhabricator

D7829.diff
No OneTemporary

D7829.diff

Index: src/__phutil_library_map__.php
===================================================================
--- src/__phutil_library_map__.php
+++ src/__phutil_library_map__.php
@@ -642,6 +642,7 @@
'DrydockBlueprintListController' => 'applications/drydock/controller/DrydockBlueprintListController.php',
'DrydockBlueprintQuery' => 'applications/drydock/query/DrydockBlueprintQuery.php',
'DrydockBlueprintScopeGuard' => 'applications/drydock/util/DrydockBlueprintScopeGuard.php',
+ 'DrydockBlueprintSearchEngine' => 'applications/drydock/query/DrydockBlueprintSearchEngine.php',
'DrydockBlueprintViewController' => 'applications/drydock/controller/DrydockBlueprintViewController.php',
'DrydockCommandInterface' => 'applications/drydock/interface/command/DrydockCommandInterface.php',
'DrydockConstants' => 'applications/drydock/constants/DrydockConstants.php',
@@ -3042,8 +3043,13 @@
),
'DrydockBlueprintCreateController' => 'DrydockController',
'DrydockBlueprintEditController' => 'DrydockController',
- 'DrydockBlueprintListController' => 'DrydockController',
+ 'DrydockBlueprintListController' =>
+ array(
+ 0 => 'DrydockController',
+ 1 => 'PhabricatorApplicationSearchResultsControllerInterface',
+ ),
'DrydockBlueprintQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
+ 'DrydockBlueprintSearchEngine' => 'PhabricatorApplicationSearchEngine',
'DrydockBlueprintViewController' => 'DrydockController',
'DrydockCommandInterface' => 'DrydockInterface',
'DrydockController' => 'PhabricatorController',
Index: src/applications/drydock/application/PhabricatorApplicationDrydock.php
===================================================================
--- src/applications/drydock/application/PhabricatorApplicationDrydock.php
+++ src/applications/drydock/application/PhabricatorApplicationDrydock.php
@@ -35,7 +35,7 @@
'/drydock/' => array(
'' => 'DrydockResourceListController',
'blueprint/' => array(
- '' => 'DrydockBlueprintListController',
+ '(?:query/(?P<queryKey>[^/]+)/)?' => 'DrydockBlueprintListController',
'(?P<id>[1-9]\d*)/' => 'DrydockBlueprintViewController',
'create/' => 'DrydockBlueprintCreateController',
'edit/(?P<id>[1-9]\d*)/' => 'DrydockBlueprintEditController',
Index: src/applications/drydock/controller/DrydockBlueprintListController.php
===================================================================
--- src/applications/drydock/controller/DrydockBlueprintListController.php
+++ src/applications/drydock/controller/DrydockBlueprintListController.php
@@ -1,52 +1,34 @@
<?php
-final class DrydockBlueprintListController extends DrydockController {
+final class DrydockBlueprintListController extends DrydockController
+ implements PhabricatorApplicationSearchResultsControllerInterface {
- public function processRequest() {
- $request = $this->getRequest();
- $user = $request->getUser();
-
- $title = pht('Blueprints');
-
- $blueprint_header = id(new PHUIHeaderView())
- ->setHeader($title);
-
- $blueprints = id(new DrydockBlueprintQuery())
- ->setViewer($user)
- ->execute();
-
- $blueprint_list = $this->buildBlueprintListView($blueprints);
+ private $queryKey;
- $crumbs = $this->buildApplicationCrumbs();
- $crumbs->addTextCrumb($title, $request->getRequestURI());
-
- $crumbs->addAction(
- id(new PHUIListItemView())
- ->setName(pht('New Blueprint'))
- ->setHref($this->getApplicationURI('blueprint/create/'))
- ->setIcon('create'));
+ public function shouldAllowPublic() {
+ return true;
+ }
- $nav = $this->buildSideNav('blueprint');
- $nav->setCrumbs($crumbs);
- $nav->appendChild(
- array(
- $blueprint_header,
- $blueprint_list
- ));
+ public function willProcessRequest(array $data) {
+ $this->queryKey = idx($data, 'queryKey');
+ }
- return $this->buildApplicationPage(
- $nav,
- array(
- 'title' => $title,
- 'device' => true,
- ));
+ public function processRequest() {
+ $request = $this->getRequest();
+ $controller = id(new PhabricatorApplicationSearchController($request))
+ ->setQueryKey($this->queryKey)
+ ->setSearchEngine(new DrydockBlueprintSearchEngine())
+ ->setNavigation($this->buildSideNav());
+ return $this->delegateToController($controller);
}
- protected function buildBlueprintListView(array $blueprints) {
+ public function renderResultsList(
+ array $blueprints,
+ PhabricatorSavedQuery $query) {
assert_instances_of($blueprints, 'DrydockBlueprint');
- $user = $this->getRequest()->getUser();
+ $viewer = $this->getRequest()->getUser();
$view = new PHUIObjectItemListView();
foreach ($blueprints as $blueprint) {
Index: src/applications/drydock/controller/DrydockController.php
===================================================================
--- src/applications/drydock/controller/DrydockController.php
+++ src/applications/drydock/controller/DrydockController.php
@@ -5,13 +5,18 @@
final protected function buildSideNav($selected = null) {
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI('/drydock/'));
- $nav->addFilter('blueprint', 'Blueprints');
- $nav->addFilter('resource', 'Resources');
+
+ id(new DrydockBlueprintSearchEngine())
+ ->setViewer($this->getRequest()->getUser())
+ ->addNavigationItems($nav->getMenu(), pht('Blueprints'));
id(new DrydockLeaseSearchEngine())
->setViewer($this->getRequest()->getUser())
->addNavigationItems($nav->getMenu(), pht('Leases'));
+ $nav->addLabel(pht('Resources'));
+ $nav->addFilter('resource', 'Resources');
+
$nav->addLabel(pht('Logs'));
$nav->addFilter('log', 'Logs');
Index: src/applications/drydock/query/DrydockBlueprintSearchEngine.php
===================================================================
--- /dev/null
+++ src/applications/drydock/query/DrydockBlueprintSearchEngine.php
@@ -0,0 +1,48 @@
+<?php
+
+final class DrydockBlueprintSearchEngine
+ extends PhabricatorApplicationSearchEngine {
+
+ public function buildSavedQueryFromRequest(AphrontRequest $request) {
+ $saved = new PhabricatorSavedQuery();
+
+ return $saved;
+ }
+
+ public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
+ $query = id(new DrydockBlueprintQuery());
+
+ return $query;
+ }
+
+ public function buildSearchForm(
+ AphrontFormView $form,
+ PhabricatorSavedQuery $saved) {
+
+ }
+
+ protected function getURI($path) {
+ return '/drydock/blueprint/'.$path;
+ }
+
+ public function getBuiltinQueryNames() {
+ $names = array(
+ 'all' => pht('All Blueprints'),
+ );
+
+ return $names;
+ }
+
+ public function buildSavedQueryFromBuiltin($query_key) {
+ $query = $this->newSavedQuery();
+ $query->setQueryKey($query_key);
+
+ switch ($query_key) {
+ case 'all':
+ return $query;
+ }
+
+ return parent::buildSavedQueryFromBuiltin($query_key);
+ }
+
+}
Index: src/applications/search/controller/PhabricatorApplicationSearchController.php
===================================================================
--- src/applications/search/controller/PhabricatorApplicationSearchController.php
+++ src/applications/search/controller/PhabricatorApplicationSearchController.php
@@ -154,8 +154,8 @@
}
$nav->selectFilter(
- 'query/'.$saved_query->getQueryKey(),
- 'query/advanced');
+ $engine->getNavPrefix().'query/'.$saved_query->getQueryKey(),
+ $engine->getNavPrefix().'query/advanced');
$form = id(new AphrontFormView())
->setUser($user);
Index: src/applications/search/engine/PhabricatorApplicationSearchEngine.php
===================================================================
--- src/applications/search/engine/PhabricatorApplicationSearchEngine.php
+++ src/applications/search/engine/PhabricatorApplicationSearchEngine.php
@@ -107,6 +107,9 @@
->setEngineClassName(get_class($this));
}
+ public function getNavPrefix() {
+ return get_class($this).':';
+ }
public function addNavigationItems(PHUIListView $menu, $label = null) {
$viewer = $this->requireViewer();
@@ -114,21 +117,30 @@
$menu->newLabel(coalesce($label, 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, 'query/'.$key);
+ $menu->newLink(
+ $query->getQueryName(),
+ $uri,
+ $prefix.'query/'.$key);
}
if ($viewer->isLoggedIn()) {
$manage_uri = $this->getQueryManagementURI();
- $menu->newLink(pht('Edit Queries...'), $manage_uri, 'query/edit');
+ $menu->newLink(
+ pht('Edit Queries...'),
+ $manage_uri,
+ $prefix.'query/edit');
}
$menu->newLabel(pht('Search'));
$advanced_uri = $this->getQueryResultsPageURI('advanced');
- $menu->newLink(pht('Advanced Search'), $advanced_uri, 'query/advanced');
+ $menu->newLink(
+ pht('Advanced Search'),
+ $advanced_uri, $prefix.'query/advanced');
return $this;
}

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 19, 4:43 PM (14 h, 50 m ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6721196
Default Alt Text
D7829.diff (9 KB)

Event Timeline