1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-23 15:22:41 +01:00

Update Search for handleRequest

Summary: Ref T8628. Updates Search.

Test Plan: Did various searches, saved new queries, reordered, ran new queries.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T8628

Differential Revision: https://secure.phabricator.com/D14268
This commit is contained in:
Chad Little 2015-10-20 09:02:55 -07:00
parent 22b9b76079
commit 09ab82faef
5 changed files with 30 additions and 60 deletions

View file

@ -5,19 +5,12 @@ final class PhabricatorSearchController
const SCOPE_CURRENT_APPLICATION = 'application'; const SCOPE_CURRENT_APPLICATION = 'application';
private $queryKey;
public function shouldAllowPublic() { public function shouldAllowPublic() {
return true; return true;
} }
public function willProcessRequest(array $data) { public function handleRequest(AphrontRequest $request) {
$this->queryKey = idx($data, 'queryKey'); $viewer = $this->getViewer();
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
if ($request->getStr('jump') != 'no') { if ($request->getStr('jump') != 'no') {
$pref_jump = PhabricatorUserPreferences::PREFERENCE_SEARCHBAR_JUMP; $pref_jump = PhabricatorUserPreferences::PREFERENCE_SEARCHBAR_JUMP;
@ -97,7 +90,7 @@ final class PhabricatorSearchController
} }
$controller = id(new PhabricatorApplicationSearchController()) $controller = id(new PhabricatorApplicationSearchController())
->setQueryKey($this->queryKey) ->setQueryKey($request->getURIData('queryKey'))
->setSearchEngine($engine) ->setSearchEngine($engine)
->setNavigation($this->buildSideNavView()); ->setNavigation($this->buildSideNavView());
@ -105,7 +98,7 @@ final class PhabricatorSearchController
} }
public function buildSideNavView($for_app = false) { public function buildSideNavView($for_app = false) {
$viewer = $this->getRequest()->getUser(); $viewer = $this->getViewer();
$nav = new AphrontSideNavFilterView(); $nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI())); $nav->setBaseURI(new PhutilURI($this->getApplicationURI()));

View file

