Differential D20408 Diff 48715 src/applications/dashboard/editor/PhabricatorDashboardPanelEditEngine.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/dashboard/editor/PhabricatorDashboardPanelEditEngine.php
| <?php | <?php | ||||
| final class PhabricatorDashboardPanelEditEngine | final class PhabricatorDashboardPanelEditEngine | ||||
| extends PhabricatorEditEngine { | extends PhabricatorEditEngine { | ||||
| const ENGINECONST = 'dashboard.panel'; | const ENGINECONST = 'dashboard.panel'; | ||||
| private $panelType; | private $panelType; | ||||
| private $dashboard; | private $contextObject; | ||||
| private $columnID; | private $columnKey; | ||||
| public function setPanelType($panel_type) { | public function setPanelType($panel_type) { | ||||
| $this->panelType = $panel_type; | $this->panelType = $panel_type; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getPanelType() { | public function getPanelType() { | ||||
| return $this->panelType; | return $this->panelType; | ||||
| } | } | ||||
| public function setDashboard(PhabricatorDashboard $dashboard) { | public function setContextObject($context) { | ||||
| $this->dashboard = $dashboard; | $this->contextObject = $context; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getDashboard() { | public function getContextObject() { | ||||
| return $this->dashboard; | return $this->contextObject; | ||||
| } | } | ||||
| public function setColumnID($column_id) { | public function setColumnKey($column_key) { | ||||
| $this->columnID = $column_id; | $this->columnKey = $column_key; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getColumnID() { | public function getColumnKey() { | ||||
| return $this->columnID; | return $this->columnKey; | ||||
| } | } | ||||
| public function isEngineConfigurable() { | public function isEngineConfigurable() { | ||||
| return false; | return false; | ||||
| } | } | ||||
| public function getEngineName() { | public function getEngineName() { | ||||
| return pht('Dashboard Panels'); | return pht('Dashboard Panels'); | ||||
| Show All 34 Lines | protected function getObjectCreateTitleText($object) { | ||||
| return pht('Create Dashboard Panel'); | return pht('Create Dashboard Panel'); | ||||
| } | } | ||||
| protected function getObjectCreateButtonText($object) { | protected function getObjectCreateButtonText($object) { | ||||
| return pht('Create Panel'); | return pht('Create Panel'); | ||||
| } | } | ||||
| protected function getObjectCreateCancelURI($object) { | protected function getObjectCreateCancelURI($object) { | ||||
| $dashboard = $this->getDashboard(); | $context = $this->getContextObject(); | ||||
| if ($dashboard) { | if ($context) { | ||||
| return $dashboard->getURI(); | return $context->getURI(); | ||||
| } | } | ||||
| return parent::getObjectCreateCancelURI($object); | return parent::getObjectCreateCancelURI($object); | ||||
| } | } | ||||
| public function getEffectiveObjectEditDoneURI($object) { | public function getEffectiveObjectEditDoneURI($object) { | ||||
| $dashboard = $this->getDashboard(); | $context = $this->getContextObject(); | ||||
| if ($dashboard) { | if ($context) { | ||||
| return $dashboard->getURI(); | return $context->getURI(); | ||||
| } | } | ||||
| return parent::getEffectiveObjectEditDoneURI($object); | return parent::getEffectiveObjectEditDoneURI($object); | ||||
| } | } | ||||
| protected function getObjectEditCancelURI($object) { | protected function getObjectEditCancelURI($object) { | ||||
| $dashboard = $this->getDashboard(); | $context = $this->getContextObject(); | ||||
| if ($dashboard) { | if ($context) { | ||||
| return $dashboard->getURI(); | return $context->getURI(); | ||||
| } | } | ||||
| return parent::getObjectEditCancelURI($object); | return parent::getObjectEditCancelURI($object); | ||||
| } | } | ||||
| protected function getObjectEditTitleText($object) { | protected function getObjectEditTitleText($object) { | ||||
| return pht('Edit Panel: %s', $object->getName()); | return pht('Edit Panel: %s', $object->getName()); | ||||
| } | } | ||||
| Show All 10 Lines | protected function getObjectName() { | ||||
| return pht('Dashboard Panel'); | return pht('Dashboard Panel'); | ||||
| } | } | ||||
| protected function getObjectViewURI($object) { | protected function getObjectViewURI($object) { | ||||
| return $object->getURI(); | return $object->getURI(); | ||||
| } | } | ||||
| protected function didApplyTransactions($object, array $xactions) { | protected function didApplyTransactions($object, array $xactions) { | ||||
| $dashboard = $this->getDashboard(); | $context = $this->getContextObject(); | ||||
| if ($dashboard) { | |||||
| if ($context instanceof PhabricatorDashboard) { | |||||
| $viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
| $controller = $this->getController(); | $controller = $this->getController(); | ||||
| $request = $controller->getRequest(); | $request = $controller->getRequest(); | ||||
| PhabricatorDashboardTransactionEditor::addPanelToDashboard( | $dashboard = $context; | ||||
| $viewer, | |||||
| PhabricatorContentSource::newFromRequest($request), | $xactions = array(); | ||||
| $object, | |||||
| $dashboard, | $ref_list = clone $dashboard->getPanelRefList(); | ||||
| (int)$this->getColumnID()); | |||||
| $ref_list->newPanelRef($object, $this->getColumnKey()); | |||||
| $new_panels = $ref_list->toDictionary(); | |||||
| $xactions[] = $dashboard->getApplicationTransactionTemplate() | |||||
| ->setTransactionType( | |||||
| PhabricatorDashboardPanelsTransaction::TRANSACTIONTYPE) | |||||
| ->setNewValue($new_panels); | |||||
| $editor = $dashboard->getApplicationTransactionEditor() | |||||
| ->setActor($viewer) | |||||
| ->setContentSourceFromRequest($request) | |||||
| ->setContinueOnNoEffect(true) | |||||
| ->setContinueOnMissingFields(true); | |||||
| $editor->applyTransactions($dashboard, $xactions); | |||||
| } | } | ||||
| } | } | ||||
| protected function buildCustomEditFields($object) { | protected function buildCustomEditFields($object) { | ||||
| $fields = array( | $fields = array( | ||||
| id(new PhabricatorTextEditField()) | id(new PhabricatorTextEditField()) | ||||
| ->setKey('name') | ->setKey('name') | ||||
| ->setLabel(pht('Name')) | ->setLabel(pht('Name')) | ||||
| Show All 18 Lines | |||||