Use ApplicationSearch in Diffusion
Summary: Ref T2625. Switches Diffusion to ApplicationSearch. Notes: - Rendering is a bit rough, I'll clean that up next. - Ordering is a bit arbitrary, also coming shortly. Test Plan: Used `/diffusion/` to execute various searches. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2625 Differential Revision: https://secure.phabricator.com/D6917
This commit is contained in:
		| @@ -0,0 +1,66 @@ | ||||
| <?php | ||||
|  | ||||
| final class PhabricatorRepositorySearchEngine | ||||
|   extends PhabricatorApplicationSearchEngine { | ||||
|  | ||||
|   public function buildSavedQueryFromRequest(AphrontRequest $request) { | ||||
|     $saved = new PhabricatorSavedQuery(); | ||||
|  | ||||
|     $saved->setParameter('callsigns', $request->getStrList('callsigns')); | ||||
|  | ||||
|     return $saved; | ||||
|   } | ||||
|  | ||||
|   public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { | ||||
|     $query = id(new PhabricatorRepositoryQuery()) | ||||
|       ->needCommitCounts(true) | ||||
|       ->needMostRecentCommits(true); | ||||
|  | ||||
|     $callsigns = $saved->getParameter('callsigns'); | ||||
|     if ($callsigns) { | ||||
|       $query->withCallsigns($callsigns); | ||||
|     } | ||||
|  | ||||
|     return $query; | ||||
|   } | ||||
|  | ||||
|   public function buildSearchForm( | ||||
|     AphrontFormView $form, | ||||
|     PhabricatorSavedQuery $saved_query) { | ||||
|  | ||||
|     $callsigns = $saved_query->getParameter('callsigns', array()); | ||||
|  | ||||
|     $form | ||||
|       ->appendChild( | ||||
|         id(new AphrontFormTextControl()) | ||||
|           ->setName('callsigns') | ||||
|           ->setLabel(pht('Callsigns')) | ||||
|           ->setValue(implode(', ', $callsigns))); | ||||
|   } | ||||
|  | ||||
|   protected function getURI($path) { | ||||
|     return '/diffusion/'.$path; | ||||
|   } | ||||
|  | ||||
|   public function getBuiltinQueryNames() { | ||||
|     $names = array( | ||||
|       'all' => pht('All Repositories'), | ||||
|     ); | ||||
|  | ||||
|     return $names; | ||||
|   } | ||||
|  | ||||
|   public function buildSavedQueryFromBuiltin($query_key) { | ||||
|  | ||||
|     $query = $this->newSavedQuery(); | ||||
|     $query->setQueryKey($query_key); | ||||
|  | ||||
|     switch ($query_key) { | ||||
|       case 'all': | ||||
|         return $query; | ||||
|     } | ||||
|  | ||||
|     return parent::buildSavedQueryFromBuiltin($query_key); | ||||
|   } | ||||
|  | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 epriestley
					epriestley