mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-28 16:30:59 +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:
parent
bf6e87da24
commit
302d5bcec5
6 changed files with 59 additions and 21 deletions
|
@ -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',
|
||||
|
|
|
@ -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),
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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));
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue