1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-30 02:32:42 +01:00

Slightly improve saved query UX

Summary:
Ref T2625.

  - Show saved queries in the left nav.
  - Highlight the correct stuff in the left nav.

Test Plan: Clicked all left-nav stuff.

Reviewers: btrahan, blc

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2625

Differential Revision: https://secure.phabricator.com/D6053
This commit is contained in:
epriestley 2013-05-27 13:41:09 -07:00
parent 12e9350efb
commit dcb5eb8e35
4 changed files with 33 additions and 22 deletions

View file

@ -2,35 +2,44 @@
abstract class PhabricatorPasteController extends PhabricatorController { abstract class PhabricatorPasteController extends PhabricatorController {
public function buildSideNavView($filter = null, $for_app = false) { public function buildSideNavView($for_app = false) {
$user = $this->getRequest()->getUser(); $user = $this->getRequest()->getUser();
$nav = new AphrontSideNavFilterView(); $nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI('filter/'))); $nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
if ($for_app) { if ($for_app) {
$nav->addFilter('', pht('Create Paste'), $nav->addFilter('create', pht('Create Paste'));
$this->getApplicationURI('/create/'));
} }
$nav->addLabel(pht('Filters')); $nav->addLabel(pht('Queries'));
$nav->addFilter('all', pht('All Pastes'));
if ($user->isLoggedIn()) { $named_queries = id(new PhabricatorNamedQueryQuery())
$nav->addFilter('my', pht('My Pastes')); ->setViewer($user)
->withUserPHIDs(array($user->getPHID()))
->withEngineClassNames(array('PhabricatorPasteSearchEngine'))
->execute();
foreach ($named_queries as $query) {
$nav->addFilter('query/'.$query->getQueryKey(), $query->getQueryName());
} }
$nav->addFilter('filter/all', pht('All Pastes'));
if ($user->isLoggedIn()) {
$nav->addFilter('filter/my', pht('My Pastes'));
}
$nav->addFilter('savedqueries', pht('Edit Queries...'));
$nav->addLabel(pht('Search')); $nav->addLabel(pht('Search'));
$nav->addFilter('advanced', pht('Advanced Search')); $nav->addFilter('filter/advanced', pht('Advanced Search'));
$nav->addFilter('', pht('Saved Queries'),
$this->getApplicationURI('/savedqueries/'));
$nav->selectFilter($filter, 'all'); $nav->selectFilter(null);
return $nav; return $nav;
} }
public function buildApplicationMenu() { public function buildApplicationMenu() {
return $this->buildSideNavView(null, true)->getMenu(); return $this->buildSideNavView(true)->getMenu();
} }
public function buildApplicationCrumbs() { public function buildApplicationCrumbs() {

View file

@ -29,12 +29,8 @@ final class PhabricatorPasteListController extends PhabricatorPasteController {
->setURI('/paste/query/'.$saved->getQueryKey().'/'); ->setURI('/paste/query/'.$saved->getQueryKey().'/');
} }
$nav = $this->buildSideNavView($this->filter); $nav = $this->buildSideNavView();
$filter = $nav->getSelectedFilter();
$saved_query = new PhabricatorSavedQuery();
$engine = id(new PhabricatorPasteSearchEngine()) $engine = id(new PhabricatorPasteSearchEngine())
->setPasteSearchFilter($filter)
->setPasteSearchUser($request->getUser()); ->setPasteSearchUser($request->getUser());
if ($this->queryKey !== null) { if ($this->queryKey !== null) {
@ -48,7 +44,13 @@ final class PhabricatorPasteListController extends PhabricatorPasteController {
$query = id(new PhabricatorPasteSearchEngine()) $query = id(new PhabricatorPasteSearchEngine())
->buildQueryFromSavedQuery($saved_query); ->buildQueryFromSavedQuery($saved_query);
$nav->selectFilter('query/'.$this->queryKey);
$filter = null;
} else { } else {
$filter = $nav->selectFilter('filter/'.$this->filter);
$engine->setPasteSearchFilter($filter);
$saved_query = $engine->buildSavedQueryFromRequest($request); $saved_query = $engine->buildSavedQueryFromRequest($request);
$query = $engine->buildQueryFromSavedQuery($saved_query); $query = $engine->buildQueryFromSavedQuery($saved_query);
} }
@ -63,7 +65,7 @@ final class PhabricatorPasteListController extends PhabricatorPasteController {
$list->setPager($pager); $list->setPager($pager);
$list->setNoDataString(pht("No results found for this query.")); $list->setNoDataString(pht("No results found for this query."));
if ($this->queryKey !== null || $filter == "advanced") { if ($this->queryKey !== null || $filter == "filter/advanced") {
$form = $engine->buildSearchForm($saved_query); $form = $engine->buildSearchForm($saved_query);
$nav->appendChild( $nav->appendChild(
array( array(

View file

@ -7,8 +7,8 @@ final class PhabricatorPasteQueriesController
$request = $this->getRequest(); $request = $this->getRequest();
$user = $request->getUser(); $user = $request->getUser();
$nav = $this->buildSideNavView(""); $nav = $this->buildSideNavView();
$filter = $nav->getSelectedFilter(); $nav->selectFilter('savedqueries');
$named_queries = id(new PhabricatorNamedQueryQuery()) $named_queries = id(new PhabricatorNamedQueryQuery())
->setViewer($user) ->setViewer($user)

View file

@ -21,7 +21,7 @@ final class PhabricatorPasteSearchEngine
$saved = new PhabricatorSavedQuery(); $saved = new PhabricatorSavedQuery();
if ($this->filter == "my") { if ($this->filter == "filter/my") {
$user = $request->getUser(); $user = $request->getUser();
$saved->setParameter('authorPHIDs', array($user->getPHID())); $saved->setParameter('authorPHIDs', array($user->getPHID()));
} else { } else {