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:
@@ -58,14 +58,28 @@ final class PhabricatorPasteListController extends PhabricatorPasteController {
|
||||
$list->setNoDataString(pht("No results found for this query."));
|
||||
|
||||
if ($this->queryKey !== null || $filter == "filter/advanced") {
|
||||
$form = $engine->buildSearchForm($saved_query);
|
||||
$nav->appendChild($form);
|
||||
$form = id(new AphrontFormView())
|
||||
->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(
|
||||
array(
|
||||
$list,
|
||||
));
|
||||
$nav->appendChild($list);
|
||||
|
||||
$crumbs = $this
|
||||
->buildApplicationCrumbs($nav)
|
||||
|
||||
@@ -18,7 +18,7 @@ final class PhabricatorPasteSearchEngine
|
||||
$saved = new PhabricatorSavedQuery();
|
||||
$saved->setParameter(
|
||||
'authorPHIDs',
|
||||
array_values($request->getArr('set_users')));
|
||||
array_values($request->getArr('authors')));
|
||||
|
||||
try {
|
||||
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
|
||||
@@ -53,31 +53,21 @@ final class PhabricatorPasteSearchEngine
|
||||
* @param PhabricatorSavedQuery The query to populate the form with.
|
||||
* @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());
|
||||
$handles = id(new PhabricatorObjectHandleData($phids))
|
||||
->setViewer($this->requireViewer())
|
||||
->loadHandles();
|
||||
$users_searched = mpull($handles, 'getFullName', 'getPHID');
|
||||
|
||||
$form = id(new AphrontFormView())
|
||||
->setUser($this->requireViewer());
|
||||
$author_tokens = mpull($handles, 'getFullName', 'getPHID');
|
||||
|
||||
$form->appendChild(
|
||||
id(new AphrontFormTokenizerControl())
|
||||
->setDatasource('/typeahead/common/searchowner/')
|
||||
->setName('set_users')
|
||||
->setLabel(pht('Users'))
|
||||
->setValue($users_searched));
|
||||
|
||||
$form->appendChild(
|
||||
id(new AphrontFormSubmitControl())
|
||||
->setValue(pht('Query'))
|
||||
->addCancelButton(
|
||||
'/search/edit/'.$saved_query->getQueryKey().'/',
|
||||
pht('Save Custom Query...')));
|
||||
|
||||
return $form;
|
||||
->setDatasource('/typeahead/common/users/')
|
||||
->setName('authors')
|
||||
->setLabel(pht('Authors'))
|
||||
->setValue($author_tokens));
|
||||
}
|
||||
|
||||
public function getQueryResultsPageURI($query_key) {
|
||||
|
||||
Reference in New Issue
Block a user