From 302d5bcec5e761bef1397a5392d7366dbfe092fe Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 15 May 2014 19:31:13 -0700 Subject: [PATCH] Allow dashboard panels to render in a headerless mode Summary: Ref T4986. This mostly just makes tab panels a little nicer. Maybe this will be modal (header = "none", "edit", "view") in a few diffs but we can clean it up then if so. Test Plan: {F155491} Reviewers: btrahan, chad Reviewed By: chad Subscribers: epriestley Maniphest Tasks: T4986 Differential Revision: https://secure.phabricator.com/D9143 --- resources/celerity/map.php | 16 +++---- ...bricatorDashboardPanelRenderController.php | 3 +- ...abricatorDashboardPanelRenderingEngine.php | 47 +++++++++++++++---- .../PhabricatorDashboardPanelType.php | 4 ++ .../PhabricatorDashboardPanelTypeTabs.php | 3 +- .../behavior-dashboard-async-panel.js | 7 ++- 6 files changed, 59 insertions(+), 21 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index fb8c760a53..00b2289db3 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -358,7 +358,7 @@ return array( 'rsrc/js/application/conpherence/behavior-pontificate.js' => '53f6f2dd', 'rsrc/js/application/conpherence/behavior-widget-pane.js' => '40b1ff90', 'rsrc/js/application/countdown/timer.js' => '889c96f3', - 'rsrc/js/application/dashboard/behavior-dashboard-async-panel.js' => 'fd965b41', + 'rsrc/js/application/dashboard/behavior-dashboard-async-panel.js' => 'f1375ea5', 'rsrc/js/application/dashboard/behavior-dashboard-move-panels.js' => 'fa187a68', 'rsrc/js/application/differential/DifferentialInlineCommentEditor.js' => 'f2441746', 'rsrc/js/application/differential/behavior-add-reviewers-and-ccs.js' => '533a187b', @@ -553,7 +553,7 @@ return array( 'javelin-behavior-conpherence-widget-pane' => '40b1ff90', 'javelin-behavior-countdown-timer' => '889c96f3', 'javelin-behavior-dark-console' => 'e9fdb5e5', - 'javelin-behavior-dashboard-async-panel' => 'fd965b41', + 'javelin-behavior-dashboard-async-panel' => 'f1375ea5', 'javelin-behavior-dashboard-move-panels' => 'fa187a68', 'javelin-behavior-device' => '03d6ed07', 'javelin-behavior-differential-add-reviewers-and-ccs' => '533a187b', @@ -1965,6 +1965,12 @@ return array( 0 => 'javelin-install', 1 => 'javelin-util', ), + 'f1375ea5' => + array( + 0 => 'javelin-behavior', + 1 => 'javelin-dom', + 2 => 'javelin-workflow', + ), 'f2441746' => array( 0 => 'javelin-dom', @@ -2033,12 +2039,6 @@ return array( 0 => 'phabricator-busy', 1 => 'javelin-behavior', ), - 'fd965b41' => - array( - 0 => 'javelin-behavior', - 1 => 'javelin-dom', - 2 => 'javelin-workflow', - ), 'fe2e0ba4' => array( 0 => 'javelin-behavior', diff --git a/src/applications/dashboard/controller/PhabricatorDashboardPanelRenderController.php b/src/applications/dashboard/controller/PhabricatorDashboardPanelRenderController.php index a92ac821db..648c21cc87 100644 --- a/src/applications/dashboard/controller/PhabricatorDashboardPanelRenderController.php +++ b/src/applications/dashboard/controller/PhabricatorDashboardPanelRenderController.php @@ -37,13 +37,14 @@ final class PhabricatorDashboardPanelRenderController ->setViewer($viewer) ->setPanel($panel) ->setParentPanelPHIDs($parent_phids) + ->setHeaderless($request->getBool('headerless')) ->renderPanel(); if ($request->isAjax()) { return id(new AphrontAjaxResponse()) ->setContent( array( - 'panelMarkup' => $rendered_panel, + 'panelMarkup' => hsprintf('%s', $rendered_panel), )); } diff --git a/src/applications/dashboard/engine/PhabricatorDashboardPanelRenderingEngine.php b/src/applications/dashboard/engine/PhabricatorDashboardPanelRenderingEngine.php index 2b92721462..3c62d38129 100644 --- a/src/applications/dashboard/engine/PhabricatorDashboardPanelRenderingEngine.php +++ b/src/applications/dashboard/engine/PhabricatorDashboardPanelRenderingEngine.php @@ -6,6 +6,16 @@ final class PhabricatorDashboardPanelRenderingEngine extends Phobject { private $viewer; private $enableAsyncRendering; private $parentPanelPHIDs; + private $headerless; + + public function setHeaderless($headerless) { + $this->headerless = $headerless; + return $this; + } + + public function getHeaderless() { + return $this->headerless; + } /** * Allow the engine to render the panel via Ajax. @@ -75,9 +85,14 @@ final class PhabricatorDashboardPanelRenderingEngine extends Phobject { } private function renderErrorPanel($title, $body) { - return id(new PHUIObjectBoxView()) - ->setHeaderText($title) - ->setFormErrors(array($body)); + if ($this->getHeaderless()) { + return id(new AphrontErrorView()) + ->setErrors(array($body)); + } else { + return id(new PHUIObjectBoxView()) + ->setHeaderText($title) + ->setFormErrors(array($body)); + } } private function renderAsyncPanel(PhabricatorDashboardPanel $panel) { @@ -88,16 +103,28 @@ final class PhabricatorDashboardPanelRenderingEngine extends Phobject { array( 'panelID' => $panel_id, 'parentPanelPHIDs' => $this->getParentPanelPHIDs(), + 'headerless' => $this->getHeaderless(), 'uri' => '/dashboard/panel/render/'.$panel->getID().'/', )); - return id(new PHUIObjectBoxView()) - ->addSigil('dashboard-panel') - ->setMetadata(array( - 'objectPHID' => $panel->getPHID())) - ->setHeaderText($panel->getName()) - ->setID($panel_id) - ->appendChild(pht('Loading...')); + $content = pht('Loading...'); + + if ($this->headerless) { + return phutil_tag( + 'div', + array( + 'id' => $panel_id, + ), + $content); + } else { + return id(new PHUIObjectBoxView()) + ->addSigil('dashboard-panel') + ->setMetadata(array( + 'objectPHID' => $panel->getPHID())) + ->setHeaderText($panel->getName()) + ->setID($panel_id) + ->appendChild($content); + } } /** diff --git a/src/applications/dashboard/paneltype/PhabricatorDashboardPanelType.php b/src/applications/dashboard/paneltype/PhabricatorDashboardPanelType.php index c44fd59b3e..e5c7f8c09f 100644 --- a/src/applications/dashboard/paneltype/PhabricatorDashboardPanelType.php +++ b/src/applications/dashboard/paneltype/PhabricatorDashboardPanelType.php @@ -47,6 +47,10 @@ abstract class PhabricatorDashboardPanelType extends Phobject { $content = $this->renderPanelContent($viewer, $panel, $engine); + if ($engine->getHeaderless()) { + return $content; + } + return id(new PHUIObjectBoxView()) ->addSigil('dashboard-panel') ->setMetadata(array( diff --git a/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeTabs.php b/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeTabs.php index 4c98d8617e..61c6199184 100644 --- a/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeTabs.php +++ b/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeTabs.php @@ -91,9 +91,10 @@ final class PhabricatorDashboardPanelTypeTabs ->setEnableAsyncRendering(true) ->setParentPanelPHIDs($parent_phids) ->setPanel($panel) + ->setHeaderless(true) ->renderPanel(); } else { - $panel_content = 'nope'; + $panel_content = pht('(Invalid Panel)'); } $content[] = phutil_tag( diff --git a/webroot/rsrc/js/application/dashboard/behavior-dashboard-async-panel.js b/webroot/rsrc/js/application/dashboard/behavior-dashboard-async-panel.js index 3938bfe643..0b5f2af825 100644 --- a/webroot/rsrc/js/application/dashboard/behavior-dashboard-async-panel.js +++ b/webroot/rsrc/js/application/dashboard/behavior-dashboard-async-panel.js @@ -9,8 +9,13 @@ JX.behavior('dashboard-async-panel', function(config) { var panel = JX.$(config.panelID); panel.style.opacity = '0.5'; + var data = { + parentPanelPHIDs: config.parentPanelPHIDs.join(','), + headerless: config.headerless ? 1 : 0 + }; + new JX.Workflow(config.uri) - .setData({parentPanelPHIDs: config.parentPanelPHIDs.join(',')}) + .setData(data) .setHandler(function(r) { JX.DOM.replace(panel, JX.$H(r.panelMarkup)); })