Differential D17314 Diff 41641 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 $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; | ||||
public function setDashboardID($id) { | public function setDashboardID($id) { | ||||
$this->dashboardID = $id; | $this->dashboardID = $id; | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | public function setPanel(PhabricatorDashboardPanel $panel) { | ||||
$this->panel = $panel; | $this->panel = $panel; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getPanel() { | public function getPanel() { | ||||
return $this->panel; | return $this->panel; | ||||
} | } | ||||
public function setPanelPHID($panel_phid) { | |||||
$this->panelPHID = $panel_phid; | |||||
return $this; | |||||
} | |||||
public function getPanelPHID() { | |||||
return $this->panelPHID; | |||||
} | |||||
public function renderPanel() { | public function renderPanel() { | ||||
$panel = $this->getPanel(); | $panel = $this->getPanel(); | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
if (!$panel) { | if (!$panel) { | ||||
return $this->renderErrorPanel( | return $this->renderErrorPanel( | ||||
pht('Missing or Restricted Panel'), | pht('Missing or Restricted Panel'), | ||||
pht( | pht( | ||||
▲ Show 20 Lines • Show All 173 Lines • ▼ Show 20 Lines | private function renderPanelHeader() { | ||||
} | } | ||||
return $header; | return $header; | ||||
} | } | ||||
private function addPanelHeaderActions( | private function addPanelHeaderActions( | ||||
PHUIHeaderView $header) { | PHUIHeaderView $header) { | ||||
$panel = $this->getPanel(); | $panel = $this->getPanel(); | ||||
if (!$panel) { | |||||
return $header; | |||||
} | |||||
$dashboard_id = $this->getDashboardID(); | $dashboard_id = $this->getDashboardID(); | ||||
$edit_uri = id(new PhutilURI( | |||||
'/dashboard/panel/edit/'.$panel->getID().'/')); | if ($panel) { | ||||
$panel_id = $panel->getID(); | |||||
$edit_uri = "/dashboard/panel/edit/{$panel_id}/"; | |||||
$edit_uri = new PhutilURI($edit_uri); | |||||
if ($dashboard_id) { | if ($dashboard_id) { | ||||
$edit_uri->setQueryParam('dashboardID', $dashboard_id); | $edit_uri->setQueryParam('dashboardID', $dashboard_id); | ||||
} | } | ||||
$action_edit = id(new PHUIIconView()) | $action_edit = id(new PHUIIconView()) | ||||
->setIcon('fa-pencil') | ->setIcon('fa-pencil') | ||||
->setWorkflow(true) | ->setWorkflow(true) | ||||
->setHref((string)$edit_uri); | ->setHref((string)$edit_uri); | ||||
$header->addActionItem($action_edit); | $header->addActionItem($action_edit); | ||||
} | |||||
if ($dashboard_id) { | if ($dashboard_id) { | ||||
$uri = id(new PhutilURI( | $panel_phid = $this->getPanelPHID(); | ||||
'/dashboard/removepanel/'.$dashboard_id.'/')) | |||||
->setQueryParam('panelPHID', $panel->getPHID()); | $remove_uri = "/dashboard/removepanel/{$dashboard_id}/"; | ||||
$remove_uri = id(new PhutilURI($remove_uri)) | |||||
->setQueryParam('panelPHID', $panel_phid); | |||||
$action_remove = id(new PHUIIconView()) | $action_remove = id(new PHUIIconView()) | ||||
->setIcon('fa-trash-o') | ->setIcon('fa-trash-o') | ||||
->setHref((string)$uri) | ->setHref((string)$remove_uri) | ||||
->setWorkflow(true); | ->setWorkflow(true); | ||||
$header->addActionItem($action_remove); | $header->addActionItem($action_remove); | ||||
} | } | ||||
return $header; | return $header; | ||||
} | } | ||||
/** | /** | ||||
* Detect graph cycles in panels, and deeply nested panels. | * Detect graph cycles in panels, and deeply nested panels. | ||||
* | * | ||||
* This method throws if the current rendering stack is too deep or contains | * This method throws if the current rendering stack is too deep or contains | ||||
Show All 34 Lines |