1
0
Fork 0
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:
Chad Little 2014-12-18 08:40:50 -08:00
parent f5600acb16
commit 05c13857af
3 changed files with 45 additions and 11 deletions

View file

@ -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.
*

View file

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

View file

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