From afa2dbc3dc3c2b6be90462bd8e4679f9d6e44065 Mon Sep 17 00:00:00 2001 From: Alan Huang Date: Mon, 23 Jul 2012 17:41:46 -0700 Subject: [PATCH] Accept GET requests for jump nav Summary: The URL /jump/?jump=%s now does the same thing as the POST version, except that if it couldn't jump to anything, it loads /jump/ with the query filled in so you can just press enter (we don't save searches without a CSRF token). (hsb: Sorry for stealing your task! It hadn't been updated in two months so I figured you were likely not actively working on it.) Test Plan: Loaded given URL with different queries (including various flavors of nothing). Search worked as expected. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T1036 Differential Revision: https://secure.phabricator.com/D3047 --- .../PhabricatorDirectoryMainController.php | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/applications/directory/controller/PhabricatorDirectoryMainController.php b/src/applications/directory/controller/PhabricatorDirectoryMainController.php index af192b8a0a..e74f810a0f 100644 --- a/src/applications/directory/controller/PhabricatorDirectoryMainController.php +++ b/src/applications/directory/controller/PhabricatorDirectoryMainController.php @@ -105,24 +105,22 @@ final class PhabricatorDirectoryMainController private function buildJumpResponse($nav) { $request = $this->getRequest(); - if ($request->isFormPost()) { - $jump = $request->getStr('jump'); + $jump = $request->getStr('jump'); - $response = PhabricatorJumpNavHandler::jumpPostResponse($jump); - if ($response) { - return $response; - } else { - $query = new PhabricatorSearchQuery(); - $query->setQuery($jump); - $query->save(); + $response = PhabricatorJumpNavHandler::jumpPostResponse($jump); + if ($response) { + return $response; + } else if ($request->isFormPost()) { + $query = new PhabricatorSearchQuery(); + $query->setQuery($jump); + $query->save(); - return id(new AphrontRedirectResponse()) - ->setURI('/search/'.$query->getQueryKey().'/'); - } + return id(new AphrontRedirectResponse()) + ->setURI('/search/'.$query->getQueryKey().'/'); } - $nav->appendChild($this->buildJumpPanel()); + $nav->appendChild($this->buildJumpPanel($jump)); return $this->buildStandardPageResponse( $nav, array( @@ -430,7 +428,7 @@ final class PhabricatorDirectoryMainController ''; } - private function buildJumpPanel() { + private function buildJumpPanel($query=null) { $request = $this->getRequest(); $user = $request->getUser(); @@ -459,6 +457,7 @@ final class PhabricatorDirectoryMainController 'class' => 'phabricator-jump-nav', 'name' => 'jump', 'id' => $uniq_id, + 'value' => $query, )); $jump_caption = phutil_render_tag( 'p',