mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 20:40:56 +01:00
Link search query to Dashboard header title
Summary: Makes the header text clickable to the full results. Test Plan: Click on a few queries. Reviewers: btrahan, epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Differential Revision: https://secure.phabricator.com/D11008
This commit is contained in:
parent
f5600acb16
commit
05c13857af
3 changed files with 45 additions and 11 deletions
|
@ -222,6 +222,12 @@ final class PhabricatorDashboardPanelRenderingEngine extends Phobject {
|
|||
$header = id(new PHUIActionHeaderView())
|
||||
->setHeaderTitle($panel->getName())
|
||||
->setHeaderColor(PHUIActionHeaderView::HEADER_LIGHTBLUE);
|
||||
$panel_type = $panel->getImplementation();
|
||||
$header = $panel_type->adjustPanelHeader(
|
||||
$this->getViewer(),
|
||||
$panel,
|
||||
$this,
|
||||
$header);
|
||||
break;
|
||||
}
|
||||
return $header;
|
||||
|
@ -256,6 +262,7 @@ final class PhabricatorDashboardPanelRenderingEngine extends Phobject {
|
|||
return $header;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Detect graph cycles in panels, and deeply nested panels.
|
||||
*
|
||||
|
|
|
@ -37,6 +37,14 @@ abstract class PhabricatorDashboardPanelType extends Phobject {
|
|||
return true;
|
||||
}
|
||||
|
||||
public function adjustPanelHeader(
|
||||
PhabricatorUser $viewer,
|
||||
PhabricatorDashboardPanel $panel,
|
||||
PhabricatorDashboardPanelRenderingEngine $engine,
|
||||
PHUIActionHeaderView $header) {
|
||||
return $header;
|
||||
}
|
||||
|
||||
public static function getAllPanelTypes() {
|
||||
static $types;
|
||||
|
||||
|
|
|
@ -69,15 +69,7 @@ final class PhabricatorDashboardPanelTypeQuery
|
|||
PhabricatorDashboardPanel $panel,
|
||||
PhabricatorDashboardPanelRenderingEngine $engine) {
|
||||
|
||||
$class = $panel->getProperty('class');
|
||||
|
||||
$engine = PhabricatorApplicationSearchEngine::getEngineByClassName($class);
|
||||
if (!$engine) {
|
||||
throw new Exception(
|
||||
pht(
|
||||
'The application search engine "%s" is not known to Phabricator!',
|
||||
$class));
|
||||
}
|
||||
$engine = $this->getSearchEngine($panel);
|
||||
|
||||
$engine->setViewer($viewer);
|
||||
$engine->setContext(PhabricatorApplicationSearchEngine::CONTEXT_PANEL);
|
||||
|
@ -88,7 +80,7 @@ final class PhabricatorDashboardPanelTypeQuery
|
|||
} else {
|
||||
$saved = id(new PhabricatorSavedQueryQuery())
|
||||
->setViewer($viewer)
|
||||
->withEngineClassNames(array($class))
|
||||
->withEngineClassNames(array(get_class($engine)))
|
||||
->withQueryKeys(array($key))
|
||||
->executeOne();
|
||||
}
|
||||
|
@ -98,7 +90,7 @@ final class PhabricatorDashboardPanelTypeQuery
|
|||
pht(
|
||||
'Query "%s" is unknown to application search engine "%s"!',
|
||||
$key,
|
||||
$class));
|
||||
get_class($engine)));
|
||||
}
|
||||
|
||||
$query = $engine->buildQueryFromSavedQuery($saved);
|
||||
|
@ -116,4 +108,31 @@ final class PhabricatorDashboardPanelTypeQuery
|
|||
return $engine->renderResults($results, $saved);
|
||||
}
|
||||
|
||||
|
||||
public function adjustPanelHeader(
|
||||
PhabricatorUser $viewer,
|
||||
PhabricatorDashboardPanel $panel,
|
||||
PhabricatorDashboardPanelRenderingEngine $engine,
|
||||
PHUIActionHeaderView $header) {
|
||||
|
||||
$search_engine = $this->getSearchEngine($panel);
|
||||
$key = $panel->getProperty('key');
|
||||
$header->setHeaderHref($search_engine->getQueryResultsPageURI($key));
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
private function getSearchEngine(PhabricatorDashboardPanel $panel) {
|
||||
$class = $panel->getProperty('class');
|
||||
$engine = PhabricatorApplicationSearchEngine::getEngineByClassName($class);
|
||||
if (!$engine) {
|
||||
throw new Exception(
|
||||
pht(
|
||||
'The application search engine "%s" is not known to Phabricator!',
|
||||
$class));
|
||||
}
|
||||
|
||||
return $engine;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue