diff --git a/src/applications/dashboard/query/PhabricatorDashboardPanelQuery.php b/src/applications/dashboard/query/PhabricatorDashboardPanelQuery.php index 242e4d22bc..9641f33338 100644 --- a/src/applications/dashboard/query/PhabricatorDashboardPanelQuery.php +++ b/src/applications/dashboard/query/PhabricatorDashboardPanelQuery.php @@ -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); diff --git a/src/applications/dashboard/query/PhabricatorDashboardPanelSearchEngine.php b/src/applications/dashboard/query/PhabricatorDashboardPanelSearchEngine.php index 229250a55c..2fee57c94e 100644 --- a/src/applications/dashboard/query/PhabricatorDashboardPanelSearchEngine.php +++ b/src/applications/dashboard/query/PhabricatorDashboardPanelSearchEngine.php @@ -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) {