mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 16:52:41 +01:00
On Dashboards, distinguish between invalid panels and restricted panels
Summary: Depends on D20374. Panels may not be visible if they are restricted (no permission) or if they are invalid (e.g., the panel was deleted). Render these as two separate states instead of one big combined state. Test Plan: {F6334756} Reviewers: amckinley Reviewed By: amckinley Differential Revision: https://secure.phabricator.com/D20376
This commit is contained in:
parent
4d0904ef95
commit
2bd1bb52e4
2 changed files with 35 additions and 7 deletions
|
@ -14,6 +14,7 @@ final class PhabricatorDashboardPanelRenderingEngine extends Phobject {
|
|||
private $headerMode = self::HEADER_MODE_NORMAL;
|
||||
private $dashboardID;
|
||||
private $movable = true;
|
||||
private $panelHandle;
|
||||
|
||||
public function setDashboardID($id) {
|
||||
$this->dashboardID = $id;
|
||||
|
@ -33,6 +34,15 @@ final class PhabricatorDashboardPanelRenderingEngine extends Phobject {
|
|||
return $this->headerMode;
|
||||
}
|
||||
|
||||
public function setPanelHandle(PhabricatorObjectHandle $panel_handle) {
|
||||
$this->panelHandle = $panel_handle;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPanelHandle() {
|
||||
return $this->panelHandle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow the engine to render the panel via Ajax.
|
||||
*/
|
||||
|
@ -90,11 +100,19 @@ final class PhabricatorDashboardPanelRenderingEngine extends Phobject {
|
|||
$panel = $this->getPanel();
|
||||
|
||||
if (!$panel) {
|
||||
$handle = $this->getPanelHandle();
|
||||
if ($handle->getPolicyFiltered()) {
|
||||
return $this->renderErrorPanel(
|
||||
pht('Missing or Restricted Panel'),
|
||||
pht('Restricted Panel'),
|
||||
pht(
|
||||
'This panel does not exist, or you do not have permission '.
|
||||
'to see it.'));
|
||||
'You do not have permission to see this panel.'));
|
||||
} else {
|
||||
return $this->renderErrorPanel(
|
||||
pht('Invalid Panel'),
|
||||
pht(
|
||||
'This panel is invalid or does not exist. It may have been '.
|
||||
'deleted.'));
|
||||
}
|
||||
}
|
||||
|
||||
$panel_type = $panel->getImplementation();
|
||||
|
@ -185,12 +203,13 @@ final class PhabricatorDashboardPanelRenderingEngine extends Phobject {
|
|||
->setHeader($title);
|
||||
break;
|
||||
}
|
||||
|
||||
$icon = id(new PHUIIconView())
|
||||
->setIcon('fa-warning red msr');
|
||||
|
||||
$content = id(new PHUIBoxView())
|
||||
->addClass('dashboard-box')
|
||||
->addMargin(PHUI::MARGIN_MEDIUM)
|
||||
->addMargin(PHUI::MARGIN_LARGE)
|
||||
->appendChild($icon)
|
||||
->appendChild($body);
|
||||
|
||||
|
|
|
@ -41,6 +41,14 @@ final class PhabricatorDashboardRenderingEngine extends Phobject {
|
|||
$h_mode = PhabricatorDashboardPanelRenderingEngine::HEADER_MODE_NORMAL;
|
||||
}
|
||||
|
||||
$panel_phids = array();
|
||||
foreach ($panel_grid_locations as $panel_column_locations) {
|
||||
foreach ($panel_column_locations as $panel_phid) {
|
||||
$panel_phids[] = $panel_phid;
|
||||
}
|
||||
}
|
||||
$handles = $viewer->loadHandles($panel_phids);
|
||||
|
||||
foreach ($panel_grid_locations as $column => $panel_column_locations) {
|
||||
$panel_phids = $panel_column_locations;
|
||||
|
||||
|
@ -57,7 +65,8 @@ final class PhabricatorDashboardRenderingEngine extends Phobject {
|
|||
->setEnableAsyncRendering(true)
|
||||
->setPanelPHID($panel_phid)
|
||||
->setParentPanelPHIDs(array())
|
||||
->setHeaderMode($h_mode);
|
||||
->setHeaderMode($h_mode)
|
||||
->setPanelHandle($handles[$panel_phid]);
|
||||
|
||||
$panel = idx($panels, $panel_phid);
|
||||
if ($panel) {
|
||||
|
|
Loading…
Reference in a new issue