@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+33 -26
+20 -6
src/applications/paste/controller/PhabricatorPasteListController.php
··· 58 58 $list->setNoDataString(pht("No results found for this query.")); 59 59 60 60 if ($this->queryKey !== null || $filter == "filter/advanced") { 61 - $form = $engine->buildSearchForm($saved_query); 62 - $nav->appendChild($form); 61 + $form = id(new AphrontFormView()) 62 + ->setNoShading(true) 63 + ->setUser($user); 64 + 65 + $engine->buildSearchForm($form, $saved_query); 66 + 67 + $submit = id(new AphrontFormSubmitControl()) 68 + ->setValue(pht('Execute Query')); 69 + 70 + if ($filter == 'filter/advanced') { 71 + $submit->addCancelButton( 72 + '/search/edit/'.$saved_query->getQueryKey().'/', 73 + pht('Save Custom Query...')); 74 + } 75 + 76 + $form->appendChild($submit); 77 + 78 + $filter_view = id(new AphrontListFilterView())->appendChild($form); 79 + $nav->appendChild($filter_view); 63 80 } 64 81 65 - $nav->appendChild( 66 - array( 67 - $list, 68 - )); 82 + $nav->appendChild($list); 69 83 70 84 $crumbs = $this 71 85 ->buildApplicationCrumbs($nav)
+9 -19
src/applications/paste/query/PhabricatorPasteSearchEngine.php
··· 18 18 $saved = new PhabricatorSavedQuery(); 19 19 $saved->setParameter( 20 20 'authorPHIDs', 21 - array_values($request->getArr('set_users'))); 21 + array_values($request->getArr('authors'))); 22 22 23 23 try { 24 24 $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); ··· 53 53 * @param PhabricatorSavedQuery The query to populate the form with. 54 54 * @return AphrontFormView The built form. 55 55 */ 56 - public function buildSearchForm(PhabricatorSavedQuery $saved_query) { 56 + public function buildSearchForm( 57 + AphrontFormView $form, 58 + PhabricatorSavedQuery $saved_query) { 57 59 $phids = $saved_query->getParameter('authorPHIDs', array()); 58 60 $handles = id(new PhabricatorObjectHandleData($phids)) 59 61 ->setViewer($this->requireViewer()) 60 62 ->loadHandles(); 61 - $users_searched = mpull($handles, 'getFullName', 'getPHID'); 62 - 63 - $form = id(new AphrontFormView()) 64 - ->setUser($this->requireViewer()); 63 + $author_tokens = mpull($handles, 'getFullName', 'getPHID'); 65 64 66 65 $form->appendChild( 67 66 id(new AphrontFormTokenizerControl()) 68 - ->setDatasource('/typeahead/common/searchowner/') 69 - ->setName('set_users') 70 - ->setLabel(pht('Users')) 71 - ->setValue($users_searched)); 72 - 73 - $form->appendChild( 74 - id(new AphrontFormSubmitControl()) 75 - ->setValue(pht('Query')) 76 - ->addCancelButton( 77 - '/search/edit/'.$saved_query->getQueryKey().'/', 78 - pht('Save Custom Query...'))); 79 - 80 - return $form; 67 + ->setDatasource('/typeahead/common/users/') 68 + ->setName('authors') 69 + ->setLabel(pht('Authors')) 70 + ->setValue($author_tokens)); 81 71 } 82 72 83 73 public function getQueryResultsPageURI($query_key) {
+4 -1
src/applications/search/engine/PhabricatorApplicationSearchEngine.php
··· 46 46 /** 47 47 * Builds the search form using the request. 48 48 * 49 + * @param AphrontFormView Form to populate. 49 50 * @param PhabricatorSavedQuery The query from which to build the form. 50 51 * @return void 51 52 */ 52 - abstract public function buildSearchForm(PhabricatorSavedQuery $query); 53 + abstract public function buildSearchForm( 54 + AphrontFormView $form, 55 + PhabricatorSavedQuery $query); 53 56 54 57 55 58 /**