@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+39 -12
+17 -5
src/applications/dashboard/engine/PhabricatorDashboardPanelRenderingEngine.php
··· 72 72 73 73 if (!$panel) { 74 74 return $this->renderErrorPanel( 75 - pht('Missing Panel'), 76 - pht('This panel does not exist.')); 75 + pht('Missing or Restricted Panel'), 76 + pht( 77 + 'This panel does not exist, or you do not have permission '. 78 + 'to see it.')); 77 79 } 78 80 79 81 $panel_type = $panel->getImplementation(); ··· 166 168 } 167 169 $icon = id(new PHUIIconView()) 168 170 ->setIcon('fa-warning red msr'); 171 + 169 172 $content = id(new PHUIBoxView()) 170 173 ->addClass('dashboard-box') 174 + ->addMargin(PHUI::MARGIN_MEDIUM) 171 175 ->appendChild($icon) 172 176 ->appendChild($body); 177 + 173 178 return $this->renderPanelDiv( 174 179 $content, 175 180 $header); ··· 203 208 $box->appendChild($content); 204 209 } 205 210 206 - $box->setHeader($header) 211 + $box 212 + ->setHeader($header) 207 213 ->setID($id) 208 - ->addSigil('dashboard-panel') 209 - ->setMetadata(array('objectPHID' => $panel->getPHID())); 214 + ->addSigil('dashboard-panel'); 215 + 216 + if ($panel) { 217 + $box->setMetadata( 218 + array( 219 + 'objectPHID' => $panel->getPHID(), 220 + )); 221 + } 210 222 211 223 return phutil_tag_div('dashboard-pane', $box); 212 224 }
+17 -7
src/applications/dashboard/engine/PhabricatorDashboardRenderingEngine.php
··· 32 32 $dashboard_id = celerity_generate_unique_node_id(); 33 33 $result = id(new AphrontMultiColumnView()) 34 34 ->setID($dashboard_id) 35 - ->setFluidlayout(true) 35 + ->setFluidLayout(true) 36 36 ->setGutter(AphrontMultiColumnView::GUTTER_LARGE); 37 37 38 38 if ($this->arrangeMode) { ··· 43 43 44 44 foreach ($panel_grid_locations as $column => $panel_column_locations) { 45 45 $panel_phids = $panel_column_locations; 46 - $column_panels = array_select_keys($panels, $panel_phids); 46 + 47 + // TODO: This list may contain duplicates when the dashboard itself 48 + // does not? Perhaps this is related to T10612. For now, just unique 49 + // the list before moving on. 50 + $panel_phids = array_unique($panel_phids); 51 + 47 52 $column_result = array(); 48 - foreach ($column_panels as $panel) { 49 - $column_result[] = id(new PhabricatorDashboardPanelRenderingEngine()) 53 + foreach ($panel_phids as $panel_phid) { 54 + $panel_engine = id(new PhabricatorDashboardPanelRenderingEngine()) 50 55 ->setViewer($viewer) 51 - ->setPanel($panel) 52 56 ->setDashboardID($dashboard->getID()) 53 57 ->setEnableAsyncRendering(true) 54 58 ->setParentPanelPHIDs(array()) 55 - ->setHeaderMode($h_mode) 56 - ->renderPanel(); 59 + ->setHeaderMode($h_mode); 60 + 61 + $panel = idx($panels, $panel_phid); 62 + if ($panel) { 63 + $panel_engine->setPanel($panel); 64 + } 65 + 66 + $column_result[] = $panel_engine->renderPanel(); 57 67 } 58 68 $column_class = $layout_config->getColumnClass( 59 69 $column,
+5
src/applications/dashboard/query/PhabricatorDashboardQuery.php
··· 70 70 71 71 $panel_phids = $edge_query->getDestinationPHIDs(); 72 72 if ($panel_phids) { 73 + // NOTE: We explicitly disable policy exceptions when loading panels. 74 + // If a particular panel is invalid or not visible to the viewer, 75 + // we'll still render the dashboard, just not that panel. 76 + 73 77 $panels = id(new PhabricatorDashboardPanelQuery()) 74 78 ->setParentQuery($this) 79 + ->setRaisePolicyExceptions(false) 75 80 ->setViewer($this->getViewer()) 76 81 ->withPHIDs($panel_phids) 77 82 ->execute();