Differential D20376 Diff 48641 src/applications/dashboard/engine/PhabricatorDashboardPanelRenderingEngine.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/dashboard/engine/PhabricatorDashboardPanelRenderingEngine.php
| <?php | <?php | ||||
| final class PhabricatorDashboardPanelRenderingEngine extends Phobject { | final class PhabricatorDashboardPanelRenderingEngine extends Phobject { | ||||
| const HEADER_MODE_NORMAL = 'normal'; | const HEADER_MODE_NORMAL = 'normal'; | ||||
| const HEADER_MODE_NONE = 'none'; | const HEADER_MODE_NONE = 'none'; | ||||
| const HEADER_MODE_EDIT = 'edit'; | const HEADER_MODE_EDIT = 'edit'; | ||||
| private $panel; | private $panel; | ||||
| private $panelPHID; | private $panelPHID; | ||||
| private $viewer; | private $viewer; | ||||
| private $enableAsyncRendering; | private $enableAsyncRendering; | ||||
| private $parentPanelPHIDs; | private $parentPanelPHIDs; | ||||
| 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; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getDashboardID() { | public function getDashboardID() { | ||||
| return $this->dashboardID; | return $this->dashboardID; | ||||
| } | } | ||||
| public function setHeaderMode($header_mode) { | public function setHeaderMode($header_mode) { | ||||
| $this->headerMode = $header_mode; | $this->headerMode = $header_mode; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getHeaderMode() { | public function getHeaderMode() { | ||||
| 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. | ||||
| */ | */ | ||||
| public function setEnableAsyncRendering($enable) { | public function setEnableAsyncRendering($enable) { | ||||
| $this->enableAsyncRendering = $enable; | $this->enableAsyncRendering = $enable; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | final class PhabricatorDashboardPanelRenderingEngine extends Phobject { | ||||
| public function getPanelPHID() { | public function getPanelPHID() { | ||||
| return $this->panelPHID; | return $this->panelPHID; | ||||
| } | } | ||||
| public function renderPanel() { | public function renderPanel() { | ||||
| $panel = $this->getPanel(); | $panel = $this->getPanel(); | ||||
| if (!$panel) { | if (!$panel) { | ||||
| $handle = $this->getPanelHandle(); | |||||
| if ($handle->getPolicyFiltered()) { | |||||
| return $this->renderErrorPanel( | return $this->renderErrorPanel( | ||||
| pht('Missing or Restricted Panel'), | pht('Restricted Panel'), | ||||
| pht( | pht( | ||||
| 'This panel does not exist, or you do not have permission '. | 'You do not have permission to see this panel.')); | ||||
| 'to see it.')); | } 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(); | ||||
| if (!$panel_type) { | if (!$panel_type) { | ||||
| return $this->renderErrorPanel( | return $this->renderErrorPanel( | ||||
| $panel->getName(), | $panel->getName(), | ||||
| pht( | pht( | ||||
| 'This panel has type "%s", but that panel type is not known to '. | 'This panel has type "%s", but that panel type is not known to '. | ||||
| ▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | switch ($this->getHeaderMode()) { | ||||
| $header = $this->addPanelHeaderActions($header); | $header = $this->addPanelHeaderActions($header); | ||||
| break; | break; | ||||
| case self::HEADER_MODE_NORMAL: | case self::HEADER_MODE_NORMAL: | ||||
| default: | default: | ||||
| $header = id(new PHUIHeaderView()) | $header = id(new PHUIHeaderView()) | ||||
| ->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); | ||||
| return $this->renderPanelDiv( | return $this->renderPanelDiv( | ||||
| $content, | $content, | ||||
| $header); | $header); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 171 Lines • Show Last 20 Lines | |||||