mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-24 06:20:56 +01:00
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
This commit is contained in:
parent
352d9f6b06
commit
e6aff100f2
7 changed files with 103 additions and 97 deletions
|
@ -4895,11 +4895,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorSearchAttachController' => 'PhabricatorSearchBaseController',
|
'PhabricatorSearchAttachController' => 'PhabricatorSearchBaseController',
|
||||||
'PhabricatorSearchBaseController' => 'PhabricatorController',
|
'PhabricatorSearchBaseController' => 'PhabricatorController',
|
||||||
'PhabricatorSearchConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
'PhabricatorSearchConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
||||||
'PhabricatorSearchController' =>
|
'PhabricatorSearchController' => 'PhabricatorSearchBaseController',
|
||||||
array(
|
|
||||||
0 => 'PhabricatorSearchBaseController',
|
|
||||||
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
|
|
||||||
),
|
|
||||||
'PhabricatorSearchDAO' => 'PhabricatorLiskDAO',
|
'PhabricatorSearchDAO' => 'PhabricatorLiskDAO',
|
||||||
'PhabricatorSearchDeleteController' => 'PhabricatorSearchBaseController',
|
'PhabricatorSearchDeleteController' => 'PhabricatorSearchBaseController',
|
||||||
'PhabricatorSearchDocument' => 'PhabricatorSearchDAO',
|
'PhabricatorSearchDocument' => 'PhabricatorSearchDAO',
|
||||||
|
@ -5524,11 +5520,7 @@ phutil_register_library_map(array(
|
||||||
'ReleephProductEditController' => 'ReleephProductController',
|
'ReleephProductEditController' => 'ReleephProductController',
|
||||||
'ReleephProductEditor' => 'PhabricatorApplicationTransactionEditor',
|
'ReleephProductEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||||
'ReleephProductHistoryController' => 'ReleephProductController',
|
'ReleephProductHistoryController' => 'ReleephProductController',
|
||||||
'ReleephProductListController' =>
|
'ReleephProductListController' => 'ReleephController',
|
||||||
array(
|
|
||||||
0 => 'ReleephController',
|
|
||||||
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
|
|
||||||
),
|
|
||||||
'ReleephProductQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
'ReleephProductQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
'ReleephProductSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
'ReleephProductSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||||
'ReleephProductTransaction' => 'PhabricatorApplicationTransaction',
|
'ReleephProductTransaction' => 'PhabricatorApplicationTransaction',
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class DiffusionPushLogListController extends DiffusionPushLogController {
|
final class DiffusionPushLogListController extends DiffusionPushLogController
|
||||||
|
implements PhabricatorApplicationSearchResultsControllerInterface {
|
||||||
|
|
||||||
private $queryKey;
|
private $queryKey;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class ReleephProductListController extends ReleephController
|
final class ReleephProductListController extends ReleephController {
|
||||||
implements PhabricatorApplicationSearchResultsControllerInterface {
|
|
||||||
|
|
||||||
private $queryKey;
|
private $queryKey;
|
||||||
|
|
||||||
|
@ -23,47 +22,6 @@ final class ReleephProductListController extends ReleephController
|
||||||
return $this->delegateToController($controller);
|
return $this->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() {
|
public function buildApplicationCrumbs() {
|
||||||
$crumbs = parent::buildApplicationCrumbs();
|
$crumbs = parent::buildApplicationCrumbs();
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,10 @@
|
||||||
final class ReleephProductSearchEngine
|
final class ReleephProductSearchEngine
|
||||||
extends PhabricatorApplicationSearchEngine {
|
extends PhabricatorApplicationSearchEngine {
|
||||||
|
|
||||||
|
public function getApplicationClassName() {
|
||||||
|
return 'PhabricatorApplicationReleeph';
|
||||||
|
}
|
||||||
|
|
||||||
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
||||||
$saved = new PhabricatorSavedQuery();
|
$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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,10 @@
|
||||||
final class PhabricatorRepositoryPushLogSearchEngine
|
final class PhabricatorRepositoryPushLogSearchEngine
|
||||||
extends PhabricatorApplicationSearchEngine {
|
extends PhabricatorApplicationSearchEngine {
|
||||||
|
|
||||||
|
public function getApplicationClassName() {
|
||||||
|
return 'PhabricatorApplicationDiffusion';
|
||||||
|
}
|
||||||
|
|
||||||
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
||||||
$saved = new PhabricatorSavedQuery();
|
$saved = new PhabricatorSavedQuery();
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class PhabricatorSearchController
|
final class PhabricatorSearchController
|
||||||
extends PhabricatorSearchBaseController
|
extends PhabricatorSearchBaseController {
|
||||||
implements PhabricatorApplicationSearchResultsControllerInterface {
|
|
||||||
|
|
||||||
private $queryKey;
|
private $queryKey;
|
||||||
|
|
||||||
|
@ -96,45 +95,4 @@ final class PhabricatorSearchController
|
||||||
return $nav;
|
return $nav;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function renderResultsList(
|
|
||||||
array $results,
|
|
||||||
PhabricatorSavedQuery $query) {
|
|
||||||
|
|
||||||
$viewer = $this->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');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,10 @@
|
||||||
final class PhabricatorSearchApplicationSearchEngine
|
final class PhabricatorSearchApplicationSearchEngine
|
||||||
extends PhabricatorApplicationSearchEngine {
|
extends PhabricatorApplicationSearchEngine {
|
||||||
|
|
||||||
|
public function getApplicationClassName() {
|
||||||
|
return 'PhabricatorApplicationSearch';
|
||||||
|
}
|
||||||
|
|
||||||
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
||||||
$saved = new PhabricatorSavedQuery();
|
$saved = new PhabricatorSavedQuery();
|
||||||
|
|
||||||
|
@ -233,5 +237,46 @@ final class PhabricatorSearchApplicationSearchEngine
|
||||||
return true;
|
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');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue