1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 01:02:42 +01:00

Make Panels slightly easier to find and use

Summary: Ref T10390, turns "add existing panel" into a typeahead, and add lots more information to search.

Test Plan: Add an existing panel, click the search icon, see more information (type, engine).

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T10390

Differential Revision: https://secure.phabricator.com/D17348
This commit is contained in:
Chad Little 2017-02-13 16:30:33 -08:00
parent 1cb924ce68
commit 2c09fc5605
6 changed files with 42 additions and 17 deletions

View file

@ -23,7 +23,7 @@ final class PhabricatorDashboardAddPanelController
$redirect_uri = $this->getApplicationURI( $redirect_uri = $this->getApplicationURI(
'arrange/'.$dashboard->getID().'/'); 'arrange/'.$dashboard->getID().'/');
$v_panel = $request->getStr('panel'); $v_panel = head($request->getArr('panel'));
$e_panel = true; $e_panel = true;
$errors = array(); $errors = array();
if ($request->isFormPost()) { if ($request->isFormPost()) {
@ -70,26 +70,19 @@ final class PhabricatorDashboardAddPanelController
->addCancelButton($redirect_uri); ->addCancelButton($redirect_uri);
} }
$panel_options = array();
foreach ($panels as $panel) {
$panel_options[$panel->getID()] = pht(
'%s %s',
$panel->getMonogram(),
$panel->getName());
}
$form = id(new AphrontFormView()) $form = id(new AphrontFormView())
->setUser($viewer) ->setUser($viewer)
->addHiddenInput('column', $request->getInt('column')) ->addHiddenInput('column', $request->getInt('column'))
->appendRemarkupInstructions( ->appendRemarkupInstructions(
pht('Choose a panel to add to this dashboard:')) pht('Choose a panel to add to this dashboard:'))
->appendChild( ->appendChild(
id(new AphrontFormSelectControl()) id(new AphrontFormTokenizerControl())
->setUser($this->getViewer())
->setDatasource(new PhabricatorDashboardPanelDatasource())
->setLimit(1)
->setName('panel') ->setName('panel')
->setLabel(pht('Panel')) ->setLabel(pht('Panel'))
->setValue($v_panel) ->setValue($v_panel));
->setError($e_panel)
->setOptions($panel_options));
return $this->newDialog() return $this->newDialog()
->setTitle(pht('Add Panel')) ->setTitle(pht('Add Panel'))

View file

@ -6,6 +6,7 @@ abstract class PhabricatorDashboardPanelType extends Phobject {
abstract public function getPanelTypeName(); abstract public function getPanelTypeName();
abstract public function getPanelTypeDescription(); abstract public function getPanelTypeDescription();
abstract public function getFieldSpecifications(); abstract public function getFieldSpecifications();
abstract public function getIcon();
abstract public function renderPanelContent( abstract public function renderPanelContent(
PhabricatorUser $viewer, PhabricatorUser $viewer,

View file

@ -11,6 +11,10 @@ final class PhabricatorDashboardQueryPanelType
return pht('Query Panel'); return pht('Query Panel');
} }
public function getIcon() {
return 'fa-search';
}
public function getPanelTypeDescription() { public function getPanelTypeDescription() {
return pht( return pht(
'Show results of a search query, like the most recently filed tasks or '. 'Show results of a search query, like the most recently filed tasks or '.

View file

@ -11,6 +11,10 @@ final class PhabricatorDashboardTabsPanelType
return pht('Tab Panel'); return pht('Tab Panel');
} }
public function getIcon() {
return 'fa-window-maximize';
}
public function getPanelTypeDescription() { public function getPanelTypeDescription() {
return pht('Use tabs to switch between several other panels.'); return pht('Use tabs to switch between several other panels.');
} }

View file

@ -11,6 +11,10 @@ final class PhabricatorDashboardTextPanelType
return pht('Text Panel'); return pht('Text Panel');
} }
public function getIcon() {
return 'fa-paragraph';
}
public function getPanelTypeDescription() { public function getPanelTypeDescription() {
return pht( return pht(
'Add some static text to the dashboard. This can be used to '. 'Add some static text to the dashboard. This can be used to '.

View file

@ -16,9 +16,19 @@ final class PhabricatorDashboardPanelDatasource
} }
public function loadResults() { public function loadResults() {
$query = id(new PhabricatorDashboardPanelQuery()); $results = $this->buildResults();
return $this->filterResultsAgainstTokens($results);
}
protected function renderSpecialTokens(array $values) {
return $this->renderTokensFromResults($this->buildResults(), $values);
}
public function buildResults() {
$query = id(new PhabricatorDashboardPanelQuery());
$panels = $this->executeQuery($query); $panels = $this->executeQuery($query);
$results = array(); $results = array();
foreach ($panels as $panel) { foreach ($panels as $panel) {
$impl = $panel->getImplementation(); $impl = $panel->getImplementation();
@ -27,20 +37,29 @@ final class PhabricatorDashboardPanelDatasource
} else { } else {
$type_text = nonempty($panel->getPanelType(), pht('Unknown Type')); $type_text = nonempty($panel->getPanelType(), pht('Unknown Type'));
} }
$id = $panel->getID();
$monogram = $panel->getMonogram();
$properties = $panel->getProperties();
$result = id(new PhabricatorTypeaheadResult()) $result = id(new PhabricatorTypeaheadResult())
->setName($panel->getName()) ->setName($panel->getName())
->setPHID($panel->getPHID()) ->setDisplayName($monogram.' '.$panel->getName())
->setPHID($id)
->setIcon($impl->getIcon())
->addAttribute($type_text); ->addAttribute($type_text);
if (!empty($properties['class'])) {
$result->addAttribute($properties['class']);
}
if ($panel->getIsArchived()) { if ($panel->getIsArchived()) {
$result->setClosed(pht('Archived')); $result->setClosed(pht('Archived'));
} }
$results[] = $result; $results[$id] = $result;
} }
return $this->filterResultsAgainstTokens($results); return $results;
} }
} }