mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-28 17:52:43 +01:00
6be53bd916
Summary: Making an attempt here. This adds the ability to set Projects on Dashboards and Dashboard Panels. Most of this went smooth, but I can't figure out why the queries don't automatically show searching by Projects. I'm stumped. Rest seems fine. Test Plan: Assign a Project to a Dashboard and a Panel, see Project show up, edit it, see transactions. Reviewers: btrahan, epriestley Reviewed By: epriestley Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D13656
125 lines
3 KiB
PHP
125 lines
3 KiB
PHP
<?php
|
|
|
|
final class PhabricatorDashboardPanelSearchEngine
|
|
extends PhabricatorApplicationSearchEngine {
|
|
|
|
public function getResultTypeDescription() {
|
|
return pht('Dashboard Panels');
|
|
}
|
|
|
|
public function getApplicationClassName() {
|
|
return 'PhabricatorDashboardApplication';
|
|
}
|
|
|
|
public function newQuery() {
|
|
return new PhabricatorDashboardPanelQuery();
|
|
}
|
|
|
|
protected function buildQueryFromParameters(array $map) {
|
|
$query = $this->newQuery();
|
|
if ($map['status']) {
|
|
switch ($map['status']) {
|
|
case 'active':
|
|
$query->withArchived(false);
|
|
break;
|
|
case 'archived':
|
|
$query->withArchived(true);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
if ($map['paneltype']) {
|
|
$query->withPanelTypes(array($map['paneltype']));
|
|
}
|
|
|
|
return $query;
|
|
}
|
|
|
|
protected function buildCustomSearchFields() {
|
|
|
|
return array(
|
|
id(new PhabricatorSearchSelectField())
|
|
->setKey('status')
|
|
->setLabel(pht('Status'))
|
|
->setOptions(
|
|
id(new PhabricatorDashboardPanel())
|
|
->getStatuses()),
|
|
id(new PhabricatorSearchSelectField())
|
|
->setKey('paneltype')
|
|
->setLabel(pht('Panel Type'))
|
|
->setOptions(
|
|
id(new PhabricatorDashboardPanel())
|
|
->getPanelTypes()),
|
|
);
|
|
}
|
|
|
|
protected function getURI($path) {
|
|
return '/dashboard/panel/'.$path;
|
|
}
|
|
|
|
protected function getBuiltinQueryNames() {
|
|
return array(
|
|
'active' => pht('Active Panels'),
|
|
'all' => pht('All Panels'),
|
|
);
|
|
}
|
|
|
|
public function buildSavedQueryFromBuiltin($query_key) {
|
|
$query = $this->newSavedQuery();
|
|
$query->setQueryKey($query_key);
|
|
|
|
switch ($query_key) {
|
|
case 'active':
|
|
return $query->setParameter('status', 'active');
|
|
case 'all':
|
|
return $query;
|
|
}
|
|
|
|
return parent::buildSavedQueryFromBuiltin($query_key);
|
|
}
|
|
|
|
protected function renderResultList(
|
|
array $panels,
|
|
PhabricatorSavedQuery $query,
|
|
array $handles) {
|
|
|
|
$viewer = $this->requireViewer();
|
|
|
|
$list = new PHUIObjectItemListView();
|
|
$list->setUser($viewer);
|
|
foreach ($panels as $panel) {
|
|
$item = id(new PHUIObjectItemView())
|
|
->setObjectName($panel->getMonogram())
|
|
->setHeader($panel->getName())
|
|
->setHref('/'.$panel->getMonogram())
|
|
->setObject($panel);
|
|
|
|
$impl = $panel->getImplementation();
|
|
if ($impl) {
|
|
$type_text = $impl->getPanelTypeName();
|
|
} else {
|
|
$type_text = nonempty($panel->getPanelType(), pht('Unknown Type'));
|
|
}
|
|
$item->addAttribute($type_text);
|
|
|
|
$properties = $panel->getProperties();
|
|
$class = idx($properties, 'class');
|
|
$item->addAttribute($class);
|
|
|
|
if ($panel->getIsArchived()) {
|
|
$item->setDisabled(true);
|
|
}
|
|
|
|
$list->addItem($item);
|
|
}
|
|
|
|
$result = new PhabricatorApplicationSearchResultView();
|
|
$result->setObjectList($list);
|
|
$result->setNoDataString(pht('No panels found.'));
|
|
|
|
return $result;
|
|
}
|
|
|
|
}
|