Page MenuHomePhabricator

D7829.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/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',
diff --git a/src/applications/drydock/application/PhabricatorApplicationDrydock.php b/src/applications/drydock/application/PhabricatorApplicationDrydock.php
--- a/src/applications/drydock/application/PhabricatorApplicationDrydock.php
+++ b/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',
diff --git a/src/applications/drydock/controller/DrydockBlueprintListController.php b/src/applications/drydock/controller/DrydockBlueprintListController.php
--- a/src/applications/drydock/controller/DrydockBlueprintListController.php
+++ b/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) {
diff --git a/src/applications/drydock/controller/DrydockController.php b/src/applications/drydock/controller/DrydockController.php
--- a/src/applications/drydock/controller/DrydockController.php
+++ b/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');
diff --git a/src/applications/drydock/query/DrydockBlueprintSearchEngine.php b/src/applications/drydock/query/DrydockBlueprintSearchEngine.php
new file mode 100644
--- /dev/null
+++ b/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);
+ }
+
+}
diff --git a/src/applications/search/controller/PhabricatorApplicationSearchController.php b/src/applications/search/controller/PhabricatorApplicationSearchController.php
--- a/src/applications/search/controller/PhabricatorApplicationSearchController.php
+++ b/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);
diff --git a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
--- a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
+++ b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
@@ -107,28 +107,40 @@
->setEngineClassName(get_class($this));
}
+ public function getNavPrefix() {
+ return get_class($this).':';
+ }
public function addNavigationItems(PHUIListView $menu, $label = null) {
$viewer = $this->requireViewer();
$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/x-diff
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/qd/37/74xp7m35bq7pojm4
Default Alt Text
D7829.diff (9 KB)

Event Timeline