mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 13:30: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:
parent
b4d03bb26c
commit
0b2697bb92
2 changed files with 32 additions and 1 deletions
|
@ -6,6 +6,7 @@ final class PhabricatorDashboardPanelQuery
|
|||
private $ids;
|
||||
private $phids;
|
||||
private $archived;
|
||||
private $panelTypes;
|
||||
|
||||
public function withIDs(array $ids) {
|
||||
$this->ids = $ids;
|
||||
|
@ -22,6 +23,11 @@ final class PhabricatorDashboardPanelQuery
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function withPanelTypes(array $types) {
|
||||
$this->panelTypes = $types;
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function loadPage() {
|
||||
$table = new PhabricatorDashboardPanel();
|
||||
$conn_r = $table->establishConnection('r');
|
||||
|
@ -61,6 +67,13 @@ final class PhabricatorDashboardPanelQuery
|
|||
(int)$this->archived);
|
||||
}
|
||||
|
||||
if ($this->panelTypes !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'panelType IN (%Ls)',
|
||||
$this->panelTypes);
|
||||
}
|
||||
|
||||
$where[] = $this->buildPagingClause($conn_r);
|
||||
|
||||
return $this->formatWhereClause($where);
|
||||
|
|
|
@ -14,6 +14,7 @@ final class PhabricatorDashboardPanelSearchEngine
|
|||
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
||||
$saved = new PhabricatorSavedQuery();
|
||||
$saved->setParameter('status', $request->getStr('status'));
|
||||
$saved->setParameter('paneltype', $request->getStr('paneltype'));
|
||||
return $saved;
|
||||
}
|
||||
|
||||
|
@ -32,6 +33,11 @@ final class PhabricatorDashboardPanelSearchEngine
|
|||
break;
|
||||
}
|
||||
|
||||
$paneltype = $saved->getParameter('paneltype');
|
||||
if ($paneltype) {
|
||||
$query->withPanelTypes(array($paneltype));
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
@ -40,6 +46,12 @@ final class PhabricatorDashboardPanelSearchEngine
|
|||
PhabricatorSavedQuery $saved_query) {
|
||||
|
||||
$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
|
||||
->appendChild(
|
||||
|
@ -52,7 +64,13 @@ final class PhabricatorDashboardPanelSearchEngine
|
|||
'' => pht('(All Panels)'),
|
||||
'active' => pht('Active Panels'),
|
||||
'archived' => pht('Archived Panels'),
|
||||
)));
|
||||
)))
|
||||
->appendChild(
|
||||
id(new AphrontFormSelectControl())
|
||||
->setLabel(pht('Panel Type'))
|
||||
->setName('paneltype')
|
||||
->setValue($paneltype)
|
||||
->setOptions($panel_types));
|
||||
}
|
||||
|
||||
protected function getURI($path) {
|
||||
|
|
Loading…
Reference in a new issue