1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-27 16:00:59 +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 {
public function buildSideNavView($filter = null, $for_app = false) {
public function buildSideNavView($for_app = false) {
$user = $this->getRequest()->getUser();
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI('filter/')));
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
if ($for_app) {
$nav->addFilter('', pht('Create Paste'),
$this->getApplicationURI('/create/'));
$nav->addFilter('create', pht('Create Paste'));
}
$nav->addLabel(pht('Filters'));
$nav->addFilter('all', pht('All Pastes'));
if ($user->isLoggedIn()) {
$nav->addFilter('my', pht('My Pastes'));
$nav->addLabel(pht('Queries'));
$named_queries = id(new PhabricatorNamedQueryQuery())
->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->addFilter('advanced', pht('Advanced Search'));
$nav->addFilter('', pht('Saved Queries'),
$this->getApplicationURI('/savedqueries/'));
$nav->addFilter('filter/advanced', pht('Advanced Search'));
$nav->selectFilter($filter, 'all');
$nav->selectFilter(null);
return $nav;
}
public function buildApplicationMenu() {
return $this->buildSideNavView(null, true)->getMenu();
return $this->buildSideNavView(true)->getMenu();
}
public function buildApplicationCrumbs() {

View file

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

View file

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

View file

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