1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-10 23:01:04 +01:00

Reduce responsibilities of PhabricatorPasteSearchEngine->buildSearchForm()

Summary:
Ref T2625. The specialized buildSearchForm() method has significant amounts of generic form construction responsibility right now. Lift the generic stuff above the Engine level. Also:

  - Rename "users" to "authors".
  - Use "users", not "searchowners" (which incorrectly includes "upforgrabs").
  - No need for "set_" prefixes anymore since we do GET redirects with query keys.
  - Use newer style for search stuff.

Test Plan:
Searched for stuff?

{F44342}

Reviewers: btrahan, blc

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2625

Differential Revision: https://secure.phabricator.com/D6061
This commit is contained in:
epriestley 2013-05-27 13:43:47 -07:00
parent a67b1f950c
commit 764e4574d1
3 changed files with 33 additions and 26 deletions

View file

@ -58,14 +58,28 @@ final class PhabricatorPasteListController extends PhabricatorPasteController {
$list->setNoDataString(pht("No results found for this query.")); $list->setNoDataString(pht("No results found for this query."));
if ($this->queryKey !== null || $filter == "filter/advanced") { if ($this->queryKey !== null || $filter == "filter/advanced") {
$form = $engine->buildSearchForm($saved_query); $form = id(new AphrontFormView())
$nav->appendChild($form); ->setNoShading(true)
->setUser($user);
$engine->buildSearchForm($form, $saved_query);
$submit = id(new AphrontFormSubmitControl())
->setValue(pht('Execute Query'));
if ($filter == 'filter/advanced') {
$submit->addCancelButton(
'/search/edit/'.$saved_query->getQueryKey().'/',
pht('Save Custom Query...'));
}
$form->appendChild($submit);
$filter_view = id(new AphrontListFilterView())->appendChild($form);
$nav->appendChild($filter_view);
} }
$nav->appendChild( $nav->appendChild($list);
array(
$list,
));
$crumbs = $this $crumbs = $this
->buildApplicationCrumbs($nav) ->buildApplicationCrumbs($nav)

View file

@ -18,7 +18,7 @@ final class PhabricatorPasteSearchEngine
$saved = new PhabricatorSavedQuery(); $saved = new PhabricatorSavedQuery();
$saved->setParameter( $saved->setParameter(
'authorPHIDs', 'authorPHIDs',
array_values($request->getArr('set_users'))); array_values($request->getArr('authors')));
try { try {
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
@ -53,31 +53,21 @@ final class PhabricatorPasteSearchEngine
* @param PhabricatorSavedQuery The query to populate the form with. * @param PhabricatorSavedQuery The query to populate the form with.
* @return AphrontFormView The built form. * @return AphrontFormView The built form.
*/ */
public function buildSearchForm(PhabricatorSavedQuery $saved_query) { public function buildSearchForm(
AphrontFormView $form,
PhabricatorSavedQuery $saved_query) {
$phids = $saved_query->getParameter('authorPHIDs', array()); $phids = $saved_query->getParameter('authorPHIDs', array());
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorObjectHandleData($phids))
->setViewer($this->requireViewer()) ->setViewer($this->requireViewer())
->loadHandles(); ->loadHandles();
$users_searched = mpull($handles, 'getFullName', 'getPHID'); $author_tokens = mpull($handles, 'getFullName', 'getPHID');
$form = id(new AphrontFormView())
->setUser($this->requireViewer());
$form->appendChild( $form->appendChild(
id(new AphrontFormTokenizerControl()) id(new AphrontFormTokenizerControl())
->setDatasource('/typeahead/common/searchowner/') ->setDatasource('/typeahead/common/users/')
->setName('set_users') ->setName('authors')
->setLabel(pht('Users')) ->setLabel(pht('Authors'))
->setValue($users_searched)); ->setValue($author_tokens));
$form->appendChild(
id(new AphrontFormSubmitControl())
->setValue(pht('Query'))
->addCancelButton(
'/search/edit/'.$saved_query->getQueryKey().'/',
pht('Save Custom Query...')));
return $form;
} }
public function getQueryResultsPageURI($query_key) { public function getQueryResultsPageURI($query_key) {

View file

@ -46,10 +46,13 @@ abstract class PhabricatorApplicationSearchEngine {
/** /**
* Builds the search form using the request. * Builds the search form using the request.
* *
* @param AphrontFormView Form to populate.
* @param PhabricatorSavedQuery The query from which to build the form. * @param PhabricatorSavedQuery The query from which to build the form.
* @return void * @return void
*/ */
abstract public function buildSearchForm(PhabricatorSavedQuery $query); abstract public function buildSearchForm(
AphrontFormView $form,
PhabricatorSavedQuery $query);
/** /**