mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 12:00:55 +01:00
Add Dashboard typeaheads
Summary: Builds a basic typeahead for Dashboards and Panels Test Plan: `/typeahead/browse/PhabricatorDashboardPanelDatasource/` Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D17064
This commit is contained in:
parent
92db64c1b2
commit
0387d62632
3 changed files with 89 additions and 0 deletions
|
@ -2448,6 +2448,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorDashboardDAO' => 'applications/dashboard/storage/PhabricatorDashboardDAO.php',
|
||||
'PhabricatorDashboardDashboardHasPanelEdgeType' => 'applications/dashboard/edge/PhabricatorDashboardDashboardHasPanelEdgeType.php',
|
||||
'PhabricatorDashboardDashboardPHIDType' => 'applications/dashboard/phid/PhabricatorDashboardDashboardPHIDType.php',
|
||||
'PhabricatorDashboardDatasource' => 'applications/dashboard/typeahead/PhabricatorDashboardDatasource.php',
|
||||
'PhabricatorDashboardEditController' => 'applications/dashboard/controller/PhabricatorDashboardEditController.php',
|
||||
'PhabricatorDashboardIconSet' => 'applications/dashboard/icon/PhabricatorDashboardIconSet.php',
|
||||
'PhabricatorDashboardInstall' => 'applications/dashboard/storage/PhabricatorDashboardInstall.php',
|
||||
|
@ -2460,6 +2461,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorDashboardPanelArchiveController' => 'applications/dashboard/controller/PhabricatorDashboardPanelArchiveController.php',
|
||||
'PhabricatorDashboardPanelCoreCustomField' => 'applications/dashboard/customfield/PhabricatorDashboardPanelCoreCustomField.php',
|
||||
'PhabricatorDashboardPanelCustomField' => 'applications/dashboard/customfield/PhabricatorDashboardPanelCustomField.php',
|
||||
'PhabricatorDashboardPanelDatasource' => 'applications/dashboard/typeahead/PhabricatorDashboardPanelDatasource.php',
|
||||
'PhabricatorDashboardPanelEditConduitAPIMethod' => 'applications/dashboard/conduit/PhabricatorDashboardPanelEditConduitAPIMethod.php',
|
||||
'PhabricatorDashboardPanelEditController' => 'applications/dashboard/controller/PhabricatorDashboardPanelEditController.php',
|
||||
'PhabricatorDashboardPanelEditEngine' => 'applications/dashboard/editor/PhabricatorDashboardPanelEditEngine.php',
|
||||
|
@ -7412,6 +7414,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorDashboardDAO' => 'PhabricatorLiskDAO',
|
||||
'PhabricatorDashboardDashboardHasPanelEdgeType' => 'PhabricatorEdgeType',
|
||||
'PhabricatorDashboardDashboardPHIDType' => 'PhabricatorPHIDType',
|
||||
'PhabricatorDashboardDatasource' => 'PhabricatorTypeaheadDatasource',
|
||||
'PhabricatorDashboardEditController' => 'PhabricatorDashboardController',
|
||||
'PhabricatorDashboardIconSet' => 'PhabricatorIconSet',
|
||||
'PhabricatorDashboardInstall' => 'PhabricatorDashboardDAO',
|
||||
|
@ -7434,6 +7437,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorStandardCustomFieldInterface',
|
||||
),
|
||||
'PhabricatorDashboardPanelCustomField' => 'PhabricatorCustomField',
|
||||
'PhabricatorDashboardPanelDatasource' => 'PhabricatorTypeaheadDatasource',
|
||||
'PhabricatorDashboardPanelEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod',
|
||||
'PhabricatorDashboardPanelEditController' => 'PhabricatorDashboardController',
|
||||
'PhabricatorDashboardPanelEditEngine' => 'PhabricatorEditEngine',
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorDashboardDatasource
|
||||
extends PhabricatorTypeaheadDatasource {
|
||||
|
||||
public function getBrowseTitle() {
|
||||
return pht('Browse Dashboards');
|
||||
}
|
||||
|
||||
public function getPlaceholderText() {
|
||||
return pht('Type a dashboard name...');
|
||||
}
|
||||
|
||||
public function getDatasourceApplicationClass() {
|
||||
return 'PhabricatorDashboardApplication';
|
||||
}
|
||||
|
||||
public function loadResults() {
|
||||
$query = id(new PhabricatorDashboardQuery());
|
||||
|
||||
$dashboards = $this->executeQuery($query);
|
||||
$results = array();
|
||||
foreach ($dashboards as $dashboard) {
|
||||
$result = id(new PhabricatorTypeaheadResult())
|
||||
->setName($dashboard->getName())
|
||||
->setPHID($dashboard->getPHID())
|
||||
->addAttribute(pht('Dashboard'));
|
||||
|
||||
if ($dashboard->isArchived()) {
|
||||
$result->setClosed(pht('Archived'));
|
||||
}
|
||||
|
||||
$results[] = $result;
|
||||
}
|
||||
|
||||
return $this->filterResultsAgainstTokens($results);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorDashboardPanelDatasource
|
||||
extends PhabricatorTypeaheadDatasource {
|
||||
|
||||
public function getBrowseTitle() {
|
||||
return pht('Browse Dashboard Panels');
|
||||
}
|
||||
|
||||
public function getPlaceholderText() {
|
||||
return pht('Type a panel name...');
|
||||
}
|
||||
|
||||
public function getDatasourceApplicationClass() {
|
||||
return 'PhabricatorDashboardApplication';
|
||||
}
|
||||
|
||||
public function loadResults() {
|
||||
$query = id(new PhabricatorDashboardPanelQuery());
|
||||
|
||||
$panels = $this->executeQuery($query);
|
||||
$results = array();
|
||||
foreach ($panels as $panel) {
|
||||
$impl = $panel->getImplementation();
|
||||
if ($impl) {
|
||||
$type_text = $impl->getPanelTypeName();
|
||||
} else {
|
||||
$type_text = nonempty($panel->getPanelType(), pht('Unknown Type'));
|
||||
}
|
||||
|
||||
$result = id(new PhabricatorTypeaheadResult())
|
||||
->setName($panel->getName())
|
||||
->setPHID($panel->getPHID())
|
||||
->addAttribute($type_text);
|
||||
|
||||
if ($panel->getIsArchived()) {
|
||||
$result->setClosed(pht('Archived'));
|
||||
}
|
||||
|
||||
$results[] = $result;
|
||||
}
|
||||
|
||||
return $this->filterResultsAgainstTokens($results);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue