1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-22 21:40:55 +01:00

Add ability to query dashboard panels by paneltype

Summary: Pretty basic, but you can now search panels by type (query, text, tab).

Test Plan: Searched for a few different types of panels, results look correct

Reviewers: btrahan, epriestley

Reviewed By: epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11782
This commit is contained in:
Chad Little 2015-02-18 10:50:37 -08:00
parent b4d03bb26c
commit 0b2697bb92
2 changed files with 32 additions and 1 deletions

View file

@ -6,6 +6,7 @@ final class PhabricatorDashboardPanelQuery
private $ids; private $ids;
private $phids; private $phids;
private $archived; private $archived;
private $panelTypes;
public function withIDs(array $ids) { public function withIDs(array $ids) {
$this->ids = $ids; $this->ids = $ids;
@ -22,6 +23,11 @@ final class PhabricatorDashboardPanelQuery
return $this; return $this;
} }
public function withPanelTypes(array $types) {
$this->panelTypes = $types;
return $this;
}
protected function loadPage() { protected function loadPage() {
$table = new PhabricatorDashboardPanel(); $table = new PhabricatorDashboardPanel();
$conn_r = $table->establishConnection('r'); $conn_r = $table->establishConnection('r');
@ -61,6 +67,13 @@ final class PhabricatorDashboardPanelQuery
(int)$this->archived); (int)$this->archived);
} }
if ($this->panelTypes !== null) {
$where[] = qsprintf(
$conn_r,
'panelType IN (%Ls)',
$this->panelTypes);
}
$where[] = $this->buildPagingClause($conn_r); $where[] = $this->buildPagingClause($conn_r);
return $this->formatWhereClause($where); return $this->formatWhereClause($where);

View file

@ -14,6 +14,7 @@ final class PhabricatorDashboardPanelSearchEngine
public function buildSavedQueryFromRequest(AphrontRequest $request) { public function buildSavedQueryFromRequest(AphrontRequest $request) {
$saved = new PhabricatorSavedQuery(); $saved = new PhabricatorSavedQuery();
$saved->setParameter('status', $request->getStr('status')); $saved->setParameter('status', $request->getStr('status'));
$saved->setParameter('paneltype', $request->getStr('paneltype'));
return $saved; return $saved;
} }
@ -32,6 +33,11 @@ final class PhabricatorDashboardPanelSearchEngine
break; break;
} }
$paneltype = $saved->getParameter('paneltype');
if ($paneltype) {
$query->withPanelTypes(array($paneltype));
}
return $query; return $query;
} }
@ -40,6 +46,12 @@ final class PhabricatorDashboardPanelSearchEngine
PhabricatorSavedQuery $saved_query) { PhabricatorSavedQuery $saved_query) {
$status = $saved_query->getParameter('status', ''); $status = $saved_query->getParameter('status', '');
$paneltype = $saved_query->getParameter('paneltype', '');
$panel_types = PhabricatorDashboardPanelType::getAllPanelTypes();
$panel_types = mpull($panel_types, 'getPanelTypeName', 'getPanelTypeKey');
asort($panel_types);
$panel_types = (array('' => pht('(All Types)')) + $panel_types);
$form $form
->appendChild( ->appendChild(
@ -52,7 +64,13 @@ final class PhabricatorDashboardPanelSearchEngine
'' => pht('(All Panels)'), '' => pht('(All Panels)'),
'active' => pht('Active Panels'), 'active' => pht('Active Panels'),
'archived' => pht('Archived Panels'), 'archived' => pht('Archived Panels'),
))); )))
->appendChild(
id(new AphrontFormSelectControl())
->setLabel(pht('Panel Type'))
->setName('paneltype')
->setValue($paneltype)
->setOptions($panel_types));
} }
protected function getURI($path) { protected function getURI($path) {