Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14049592
D8913.id21148.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Referenced Files
None
Subscribers
None
D8913.id21148.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -1443,6 +1443,8 @@
'PhabricatorDashboardPanelEditController' => 'applications/dashboard/controller/PhabricatorDashboardPanelEditController.php',
'PhabricatorDashboardPanelListController' => 'applications/dashboard/controller/PhabricatorDashboardPanelListController.php',
'PhabricatorDashboardPanelQuery' => 'applications/dashboard/query/PhabricatorDashboardPanelQuery.php',
+ 'PhabricatorDashboardPanelRenderController' => 'applications/dashboard/controller/PhabricatorDashboardPanelRenderController.php',
+ 'PhabricatorDashboardPanelRenderingEngine' => 'applications/dashboard/engine/PhabricatorDashboardPanelRenderingEngine.php',
'PhabricatorDashboardPanelSearchEngine' => 'applications/dashboard/query/PhabricatorDashboardPanelSearchEngine.php',
'PhabricatorDashboardPanelTransaction' => 'applications/dashboard/storage/PhabricatorDashboardPanelTransaction.php',
'PhabricatorDashboardPanelTransactionEditor' => 'applications/dashboard/editor/PhabricatorDashboardPanelTransactionEditor.php',
@@ -4253,6 +4255,8 @@
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
),
'PhabricatorDashboardPanelQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
+ 'PhabricatorDashboardPanelRenderController' => 'PhabricatorDashboardController',
+ 'PhabricatorDashboardPanelRenderingEngine' => 'Phobject',
'PhabricatorDashboardPanelSearchEngine' => 'PhabricatorApplicationSearchEngine',
'PhabricatorDashboardPanelTransaction' => 'PhabricatorApplicationTransaction',
'PhabricatorDashboardPanelTransactionEditor' => 'PhabricatorApplicationTransactionEditor',
diff --git a/src/applications/dashboard/application/PhabricatorApplicationDashboard.php b/src/applications/dashboard/application/PhabricatorApplicationDashboard.php
--- a/src/applications/dashboard/application/PhabricatorApplicationDashboard.php
+++ b/src/applications/dashboard/application/PhabricatorApplicationDashboard.php
@@ -29,6 +29,7 @@
=> 'PhabricatorDashboardPanelListController',
'create/' => 'PhabricatorDashboardPanelCreateController',
'edit/(?:(?P<id>\d+)/)?' => 'PhabricatorDashboardPanelEditController',
+ 'render/(?P<id>\d+)/' => 'PhabricatorDashboardPanelRenderController',
),
),
);
diff --git a/src/applications/dashboard/controller/PhabricatorDashboardPanelRenderController.php b/src/applications/dashboard/controller/PhabricatorDashboardPanelRenderController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/dashboard/controller/PhabricatorDashboardPanelRenderController.php
@@ -0,0 +1,53 @@
+<?php
+
+final class PhabricatorDashboardPanelRenderController
+ extends PhabricatorDashboardController {
+
+ private $id;
+
+ public function willProcessRequest(array $data) {
+ $this->id = $data['id'];
+ }
+
+ public function processRequest() {
+ $request = $this->getRequest();
+ $viewer = $request->getUser();
+
+ $panel = id(new PhabricatorDashboardPanelQuery())
+ ->setViewer($viewer)
+ ->withIDs(array($this->id))
+ ->executeOne();
+ if (!$panel) {
+ return new Aphront404Response();
+ }
+
+ $rendered_panel = id(new PhabricatorDashboardPanelRenderingEngine())
+ ->setViewer($viewer)
+ ->setPanel($panel)
+ ->renderPanel();
+
+ if ($request->isAjax()) {
+ return id(new AphrontAjaxResponse())
+ ->setContent(
+ array(
+ 'panelMarkup' => $rendered_panel,
+ ));
+ }
+
+ $crumbs = $this->buildApplicationCrumbs()
+ ->addTextCrumb(pht('Panels'), $this->getApplicationURI('panel/'))
+ ->addTextCrumb($panel->getMonogram(), '/'.$panel->getMonogram())
+ ->addTextCrumb(pht('Standalone View'));
+
+ return $this->buildApplicationPage(
+ array(
+ $crumbs,
+ $rendered_panel,
+ ),
+ array(
+ 'title' => array(pht('Panel'), $panel->getName()),
+ 'device' => true,
+ ));
+ }
+
+}
diff --git a/src/applications/dashboard/controller/PhabricatorDashboardPanelViewController.php b/src/applications/dashboard/controller/PhabricatorDashboardPanelViewController.php
--- a/src/applications/dashboard/controller/PhabricatorDashboardPanelViewController.php
+++ b/src/applications/dashboard/controller/PhabricatorDashboardPanelViewController.php
@@ -38,11 +38,17 @@
->setHeader($header)
->addPropertyList($properties);
+ $rendered_panel = id(new PhabricatorDashboardPanelRenderingEngine())
+ ->setViewer($viewer)
+ ->setPanel($panel)
+ ->renderPanel();
+
return $this->buildApplicationPage(
array(
$crumbs,
$box,
$timeline,
+ $rendered_panel,
),
array(
'title' => $title,
@@ -80,6 +86,12 @@
->setDisabled(!$can_edit)
->setWorkflow(!$can_edit));
+ $actions->addAction(
+ id(new PhabricatorActionView())
+ ->setName(pht('View Standalone'))
+ ->setIcon('preview')
+ ->setHref($this->getApplicationURI("panel/render/{$id}/")));
+
return $actions;
}
diff --git a/src/applications/dashboard/engine/PhabricatorDashboardPanelRenderingEngine.php b/src/applications/dashboard/engine/PhabricatorDashboardPanelRenderingEngine.php
new file mode 100644
--- /dev/null
+++ b/src/applications/dashboard/engine/PhabricatorDashboardPanelRenderingEngine.php
@@ -0,0 +1,47 @@
+<?php
+
+final class PhabricatorDashboardPanelRenderingEngine extends Phobject {
+
+ private $panel;
+ private $viewer;
+
+ public function setViewer(PhabricatorUser $viewer) {
+ $this->viewer = $viewer;
+ return $this;
+ }
+
+ public function setPanel(PhabricatorDashboardPanel $panel) {
+ $this->panel = $panel;
+ return $this;
+ }
+
+ public function renderPanel() {
+ $panel = $this->panel;
+ $viewer = $this->viewer;
+
+ if (!$panel) {
+ return $this->renderErrorPanel(
+ pht('Missing Panel'),
+ pht('This panel does not exist.'));
+ }
+
+ $panel_type = $panel->getImplementation();
+ if (!$panel_type) {
+ return $this->renderErrorPanel(
+ $panel->getName(),
+ pht(
+ 'This panel has type "%s", but that panel type is not known to '.
+ 'Phabricator.',
+ $panel->getPanelType()));
+ }
+
+ return $panel_type->renderPanel($viewer, $panel);
+ }
+
+ private function renderErrorPanel($title, $body) {
+ return id(new PHUIObjectBoxView())
+ ->setHeaderText($title)
+ ->setFormErrors(array($body));
+ }
+
+}
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
@@ -39,4 +39,13 @@
return $types;
}
+ public function renderPanel(
+ PhabricatorUser $viewer,
+ PhabricatorDashboardPanel $panel) {
+
+ return id(new PHUIObjectBoxView())
+ ->setHeaderText($panel->getName())
+ ->appendChild(pht('TODO: Panel content goes here.'));
+ }
+
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 15, 1:47 PM (3 d, 17 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6757170
Default Alt Text
D8913.id21148.diff (7 KB)
Attached To
Mode
D8913: Let dashboard panels render in a very basic way
Attached
Detach File
Event Timeline
Log In to Comment