1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Move dashboard list rendering to ApplicationSearch

Summary: Ref T4986. This is "good" and "desirable".

Test Plan: Saw dashboard list, panel.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4986

Differential Revision: https://secure.phabricator.com/D9015
This commit is contained in:
epriestley 2014-05-08 09:31:33 -07:00
parent 46405064e9
commit c6a68aadc0
2 changed files with 31 additions and 24 deletions

View file

@ -1,10 +1,10 @@
<?php <?php
final class PhabricatorDashboardListController final class PhabricatorDashboardListController
extends PhabricatorDashboardController extends PhabricatorDashboardController {
implements PhabricatorApplicationSearchResultsControllerInterface {
private $queryKey; private $queryKey;
public function willProcessRequest(array $data) { public function willProcessRequest(array $data) {
$this->queryKey = idx($data, 'queryKey'); $this->queryKey = idx($data, 'queryKey');
} }
@ -48,26 +48,4 @@ final class PhabricatorDashboardListController
return $crumbs; return $crumbs;
} }
public function renderResultsList(
array $dashboards,
PhabricatorSavedQuery $query) {
$viewer = $this->getRequest()->getUser();
$list = new PHUIObjectItemListView();
$list->setUser($viewer);
foreach ($dashboards as $dashboard) {
$id = $dashboard->getID();
$item = id(new PHUIObjectItemView())
->setObjectName(pht('Dashboard %d', $id))
->setHeader($dashboard->getName())
->setHref($this->getApplicationURI("view/{$id}/"))
->setObject($dashboard);
$list->addItem($item);
}
return $list;
}
} }

View file

@ -3,6 +3,10 @@
final class PhabricatorDashboardSearchEngine final class PhabricatorDashboardSearchEngine
extends PhabricatorApplicationSearchEngine { extends PhabricatorApplicationSearchEngine {
public function getApplicationClassName() {
return 'PhabricatorApplicationDashboard';
}
public function buildSavedQueryFromRequest(AphrontRequest $request) { public function buildSavedQueryFromRequest(AphrontRequest $request) {
$saved = new PhabricatorSavedQuery(); $saved = new PhabricatorSavedQuery();
@ -46,4 +50,29 @@ final class PhabricatorDashboardSearchEngine
return parent::buildSavedQueryFromBuiltin($query_key); return parent::buildSavedQueryFromBuiltin($query_key);
} }
protected function renderResultList(
array $dashboards,
PhabricatorSavedQuery $query,
array $handles) {
$viewer = $this->requireViewer();
$list = new PHUIObjectItemListView();
$list->setUser($viewer);
foreach ($dashboards as $dashboard) {
$id = $dashboard->getID();
$item = id(new PHUIObjectItemView())
->setObjectName(pht('Dashboard %d', $id))
->setHeader($dashboard->getName())
->setHref($this->getApplicationURI("view/{$id}/"))
->setObject($dashboard);
$list->addItem($item);
}
return $list;
}
} }