1
0
Fork 0
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:
Chad Little 2016-12-16 08:41:18 -08:00
parent 92db64c1b2
commit 0387d62632
3 changed files with 89 additions and 0 deletions

View file

@ -2448,6 +2448,7 @@ phutil_register_library_map(array(
'PhabricatorDashboardDAO' => 'applications/dashboard/storage/PhabricatorDashboardDAO.php', 'PhabricatorDashboardDAO' => 'applications/dashboard/storage/PhabricatorDashboardDAO.php',
'PhabricatorDashboardDashboardHasPanelEdgeType' => 'applications/dashboard/edge/PhabricatorDashboardDashboardHasPanelEdgeType.php', 'PhabricatorDashboardDashboardHasPanelEdgeType' => 'applications/dashboard/edge/PhabricatorDashboardDashboardHasPanelEdgeType.php',
'PhabricatorDashboardDashboardPHIDType' => 'applications/dashboard/phid/PhabricatorDashboardDashboardPHIDType.php', 'PhabricatorDashboardDashboardPHIDType' => 'applications/dashboard/phid/PhabricatorDashboardDashboardPHIDType.php',
'PhabricatorDashboardDatasource' => 'applications/dashboard/typeahead/PhabricatorDashboardDatasource.php',
'PhabricatorDashboardEditController' => 'applications/dashboard/controller/PhabricatorDashboardEditController.php', 'PhabricatorDashboardEditController' => 'applications/dashboard/controller/PhabricatorDashboardEditController.php',
'PhabricatorDashboardIconSet' => 'applications/dashboard/icon/PhabricatorDashboardIconSet.php', 'PhabricatorDashboardIconSet' => 'applications/dashboard/icon/PhabricatorDashboardIconSet.php',
'PhabricatorDashboardInstall' => 'applications/dashboard/storage/PhabricatorDashboardInstall.php', 'PhabricatorDashboardInstall' => 'applications/dashboard/storage/PhabricatorDashboardInstall.php',
@ -2460,6 +2461,7 @@ phutil_register_library_map(array(
'PhabricatorDashboardPanelArchiveController' => 'applications/dashboard/controller/PhabricatorDashboardPanelArchiveController.php', 'PhabricatorDashboardPanelArchiveController' => 'applications/dashboard/controller/PhabricatorDashboardPanelArchiveController.php',
'PhabricatorDashboardPanelCoreCustomField' => 'applications/dashboard/customfield/PhabricatorDashboardPanelCoreCustomField.php', 'PhabricatorDashboardPanelCoreCustomField' => 'applications/dashboard/customfield/PhabricatorDashboardPanelCoreCustomField.php',
'PhabricatorDashboardPanelCustomField' => 'applications/dashboard/customfield/PhabricatorDashboardPanelCustomField.php', 'PhabricatorDashboardPanelCustomField' => 'applications/dashboard/customfield/PhabricatorDashboardPanelCustomField.php',
'PhabricatorDashboardPanelDatasource' => 'applications/dashboard/typeahead/PhabricatorDashboardPanelDatasource.php',
'PhabricatorDashboardPanelEditConduitAPIMethod' => 'applications/dashboard/conduit/PhabricatorDashboardPanelEditConduitAPIMethod.php', 'PhabricatorDashboardPanelEditConduitAPIMethod' => 'applications/dashboard/conduit/PhabricatorDashboardPanelEditConduitAPIMethod.php',
'PhabricatorDashboardPanelEditController' => 'applications/dashboard/controller/PhabricatorDashboardPanelEditController.php', 'PhabricatorDashboardPanelEditController' => 'applications/dashboard/controller/PhabricatorDashboardPanelEditController.php',
'PhabricatorDashboardPanelEditEngine' => 'applications/dashboard/editor/PhabricatorDashboardPanelEditEngine.php', 'PhabricatorDashboardPanelEditEngine' => 'applications/dashboard/editor/PhabricatorDashboardPanelEditEngine.php',
@ -7412,6 +7414,7 @@ phutil_register_library_map(array(
'PhabricatorDashboardDAO' => 'PhabricatorLiskDAO', 'PhabricatorDashboardDAO' => 'PhabricatorLiskDAO',
'PhabricatorDashboardDashboardHasPanelEdgeType' => 'PhabricatorEdgeType', 'PhabricatorDashboardDashboardHasPanelEdgeType' => 'PhabricatorEdgeType',
'PhabricatorDashboardDashboardPHIDType' => 'PhabricatorPHIDType', 'PhabricatorDashboardDashboardPHIDType' => 'PhabricatorPHIDType',
'PhabricatorDashboardDatasource' => 'PhabricatorTypeaheadDatasource',
'PhabricatorDashboardEditController' => 'PhabricatorDashboardController', 'PhabricatorDashboardEditController' => 'PhabricatorDashboardController',
'PhabricatorDashboardIconSet' => 'PhabricatorIconSet', 'PhabricatorDashboardIconSet' => 'PhabricatorIconSet',
'PhabricatorDashboardInstall' => 'PhabricatorDashboardDAO', 'PhabricatorDashboardInstall' => 'PhabricatorDashboardDAO',
@ -7434,6 +7437,7 @@ phutil_register_library_map(array(
'PhabricatorStandardCustomFieldInterface', 'PhabricatorStandardCustomFieldInterface',
), ),
'PhabricatorDashboardPanelCustomField' => 'PhabricatorCustomField', 'PhabricatorDashboardPanelCustomField' => 'PhabricatorCustomField',
'PhabricatorDashboardPanelDatasource' => 'PhabricatorTypeaheadDatasource',
'PhabricatorDashboardPanelEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod', 'PhabricatorDashboardPanelEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod',
'PhabricatorDashboardPanelEditController' => 'PhabricatorDashboardController', 'PhabricatorDashboardPanelEditController' => 'PhabricatorDashboardController',
'PhabricatorDashboardPanelEditEngine' => 'PhabricatorEditEngine', 'PhabricatorDashboardPanelEditEngine' => 'PhabricatorEditEngine',

View file

@ -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);
}
}

View file

@ -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);
}
}