From 7615e59cf97c0a023cc9d9d6509a57a22bf17ec2 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 5 Jun 2013 18:58:50 -0700 Subject: [PATCH] Default application search to the topmost filter Summary: Allow users to set a default by dragging it to the top. When they land on a page without a saved query, choose their default. Test Plan: Hit `/paste/`, got my default results, etc. Reviewers: chad Reviewed By: chad CC: aran Differential Revision: https://secure.phabricator.com/D6140 --- .../controller/PhabricatorFileListController.php | 2 +- .../controller/PhabricatorMacroListController.php | 2 +- .../controller/PhabricatorPasteListController.php | 2 +- .../controller/PhabricatorPeopleListController.php | 2 +- .../PhabricatorApplicationSearchController.php | 11 ++++------- 5 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/applications/files/controller/PhabricatorFileListController.php b/src/applications/files/controller/PhabricatorFileListController.php index d3c1322607..3f307569b8 100644 --- a/src/applications/files/controller/PhabricatorFileListController.php +++ b/src/applications/files/controller/PhabricatorFileListController.php @@ -10,7 +10,7 @@ final class PhabricatorFileListController extends PhabricatorFileController } public function willProcessRequest(array $data) { - $this->key = idx($data, 'key', 'authored'); + $this->key = idx($data, 'key'); } public function processRequest() { diff --git a/src/applications/macro/controller/PhabricatorMacroListController.php b/src/applications/macro/controller/PhabricatorMacroListController.php index 95a0ab1f41..e1f03fd574 100644 --- a/src/applications/macro/controller/PhabricatorMacroListController.php +++ b/src/applications/macro/controller/PhabricatorMacroListController.php @@ -10,7 +10,7 @@ final class PhabricatorMacroListController extends PhabricatorMacroController } public function willProcessRequest(array $data) { - $this->key = idx($data, 'key', 'active'); + $this->key = idx($data, 'key'); } public function processRequest() { diff --git a/src/applications/paste/controller/PhabricatorPasteListController.php b/src/applications/paste/controller/PhabricatorPasteListController.php index 385e0ecc8c..7e4f972490 100644 --- a/src/applications/paste/controller/PhabricatorPasteListController.php +++ b/src/applications/paste/controller/PhabricatorPasteListController.php @@ -10,7 +10,7 @@ final class PhabricatorPasteListController extends PhabricatorPasteController } public function willProcessRequest(array $data) { - $this->queryKey = idx($data, 'queryKey', 'all'); + $this->queryKey = idx($data, 'queryKey'); } public function processRequest() { diff --git a/src/applications/people/controller/PhabricatorPeopleListController.php b/src/applications/people/controller/PhabricatorPeopleListController.php index beda82486d..b81397003c 100644 --- a/src/applications/people/controller/PhabricatorPeopleListController.php +++ b/src/applications/people/controller/PhabricatorPeopleListController.php @@ -14,7 +14,7 @@ final class PhabricatorPeopleListController extends PhabricatorPeopleController } public function willProcessRequest(array $data) { - $this->key = idx($data, 'key', 'all'); + $this->key = idx($data, 'key'); } public function processRequest() { diff --git a/src/applications/search/controller/PhabricatorApplicationSearchController.php b/src/applications/search/controller/PhabricatorApplicationSearchController.php index 814595593c..40ad447857 100644 --- a/src/applications/search/controller/PhabricatorApplicationSearchController.php +++ b/src/applications/search/controller/PhabricatorApplicationSearchController.php @@ -96,11 +96,13 @@ final class PhabricatorApplicationSearchController if ($this->queryKey == 'advanced') { $run_query = false; $query_key = $request->getStr('query'); + } else if (!strlen($this->queryKey)) { + $query_key = head_key($engine->loadEnabledNamedQueries()); } if ($engine->isBuiltinQuery($query_key)) { $saved_query = $engine->buildSavedQueryFromBuiltin($query_key); - $named_query = $engine->getBuiltinQuery($query_key); + $named_query = idx($engine->loadEnabledNamedQueries(), $query_key); } else if ($query_key) { $saved_query = id(new PhabricatorSavedQueryQuery()) ->setViewer($user) @@ -111,12 +113,7 @@ final class PhabricatorApplicationSearchController return new Aphront404Response(); } - $named_query = id(new PhabricatorNamedQueryQuery()) - ->setViewer($user) - ->withQueryKeys(array($saved_query->getQueryKey())) - ->withEngineClassNames(array(get_class($engine))) - ->withUserPHIDs(array($user->getPHID())) - ->executeOne(); + $named_query = idx($engine->loadEnabledNamedQueries(), $query_key); } else { $saved_query = $engine->buildSavedQueryFromRequest($request); }