1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-23 07:12:41 +01:00

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
This commit is contained in:
epriestley 2014-05-15 19:31:13 -07:00
parent bf6e87da24
commit 302d5bcec5
6 changed files with 59 additions and 21 deletions

View file

@ -358,7 +358,7 @@ return array(
'rsrc/js/application/conpherence/behavior-pontificate.js' => '53f6f2dd', 'rsrc/js/application/conpherence/behavior-pontificate.js' => '53f6f2dd',
'rsrc/js/application/conpherence/behavior-widget-pane.js' => '40b1ff90', 'rsrc/js/application/conpherence/behavior-widget-pane.js' => '40b1ff90',
'rsrc/js/application/countdown/timer.js' => '889c96f3', '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/dashboard/behavior-dashboard-move-panels.js' => 'fa187a68',
'rsrc/js/application/differential/DifferentialInlineCommentEditor.js' => 'f2441746', 'rsrc/js/application/differential/DifferentialInlineCommentEditor.js' => 'f2441746',
'rsrc/js/application/differential/behavior-add-reviewers-and-ccs.js' => '533a187b', '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-conpherence-widget-pane' => '40b1ff90',
'javelin-behavior-countdown-timer' => '889c96f3', 'javelin-behavior-countdown-timer' => '889c96f3',
'javelin-behavior-dark-console' => 'e9fdb5e5', '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-dashboard-move-panels' => 'fa187a68',
'javelin-behavior-device' => '03d6ed07', 'javelin-behavior-device' => '03d6ed07',
'javelin-behavior-differential-add-reviewers-and-ccs' => '533a187b', 'javelin-behavior-differential-add-reviewers-and-ccs' => '533a187b',
@ -1965,6 +1965,12 @@ return array(
0 => 'javelin-install', 0 => 'javelin-install',
1 => 'javelin-util', 1 => 'javelin-util',
), ),
'f1375ea5' =>
array(
0 => 'javelin-behavior',
1 => 'javelin-dom',
2 => 'javelin-workflow',
),
'f2441746' => 'f2441746' =>
array( array(
0 => 'javelin-dom', 0 => 'javelin-dom',
@ -2033,12 +2039,6 @@ return array(
0 => 'phabricator-busy', 0 => 'phabricator-busy',
1 => 'javelin-behavior', 1 => 'javelin-behavior',
), ),
'fd965b41' =>
array(
0 => 'javelin-behavior',
1 => 'javelin-dom',
2 => 'javelin-workflow',
),
'fe2e0ba4' => 'fe2e0ba4' =>
array( array(
0 => 'javelin-behavior', 0 => 'javelin-behavior',

View file

@ -37,13 +37,14 @@ final class PhabricatorDashboardPanelRenderController
->setViewer($viewer) ->setViewer($viewer)
->setPanel($panel) ->setPanel($panel)
->setParentPanelPHIDs($parent_phids) ->setParentPanelPHIDs($parent_phids)
->setHeaderless($request->getBool('headerless'))
->renderPanel(); ->renderPanel();
if ($request->isAjax()) { if ($request->isAjax()) {
return id(new AphrontAjaxResponse()) return id(new AphrontAjaxResponse())
->setContent( ->setContent(
array( array(
'panelMarkup' => $rendered_panel, 'panelMarkup' => hsprintf('%s', $rendered_panel),
)); ));
} }

View file

@ -6,6 +6,16 @@ final class PhabricatorDashboardPanelRenderingEngine extends Phobject {
private $viewer; private $viewer;
private $enableAsyncRendering; private $enableAsyncRendering;
private $parentPanelPHIDs; 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. * Allow the engine to render the panel via Ajax.
@ -75,9 +85,14 @@ final class PhabricatorDashboardPanelRenderingEngine extends Phobject {
} }
private function renderErrorPanel($title, $body) { private function renderErrorPanel($title, $body) {
return id(new PHUIObjectBoxView()) if ($this->getHeaderless()) {
->setHeaderText($title) return id(new AphrontErrorView())
->setFormErrors(array($body)); ->setErrors(array($body));
} else {
return id(new PHUIObjectBoxView())
->setHeaderText($title)
->setFormErrors(array($body));
}
} }
private function renderAsyncPanel(PhabricatorDashboardPanel $panel) { private function renderAsyncPanel(PhabricatorDashboardPanel $panel) {
@ -88,16 +103,28 @@ final class PhabricatorDashboardPanelRenderingEngine extends Phobject {
array( array(
'panelID' => $panel_id, 'panelID' => $panel_id,
'parentPanelPHIDs' => $this->getParentPanelPHIDs(), 'parentPanelPHIDs' => $this->getParentPanelPHIDs(),
'headerless' => $this->getHeaderless(),
'uri' => '/dashboard/panel/render/'.$panel->getID().'/', 'uri' => '/dashboard/panel/render/'.$panel->getID().'/',
)); ));
return id(new PHUIObjectBoxView()) $content = pht('Loading...');
->addSigil('dashboard-panel')
->setMetadata(array( if ($this->headerless) {
'objectPHID' => $panel->getPHID())) return phutil_tag(
->setHeaderText($panel->getName()) 'div',
->setID($panel_id) array(
->appendChild(pht('Loading...')); '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);
}
} }
/** /**

View file

@ -47,6 +47,10 @@ abstract class PhabricatorDashboardPanelType extends Phobject {
$content = $this->renderPanelContent($viewer, $panel, $engine); $content = $this->renderPanelContent($viewer, $panel, $engine);
if ($engine->getHeaderless()) {
return $content;
}
return id(new PHUIObjectBoxView()) return id(new PHUIObjectBoxView())
->addSigil('dashboard-panel') ->addSigil('dashboard-panel')
->setMetadata(array( ->setMetadata(array(

View file

@ -91,9 +91,10 @@ final class PhabricatorDashboardPanelTypeTabs
->setEnableAsyncRendering(true) ->setEnableAsyncRendering(true)
->setParentPanelPHIDs($parent_phids) ->setParentPanelPHIDs($parent_phids)
->setPanel($panel) ->setPanel($panel)
->setHeaderless(true)
->renderPanel(); ->renderPanel();
} else { } else {
$panel_content = 'nope'; $panel_content = pht('(Invalid Panel)');
} }
$content[] = phutil_tag( $content[] = phutil_tag(

View file

@ -9,8 +9,13 @@ JX.behavior('dashboard-async-panel', function(config) {
var panel = JX.$(config.panelID); var panel = JX.$(config.panelID);
panel.style.opacity = '0.5'; panel.style.opacity = '0.5';
var data = {
parentPanelPHIDs: config.parentPanelPHIDs.join(','),
headerless: config.headerless ? 1 : 0
};
new JX.Workflow(config.uri) new JX.Workflow(config.uri)
.setData({parentPanelPHIDs: config.parentPanelPHIDs.join(',')}) .setData(data)
.setHandler(function(r) { .setHandler(function(r) {
JX.DOM.replace(panel, JX.$H(r.panelMarkup)); JX.DOM.replace(panel, JX.$H(r.panelMarkup));
}) })