mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 23:02:42 +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 $headerMode = self::HEADER_MODE_NORMAL;
|
||||||
private $dashboardID;
|
private $dashboardID;
|
||||||
private $movable = true;
|
private $movable = true;
|
||||||
|
private $panelHandle;
|
||||||
|
|
||||||
public function setDashboardID($id) {
|
public function setDashboardID($id) {
|
||||||
$this->dashboardID = $id;
|
$this->dashboardID = $id;
|
||||||
|
@ -33,6 +34,15 @@ final class PhabricatorDashboardPanelRenderingEngine extends Phobject {
|
||||||
return $this->headerMode;
|
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.
|
* Allow the engine to render the panel via Ajax.
|
||||||
*/
|
*/
|
||||||
|
@ -90,11 +100,19 @@ final class PhabricatorDashboardPanelRenderingEngine extends Phobject {
|
||||||
$panel = $this->getPanel();
|
$panel = $this->getPanel();
|
||||||
|
|
||||||
if (!$panel) {
|
if (!$panel) {
|
||||||
return $this->renderErrorPanel(
|
$handle = $this->getPanelHandle();
|
||||||
pht('Missing or Restricted Panel'),
|
if ($handle->getPolicyFiltered()) {
|
||||||
pht(
|
return $this->renderErrorPanel(
|
||||||
'This panel does not exist, or you do not have permission '.
|
pht('Restricted Panel'),
|
||||||
'to see it.'));
|
pht(
|
||||||
|
'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();
|
$panel_type = $panel->getImplementation();
|
||||||
|
@ -185,12 +203,13 @@ final class PhabricatorDashboardPanelRenderingEngine extends Phobject {
|
||||||
->setHeader($title);
|
->setHeader($title);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$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)
|
->addMargin(PHUI::MARGIN_LARGE)
|
||||||
->appendChild($icon)
|
->appendChild($icon)
|
||||||
->appendChild($body);
|
->appendChild($body);
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,14 @@ final class PhabricatorDashboardRenderingEngine extends Phobject {
|
||||||
$h_mode = PhabricatorDashboardPanelRenderingEngine::HEADER_MODE_NORMAL;
|
$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) {
|
foreach ($panel_grid_locations as $column => $panel_column_locations) {
|
||||||
$panel_phids = $panel_column_locations;
|
$panel_phids = $panel_column_locations;
|
||||||
|
|
||||||
|
@ -57,7 +65,8 @@ final class PhabricatorDashboardRenderingEngine extends Phobject {
|
||||||
->setEnableAsyncRendering(true)
|
->setEnableAsyncRendering(true)
|
||||||
->setPanelPHID($panel_phid)
|
->setPanelPHID($panel_phid)
|
||||||
->setParentPanelPHIDs(array())
|
->setParentPanelPHIDs(array())
|
||||||
->setHeaderMode($h_mode);
|
->setHeaderMode($h_mode)
|
||||||
|
->setPanelHandle($handles[$panel_phid]);
|
||||||
|
|
||||||
$panel = idx($panels, $panel_phid);
|
$panel = idx($panels, $panel_phid);
|
||||||
if ($panel) {
|
if ($panel) {
|
||||||
|
|
Loading…
Reference in a new issue