mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +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:
parent
1cb924ce68
commit
2c09fc5605
6 changed files with 42 additions and 17 deletions
|
@ -23,7 +23,7 @@ final class PhabricatorDashboardAddPanelController
|
|||
$redirect_uri = $this->getApplicationURI(
|
||||
'arrange/'.$dashboard->getID().'/');
|
||||
|
||||
$v_panel = $request->getStr('panel');
|
||||
$v_panel = head($request->getArr('panel'));
|
||||
$e_panel = true;
|
||||
$errors = array();
|
||||
if ($request->isFormPost()) {
|
||||
|
@ -70,26 +70,19 @@ final class PhabricatorDashboardAddPanelController
|
|||
->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())
|
||||
->setUser($viewer)
|
||||
->addHiddenInput('column', $request->getInt('column'))
|
||||
->appendRemarkupInstructions(
|
||||
pht('Choose a panel to add to this dashboard:'))
|
||||
->appendChild(
|
||||
id(new AphrontFormSelectControl())
|
||||
id(new AphrontFormTokenizerControl())
|
||||
->setUser($this->getViewer())
|
||||
->setDatasource(new PhabricatorDashboardPanelDatasource())
|
||||
->setLimit(1)
|
||||
->setName('panel')
|
||||
->setLabel(pht('Panel'))
|
||||
->setValue($v_panel)
|
||||
->setError($e_panel)
|
||||
->setOptions($panel_options));
|
||||
->setValue($v_panel));
|
||||
|
||||
return $this->newDialog()
|
||||
->setTitle(pht('Add Panel'))
|
||||
|
|
|
@ -6,6 +6,7 @@ abstract class PhabricatorDashboardPanelType extends Phobject {
|
|||
abstract public function getPanelTypeName();
|
||||
abstract public function getPanelTypeDescription();
|
||||
abstract public function getFieldSpecifications();
|
||||
abstract public function getIcon();
|
||||
|
||||
abstract public function renderPanelContent(
|
||||
PhabricatorUser $viewer,
|
||||
|
|
|
@ -11,6 +11,10 @@ final class PhabricatorDashboardQueryPanelType
|
|||
return pht('Query Panel');
|
||||
}
|
||||
|
||||
public function getIcon() {
|
||||
return 'fa-search';
|
||||
}
|
||||
|
||||
public function getPanelTypeDescription() {
|
||||
return pht(
|
||||
'Show results of a search query, like the most recently filed tasks or '.
|
||||
|
|
|
@ -11,6 +11,10 @@ final class PhabricatorDashboardTabsPanelType
|
|||
return pht('Tab Panel');
|
||||
}
|
||||
|
||||
public function getIcon() {
|
||||
return 'fa-window-maximize';
|
||||
}
|
||||
|
||||
public function getPanelTypeDescription() {
|
||||
return pht('Use tabs to switch between several other panels.');
|
||||
}
|
||||
|
|
|
@ -11,6 +11,10 @@ final class PhabricatorDashboardTextPanelType
|
|||
return pht('Text Panel');
|
||||
}
|
||||
|
||||
public function getIcon() {
|
||||
return 'fa-paragraph';
|
||||
}
|
||||
|
||||
public function getPanelTypeDescription() {
|
||||
return pht(
|
||||
'Add some static text to the dashboard. This can be used to '.
|
||||
|
|
|
@ -16,9 +16,19 @@ final class PhabricatorDashboardPanelDatasource
|
|||
}
|
||||
|
||||
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);
|
||||
|
||||
$results = array();
|
||||
foreach ($panels as $panel) {
|
||||
$impl = $panel->getImplementation();
|
||||
|
@ -27,20 +37,29 @@ final class PhabricatorDashboardPanelDatasource
|
|||
} else {
|
||||
$type_text = nonempty($panel->getPanelType(), pht('Unknown Type'));
|
||||
}
|
||||
$id = $panel->getID();
|
||||
$monogram = $panel->getMonogram();
|
||||
$properties = $panel->getProperties();
|
||||
|
||||
$result = id(new PhabricatorTypeaheadResult())
|
||||
->setName($panel->getName())
|
||||
->setPHID($panel->getPHID())
|
||||
->setDisplayName($monogram.' '.$panel->getName())
|
||||
->setPHID($id)
|
||||
->setIcon($impl->getIcon())
|
||||
->addAttribute($type_text);
|
||||
|
||||
if (!empty($properties['class'])) {
|
||||
$result->addAttribute($properties['class']);
|
||||
}
|
||||
|
||||
if ($panel->getIsArchived()) {
|
||||
$result->setClosed(pht('Archived'));
|
||||
}
|
||||
|
||||
$results[] = $result;
|
||||
$results[$id] = $result;
|
||||
}
|
||||
|
||||
return $this->filterResultsAgainstTokens($results);
|
||||
return $results;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue