From e6aff100f26875fb3f8eb67df7ae0989c32b96d1 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 9 May 2014 12:28:02 -0700 Subject: [PATCH] Move even more rendering into SearchEngine Summary: Ref T4986. I think this is the last of the easy ones, there are about 10 not-quite-so-trivial ones left. Test Plan: - Viewed app results. - Created panels. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4986 Differential Revision: https://secure.phabricator.com/D9025 --- src/__phutil_library_map__.php | 12 +---- .../DiffusionPushLogListController.php | 3 +- .../product/ReleephProductListController.php | 44 +---------------- .../query/ReleephProductSearchEngine.php | 48 +++++++++++++++++++ ...abricatorRepositoryPushLogSearchEngine.php | 4 ++ .../PhabricatorSearchController.php | 44 +---------------- ...abricatorSearchApplicationSearchEngine.php | 45 +++++++++++++++++ 7 files changed, 103 insertions(+), 97 deletions(-) diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index df17f25db0..df5be45c65 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -4895,11 +4895,7 @@ phutil_register_library_map(array( 'PhabricatorSearchAttachController' => 'PhabricatorSearchBaseController', 'PhabricatorSearchBaseController' => 'PhabricatorController', 'PhabricatorSearchConfigOptions' => 'PhabricatorApplicationConfigOptions', - 'PhabricatorSearchController' => - array( - 0 => 'PhabricatorSearchBaseController', - 1 => 'PhabricatorApplicationSearchResultsControllerInterface', - ), + 'PhabricatorSearchController' => 'PhabricatorSearchBaseController', 'PhabricatorSearchDAO' => 'PhabricatorLiskDAO', 'PhabricatorSearchDeleteController' => 'PhabricatorSearchBaseController', 'PhabricatorSearchDocument' => 'PhabricatorSearchDAO', @@ -5524,11 +5520,7 @@ phutil_register_library_map(array( 'ReleephProductEditController' => 'ReleephProductController', 'ReleephProductEditor' => 'PhabricatorApplicationTransactionEditor', 'ReleephProductHistoryController' => 'ReleephProductController', - 'ReleephProductListController' => - array( - 0 => 'ReleephController', - 1 => 'PhabricatorApplicationSearchResultsControllerInterface', - ), + 'ReleephProductListController' => 'ReleephController', 'ReleephProductQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'ReleephProductSearchEngine' => 'PhabricatorApplicationSearchEngine', 'ReleephProductTransaction' => 'PhabricatorApplicationTransaction', diff --git a/src/applications/diffusion/controller/DiffusionPushLogListController.php b/src/applications/diffusion/controller/DiffusionPushLogListController.php index 26822c64f5..6c8b9ef366 100644 --- a/src/applications/diffusion/controller/DiffusionPushLogListController.php +++ b/src/applications/diffusion/controller/DiffusionPushLogListController.php @@ -1,6 +1,7 @@ delegateToController($controller); } - public function renderResultsList( - array $products, - PhabricatorSavedQuery $query) { - assert_instances_of($products, 'ReleephProject'); - $viewer = $this->getRequest()->getUser(); - - $list = id(new PHUIObjectItemListView()) - ->setUser($viewer); - - foreach ($products as $product) { - $id = $product->getID(); - - $item = id(new PHUIObjectItemView()) - ->setHeader($product->getName()) - ->setHref($this->getApplicationURI("product/{$id}/")); - - if (!$product->getIsActive()) { - $item->setDisabled(true); - $item->addIcon('none', pht('Inactive')); - } - - $repo = $product->getRepository(); - $item->addAttribute( - phutil_tag( - 'a', - array( - 'href' => '/diffusion/'.$repo->getCallsign().'/', - ), - 'r'.$repo->getCallsign())); - - $arc = $product->getArcanistProject(); - if ($arc) { - $item->addAttribute($arc->getName()); - } - - $list->addItem($item); - } - - return $list; - } - public function buildApplicationCrumbs() { $crumbs = parent::buildApplicationCrumbs(); diff --git a/src/applications/releeph/query/ReleephProductSearchEngine.php b/src/applications/releeph/query/ReleephProductSearchEngine.php index 7d054e95cb..23f198139b 100644 --- a/src/applications/releeph/query/ReleephProductSearchEngine.php +++ b/src/applications/releeph/query/ReleephProductSearchEngine.php @@ -3,6 +3,10 @@ final class ReleephProductSearchEngine extends PhabricatorApplicationSearchEngine { + public function getApplicationClassName() { + return 'PhabricatorApplicationReleeph'; + } + public function buildSavedQueryFromRequest(AphrontRequest $request) { $saved = new PhabricatorSavedQuery(); @@ -83,4 +87,48 @@ final class ReleephProductSearchEngine ); } + protected function renderResultList( + array $products, + PhabricatorSavedQuery $query, + array $handles) { + + assert_instances_of($products, 'ReleephProject'); + $viewer = $this->requireViewer(); + + $list = id(new PHUIObjectItemListView()) + ->setUser($viewer); + + foreach ($products as $product) { + $id = $product->getID(); + + $item = id(new PHUIObjectItemView()) + ->setHeader($product->getName()) + ->setHref($this->getApplicationURI("product/{$id}/")); + + if (!$product->getIsActive()) { + $item->setDisabled(true); + $item->addIcon('none', pht('Inactive')); + } + + $repo = $product->getRepository(); + $item->addAttribute( + phutil_tag( + 'a', + array( + 'href' => '/diffusion/'.$repo->getCallsign().'/', + ), + 'r'.$repo->getCallsign())); + + $arc = $product->getArcanistProject(); + if ($arc) { + $item->addAttribute($arc->getName()); + } + + $list->addItem($item); + } + + return $list; + } + + } diff --git a/src/applications/repository/query/PhabricatorRepositoryPushLogSearchEngine.php b/src/applications/repository/query/PhabricatorRepositoryPushLogSearchEngine.php index 938ef48d12..7dace67542 100644 --- a/src/applications/repository/query/PhabricatorRepositoryPushLogSearchEngine.php +++ b/src/applications/repository/query/PhabricatorRepositoryPushLogSearchEngine.php @@ -3,6 +3,10 @@ final class PhabricatorRepositoryPushLogSearchEngine extends PhabricatorApplicationSearchEngine { + public function getApplicationClassName() { + return 'PhabricatorApplicationDiffusion'; + } + public function buildSavedQueryFromRequest(AphrontRequest $request) { $saved = new PhabricatorSavedQuery(); diff --git a/src/applications/search/controller/PhabricatorSearchController.php b/src/applications/search/controller/PhabricatorSearchController.php index 62401bbf49..c6e0745d26 100644 --- a/src/applications/search/controller/PhabricatorSearchController.php +++ b/src/applications/search/controller/PhabricatorSearchController.php @@ -1,8 +1,7 @@ getRequest()->getUser(); - - if ($results) { - $objects = id(new PhabricatorObjectQuery()) - ->setViewer($viewer) - ->withPHIDs(mpull($results, 'getPHID')) - ->execute(); - - $output = array(); - foreach ($results as $phid => $handle) { - $view = id(new PhabricatorSearchResultView()) - ->setHandle($handle) - ->setQuery($query) - ->setObject(idx($objects, $phid)); - $output[] = $view->render(); - } - - $results = phutil_tag_div( - 'phabricator-search-result-list', - $output); - } else { - $results = phutil_tag_div( - 'phabricator-search-result-list', - phutil_tag( - 'p', - array('class' => 'phabricator-search-no-results'), - pht('No search results.'))); - } - - return id(new PHUIBoxView()) - ->addMargin(PHUI::MARGIN_LARGE) - ->addPadding(PHUI::PADDING_LARGE) - ->setBorder(true) - ->appendChild($results) - ->addClass('phabricator-search-result-box'); - } - } diff --git a/src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php b/src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php index 8e73feeb1b..2263b0290d 100644 --- a/src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php +++ b/src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php @@ -3,6 +3,10 @@ final class PhabricatorSearchApplicationSearchEngine extends PhabricatorApplicationSearchEngine { + public function getApplicationClassName() { + return 'PhabricatorApplicationSearch'; + } + public function buildSavedQueryFromRequest(AphrontRequest $request) { $saved = new PhabricatorSavedQuery(); @@ -233,5 +237,46 @@ final class PhabricatorSearchApplicationSearchEngine return true; } + protected function renderResultList( + array $results, + PhabricatorSavedQuery $query, + array $handles) { + + $viewer = $this->requireViewer(); + + if ($results) { + $objects = id(new PhabricatorObjectQuery()) + ->setViewer($viewer) + ->withPHIDs(mpull($results, 'getPHID')) + ->execute(); + + $output = array(); + foreach ($results as $phid => $handle) { + $view = id(new PhabricatorSearchResultView()) + ->setHandle($handle) + ->setQuery($query) + ->setObject(idx($objects, $phid)); + $output[] = $view->render(); + } + + $results = phutil_tag_div( + 'phabricator-search-result-list', + $output); + } else { + $results = phutil_tag_div( + 'phabricator-search-result-list', + phutil_tag( + 'p', + array('class' => 'phabricator-search-no-results'), + pht('No search results.'))); + } + + return id(new PHUIBoxView()) + ->addMargin(PHUI::MARGIN_LARGE) + ->addPadding(PHUI::PADDING_LARGE) + ->setBorder(true) + ->appendChild($results) + ->addClass('phabricator-search-result-box'); + } }