@ -3,33 +3,24 @@
final class PhabricatorSearchDeleteController final class PhabricatorSearchDeleteController
extends PhabricatorSearchBaseController { extends PhabricatorSearchBaseController {
private $queryKey; public function handleRequest(AphrontRequest $request) {
private $engineClass; $viewer = $this->getViewer();
$key = $request->getURIData('queryKey');
public function willProcessRequest(array $data) { $engine_class = $request->getURIData('engine');
$this->queryKey = idx($data, 'queryKey');
$this->engineClass = idx($data, 'engine');
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$key = $this->queryKey;
$base_class = 'PhabricatorApplicationSearchEngine'; $base_class = 'PhabricatorApplicationSearchEngine';
if (!is_subclass_of($this->engineClass, $base_class)) { if (!is_subclass_of($engine_class, $base_class)) {
return new Aphront400Response(); return new Aphront400Response();
} }
$engine = newv($this->engineClass, array()); $engine = newv($engine_class, array());
$engine->setViewer($user); $engine->setViewer($viewer);
$named_query = id(new PhabricatorNamedQueryQuery()) $named_query = id(new PhabricatorNamedQueryQuery())
->setViewer($user) ->setViewer($viewer)
->withEngineClassNames(array($this->engineClass)) ->withEngineClassNames(array($engine_class))
->withQueryKeys(array($key)) ->withQueryKeys(array($key))
->withUserPHIDs(array($user->getPHID())) ->withUserPHIDs(array($viewer->getPHID()))
->executeOne(); ->executeOne();
if (!$named_query && $engine->isBuiltinQuery($key)) { if (!$named_query && $engine->isBuiltinQuery($key)) {
@ -84,7 +75,7 @@ final class PhabricatorSearchDeleteController
} }
$dialog = id(new AphrontDialogView()) $dialog = id(new AphrontDialogView())
->setUser($user) ->setUser($viewer)
->setTitle($title) ->setTitle($title)
->appendChild($desc) ->appendChild($desc)
->addCancelButton($return_uri) ->addCancelButton($return_uri)

View file

@ -3,38 +3,31 @@
final class PhabricatorSearchEditController final class PhabricatorSearchEditController
extends PhabricatorSearchBaseController { extends PhabricatorSearchBaseController {
private $queryKey; public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
public function willProcessRequest(array $data) {
$this->queryKey = idx($data, 'queryKey');
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$saved_query = id(new PhabricatorSavedQueryQuery()) $saved_query = id(new PhabricatorSavedQueryQuery())
->setViewer($user) ->setViewer($viewer)
->withQueryKeys(array($this->queryKey)) ->withQueryKeys(array($request->getURIData('queryKey')))
->executeOne(); ->executeOne();
if (!$saved_query) { if (!$saved_query) {
return new Aphront404Response(); return new Aphront404Response();
} }
$engine = $saved_query->newEngine()->setViewer($user); $engine = $saved_query->newEngine()->setViewer($viewer);
$complete_uri = $engine->getQueryManagementURI(); $complete_uri = $engine->getQueryManagementURI();
$cancel_uri = $complete_uri; $cancel_uri = $complete_uri;
$named_query = id(new PhabricatorNamedQueryQuery()) $named_query = id(new PhabricatorNamedQueryQuery())
->setViewer($user) ->setViewer($viewer)
->withQueryKeys(array($saved_query->getQueryKey())) ->withQueryKeys(array($saved_query->getQueryKey()))
->withUserPHIDs(array($user->getPHID())) ->withUserPHIDs(array($viewer->getPHID()))
->executeOne(); ->executeOne();
if (!$named_query) { if (!$named_query) {
$named_query = id(new PhabricatorNamedQuery()) $named_query = id(new PhabricatorNamedQuery())
->setUserPHID($user->getPHID()) ->setUserPHID($viewer->getPHID())
->setQueryKey($saved_query->getQueryKey()) ->setQueryKey($saved_query->getQueryKey())
->setEngineClassName($saved_query->getEngineClassName()); ->setEngineClassName($saved_query->getEngineClassName());
@ -64,7 +57,7 @@ final class PhabricatorSearchEditController
} }
$form = id(new AphrontFormView()) $form = id(new AphrontFormView())
->setUser($user); ->setUser($viewer);
$form->appendChild( $form->appendChild(
id(new AphrontFormTextControl()) id(new AphrontFormTextControl())

View file

@ -9,7 +9,6 @@ final class PhabricatorSearchHovercardController
public function handleRequest(AphrontRequest $request) { public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer(); $viewer = $this->getViewer();
$phids = $request->getArr('phids'); $phids = $request->getArr('phids');
$handles = id(new PhabricatorHandleQuery()) $handles = id(new PhabricatorHandleQuery())

View file

@ -3,25 +3,19 @@
final class PhabricatorSearchOrderController final class PhabricatorSearchOrderController
extends PhabricatorSearchBaseController { extends PhabricatorSearchBaseController {
private $engineClass; public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
public function willProcessRequest(array $data) { $engine_class = $request->getURIData('engine');
$this->engineClass = idx($data, 'engine');
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$request->validateCSRF(); $request->validateCSRF();
$base_class = 'PhabricatorApplicationSearchEngine'; $base_class = 'PhabricatorApplicationSearchEngine';
if (!is_subclass_of($this->engineClass, $base_class)) { if (!is_subclass_of($engine_class, $base_class)) {
return new Aphront400Response(); return new Aphront400Response();
} }
$engine = newv($this->engineClass, array()); $engine = newv($engine_class, array());
$engine->setViewer($user); $engine->setViewer($viewer);
$queries = $engine->loadAllNamedQueries(); $queries = $engine->loadAllNamedQueries();
$queries = mpull($queries, null, 'getQueryKey'); $queries = mpull($queries, null, 'getQueryKey');