Page MenuHomePhabricator

D11008.id26435.diff
No OneTemporary

D11008.id26435.diff

diff --git a/src/applications/dashboard/engine/PhabricatorDashboardPanelRenderingEngine.php b/src/applications/dashboard/engine/PhabricatorDashboardPanelRenderingEngine.php
--- a/src/applications/dashboard/engine/PhabricatorDashboardPanelRenderingEngine.php
+++ b/src/applications/dashboard/engine/PhabricatorDashboardPanelRenderingEngine.php
@@ -222,6 +222,12 @@
$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 @@
return $header;
}
+
/**
* Detect graph cycles in panels, and deeply nested panels.
*
diff --git a/src/applications/dashboard/paneltype/PhabricatorDashboardPanelType.php b/src/applications/dashboard/paneltype/PhabricatorDashboardPanelType.php
--- a/src/applications/dashboard/paneltype/PhabricatorDashboardPanelType.php
+++ b/src/applications/dashboard/paneltype/PhabricatorDashboardPanelType.php
@@ -37,6 +37,14 @@
return true;
}
+ public function adjustPanelHeader(
+ PhabricatorUser $viewer,
+ PhabricatorDashboardPanel $panel,
+ PhabricatorDashboardPanelRenderingEngine $engine,
+ PHUIActionHeaderView $header) {
+ return $header;
+ }
+
public static function getAllPanelTypes() {
static $types;
diff --git a/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeQuery.php b/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeQuery.php
--- a/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeQuery.php
+++ b/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeQuery.php
@@ -69,15 +69,7 @@
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 @@
} else {
$saved = id(new PhabricatorSavedQueryQuery())
->setViewer($viewer)
- ->withEngineClassNames(array($class))
+ ->withEngineClassNames(array(get_class($engine)))
->withQueryKeys(array($key))
->executeOne();
}
@@ -98,7 +90,7 @@
pht(
'Query "%s" is unknown to application search engine "%s"!',
$key,
- $class));
+ get_class($engine)));
}
$query = $engine->buildQueryFromSavedQuery($saved);
@@ -116,4 +108,31 @@
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;
+ }
+
}

File Metadata

Mime Type
text/plain
Expires
Wed, Oct 23, 8:39 PM (3 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6712669
Default Alt Text
D11008.id26435.diff (3 KB)

Event Timeline