1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-18 12:52:42 +01:00

When a viewer can't see some of a dashboard's panels, only hide those panels

Summary:
Ref T12174. Ref T8033. Currently, if you can't see one panel on a dashboard, you can't see the dashboard at all. This is confusing and hard to debug.

Improve this behavior at least slightly: render the dashboard, with a big "you can't see this" panel in place of any panels you can't see. This should at least make the behavior obvious, even if it isn't the best or most comprehensive way we can handle it in all cases.

Test Plan: {F2566003}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12174, T8033

Differential Revision: https://secure.phabricator.com/D17308
This commit is contained in:
epriestley 2017-02-03 09:54:39 -08:00
parent d054f87f93
commit 42743810e9
3 changed files with 39 additions and 12 deletions

View file

@ -72,8 +72,10 @@ final class PhabricatorDashboardPanelRenderingEngine extends Phobject {
if (!$panel) { if (!$panel) {
return $this->renderErrorPanel( return $this->renderErrorPanel(
pht('Missing Panel'), pht('Missing or Restricted Panel'),
pht('This panel does not exist.')); pht(
'This panel does not exist, or you do not have permission '.
'to see it.'));
} }
$panel_type = $panel->getImplementation(); $panel_type = $panel->getImplementation();
@ -166,10 +168,13 @@ final class PhabricatorDashboardPanelRenderingEngine extends Phobject {
} }
$icon = id(new PHUIIconView()) $icon = id(new PHUIIconView())
->setIcon('fa-warning red msr'); ->setIcon('fa-warning red msr');
$content = id(new PHUIBoxView()) $content = id(new PHUIBoxView())
->addClass('dashboard-box') ->addClass('dashboard-box')
->addMargin(PHUI::MARGIN_MEDIUM)
->appendChild($icon) ->appendChild($icon)
->appendChild($body); ->appendChild($body);
return $this->renderPanelDiv( return $this->renderPanelDiv(
$content, $content,
$header); $header);
@ -203,10 +208,17 @@ final class PhabricatorDashboardPanelRenderingEngine extends Phobject {
$box->appendChild($content); $box->appendChild($content);
} }
$box->setHeader($header) $box
->setHeader($header)
->setID($id) ->setID($id)
->addSigil('dashboard-panel') ->addSigil('dashboard-panel');
->setMetadata(array('objectPHID' => $panel->getPHID()));
if ($panel) {
$box->setMetadata(
array(
'objectPHID' => $panel->getPHID(),
));
}
return phutil_tag_div('dashboard-pane', $box); return phutil_tag_div('dashboard-pane', $box);
} }

View file

@ -32,7 +32,7 @@ final class PhabricatorDashboardRenderingEngine extends Phobject {
$dashboard_id = celerity_generate_unique_node_id(); $dashboard_id = celerity_generate_unique_node_id();
$result = id(new AphrontMultiColumnView()) $result = id(new AphrontMultiColumnView())
->setID($dashboard_id) ->setID($dashboard_id)
->setFluidlayout(true) ->setFluidLayout(true)
->setGutter(AphrontMultiColumnView::GUTTER_LARGE); ->setGutter(AphrontMultiColumnView::GUTTER_LARGE);
if ($this->arrangeMode) { if ($this->arrangeMode) {
@ -43,17 +43,27 @@ final class PhabricatorDashboardRenderingEngine extends Phobject {
foreach ($panel_grid_locations as $column => $panel_column_locations) { foreach ($panel_grid_locations as $column => $panel_column_locations) {
$panel_phids = $panel_column_locations; $panel_phids = $panel_column_locations;
$column_panels = array_select_keys($panels, $panel_phids);
// TODO: This list may contain duplicates when the dashboard itself
// does not? Perhaps this is related to T10612. For now, just unique
// the list before moving on.
$panel_phids = array_unique($panel_phids);
$column_result = array(); $column_result = array();
foreach ($column_panels as $panel) { foreach ($panel_phids as $panel_phid) {
$column_result[] = id(new PhabricatorDashboardPanelRenderingEngine()) $panel_engine = id(new PhabricatorDashboardPanelRenderingEngine())
->setViewer($viewer) ->setViewer($viewer)
->setPanel($panel)
->setDashboardID($dashboard->getID()) ->setDashboardID($dashboard->getID())
->setEnableAsyncRendering(true) ->setEnableAsyncRendering(true)
->setParentPanelPHIDs(array()) ->setParentPanelPHIDs(array())
->setHeaderMode($h_mode) ->setHeaderMode($h_mode);
->renderPanel();
$panel = idx($panels, $panel_phid);
if ($panel) {
$panel_engine->setPanel($panel);
}
$column_result[] = $panel_engine->renderPanel();
} }
$column_class = $layout_config->getColumnClass( $column_class = $layout_config->getColumnClass(
$column, $column,

View file

@ -70,8 +70,13 @@ final class PhabricatorDashboardQuery
$panel_phids = $edge_query->getDestinationPHIDs(); $panel_phids = $edge_query->getDestinationPHIDs();
if ($panel_phids) { if ($panel_phids) {
// NOTE: We explicitly disable policy exceptions when loading panels.
// If a particular panel is invalid or not visible to the viewer,
// we'll still render the dashboard, just not that panel.
$panels = id(new PhabricatorDashboardPanelQuery()) $panels = id(new PhabricatorDashboardPanelQuery())
->setParentQuery($this) ->setParentQuery($this)
->setRaisePolicyExceptions(false)
->setViewer($this->getViewer()) ->setViewer($this->getViewer())
->withPHIDs($panel_phids) ->withPHIDs($panel_phids)
->execute(); ->execute();