mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 05:20: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())
|
$header = id(new PHUIActionHeaderView())
|
||||||
->setHeaderTitle($panel->getName())
|
->setHeaderTitle($panel->getName())
|
||||||
->setHeaderColor(PHUIActionHeaderView::HEADER_LIGHTBLUE);
|
->setHeaderColor(PHUIActionHeaderView::HEADER_LIGHTBLUE);
|
||||||
|
$panel_type = $panel->getImplementation();
|
||||||
|
$header = $panel_type->adjustPanelHeader(
|
||||||
|
$this->getViewer(),
|
||||||
|
$panel,
|
||||||
|
$this,
|
||||||
|
$header);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $header;
|
return $header;
|
||||||
|
@ -256,6 +262,7 @@ final class PhabricatorDashboardPanelRenderingEngine extends Phobject {
|
||||||
return $header;
|
return $header;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detect graph cycles in panels, and deeply nested panels.
|
* Detect graph cycles in panels, and deeply nested panels.
|
||||||
*
|
*
|
||||||
|
|
|
@ -37,6 +37,14 @@ abstract class PhabricatorDashboardPanelType extends Phobject {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function adjustPanelHeader(
|
||||||
|
PhabricatorUser $viewer,
|
||||||
|
PhabricatorDashboardPanel $panel,
|
||||||
|
PhabricatorDashboardPanelRenderingEngine $engine,
|
||||||
|
PHUIActionHeaderView $header) {
|
||||||
|
return $header;
|
||||||
|
}
|
||||||
|
|
||||||
public static function getAllPanelTypes() {
|
public static function getAllPanelTypes() {
|
||||||
static $types;
|
static $types;
|
||||||
|
|
||||||
|
|
|
@ -69,15 +69,7 @@ final class PhabricatorDashboardPanelTypeQuery
|
||||||
PhabricatorDashboardPanel $panel,
|
PhabricatorDashboardPanel $panel,
|
||||||
PhabricatorDashboardPanelRenderingEngine $engine) {
|
PhabricatorDashboardPanelRenderingEngine $engine) {
|
||||||
|
|
||||||
$class = $panel->getProperty('class');
|
$engine = $this->getSearchEngine($panel);
|
||||||
|
|
||||||
$engine = PhabricatorApplicationSearchEngine::getEngineByClassName($class);
|
|
||||||
if (!$engine) {
|
|
||||||
throw new Exception(
|
|
||||||
pht(
|
|
||||||
'The application search engine "%s" is not known to Phabricator!',
|
|
||||||
$class));
|
|
||||||
}
|
|
||||||
|
|
||||||
$engine->setViewer($viewer);
|
$engine->setViewer($viewer);
|
||||||
$engine->setContext(PhabricatorApplicationSearchEngine::CONTEXT_PANEL);
|
$engine->setContext(PhabricatorApplicationSearchEngine::CONTEXT_PANEL);
|
||||||
|
@ -88,7 +80,7 @@ final class PhabricatorDashboardPanelTypeQuery
|
||||||
} else {
|
} else {
|
||||||
$saved = id(new PhabricatorSavedQueryQuery())
|
$saved = id(new PhabricatorSavedQueryQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->withEngineClassNames(array($class))
|
->withEngineClassNames(array(get_class($engine)))
|
||||||
->withQueryKeys(array($key))
|
->withQueryKeys(array($key))
|
||||||
->executeOne();
|
->executeOne();
|
||||||
}
|
}
|
||||||
|
@ -98,7 +90,7 @@ final class PhabricatorDashboardPanelTypeQuery
|
||||||
pht(
|
pht(
|
||||||
'Query "%s" is unknown to application search engine "%s"!',
|
'Query "%s" is unknown to application search engine "%s"!',
|
||||||
$key,
|
$key,
|
||||||
$class));
|
get_class($engine)));
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = $engine->buildQueryFromSavedQuery($saved);
|
$query = $engine->buildQueryFromSavedQuery($saved);
|
||||||
|
@ -116,4 +108,31 @@ final class PhabricatorDashboardPanelTypeQuery
|
||||||
return $engine->renderResults($results, $saved);
|
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