Page MenuHomePhabricator

D16226.id39030.diff
No OneTemporary

D16226.id39030.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2295,7 +2295,10 @@
'PhabricatorDashboardPanelArchiveController' => 'applications/dashboard/controller/PhabricatorDashboardPanelArchiveController.php',
'PhabricatorDashboardPanelCoreCustomField' => 'applications/dashboard/customfield/PhabricatorDashboardPanelCoreCustomField.php',
'PhabricatorDashboardPanelCustomField' => 'applications/dashboard/customfield/PhabricatorDashboardPanelCustomField.php',
+ 'PhabricatorDashboardPanelEditConduitAPIMethod' => 'applications/dashboard/conduit/PhabricatorDashboardPanelEditConduitAPIMethod.php',
'PhabricatorDashboardPanelEditController' => 'applications/dashboard/controller/PhabricatorDashboardPanelEditController.php',
+ 'PhabricatorDashboardPanelEditEngine' => 'applications/dashboard/editor/PhabricatorDashboardPanelEditEngine.php',
+ 'PhabricatorDashboardPanelEditproController' => 'applications/dashboard/controller/PhabricatorDashboardPanelEditproController.php',
'PhabricatorDashboardPanelHasDashboardEdgeType' => 'applications/dashboard/edge/PhabricatorDashboardPanelHasDashboardEdgeType.php',
'PhabricatorDashboardPanelListController' => 'applications/dashboard/controller/PhabricatorDashboardPanelListController.php',
'PhabricatorDashboardPanelPHIDType' => 'applications/dashboard/phid/PhabricatorDashboardPanelPHIDType.php',
@@ -6951,7 +6954,10 @@
'PhabricatorStandardCustomFieldInterface',
),
'PhabricatorDashboardPanelCustomField' => 'PhabricatorCustomField',
+ 'PhabricatorDashboardPanelEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod',
'PhabricatorDashboardPanelEditController' => 'PhabricatorDashboardController',
+ 'PhabricatorDashboardPanelEditEngine' => 'PhabricatorEditEngine',
+ 'PhabricatorDashboardPanelEditproController' => 'PhabricatorDashboardController',
'PhabricatorDashboardPanelHasDashboardEdgeType' => 'PhabricatorEdgeType',
'PhabricatorDashboardPanelListController' => 'PhabricatorDashboardController',
'PhabricatorDashboardPanelPHIDType' => 'PhabricatorPHIDType',
diff --git a/src/applications/dashboard/application/PhabricatorDashboardApplication.php b/src/applications/dashboard/application/PhabricatorDashboardApplication.php
--- a/src/applications/dashboard/application/PhabricatorDashboardApplication.php
+++ b/src/applications/dashboard/application/PhabricatorDashboardApplication.php
@@ -40,6 +40,8 @@
'(?:query/(?P<queryKey>[^/]+)/)?'
=> 'PhabricatorDashboardPanelListController',
'create/' => 'PhabricatorDashboardPanelEditController',
+ $this->getEditRoutePattern('editpro/')
+ => 'PhabricatorDashboardPanelEditproController',
'edit/(?:(?P<id>\d+)/)?' => 'PhabricatorDashboardPanelEditController',
'render/(?P<id>\d+)/' => 'PhabricatorDashboardPanelRenderController',
'archive/(?P<id>\d+)/'
diff --git a/src/applications/dashboard/conduit/PhabricatorDashboardPanelEditConduitAPIMethod.php b/src/applications/dashboard/conduit/PhabricatorDashboardPanelEditConduitAPIMethod.php
new file mode 100644
--- /dev/null
+++ b/src/applications/dashboard/conduit/PhabricatorDashboardPanelEditConduitAPIMethod.php
@@ -0,0 +1,20 @@
+<?php
+
+final class PhabricatorDashboardPanelEditConduitAPIMethod
+ extends PhabricatorEditEngineAPIMethod {
+
+ public function getAPIMethodName() {
+ return 'dashboard.panel.edit';
+ }
+
+ public function newEditEngine() {
+ return new PhabricatorDashboardPanelEditEngine();
+ }
+
+ public function getMethodSummary() {
+ return pht(
+ 'Apply transactions to create a new dashboard panel or edit an '.
+ 'existing one.');
+ }
+
+}
diff --git a/src/applications/dashboard/controller/PhabricatorDashboardPanelEditproController.php b/src/applications/dashboard/controller/PhabricatorDashboardPanelEditproController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/dashboard/controller/PhabricatorDashboardPanelEditproController.php
@@ -0,0 +1,105 @@
+<?php
+
+final class PhabricatorDashboardPanelEditproController
+ extends PhabricatorDashboardController {
+
+ public function handleRequest(AphrontRequest $request) {
+ $engine = id(new PhabricatorDashboardPanelEditEngine())
+ ->setController($this);
+
+ $id = $request->getURIData('id');
+ if (!$id) {
+ $list_uri = $this->getApplicationURI('panel/');
+
+ $panel_type = $request->getStr('panelType');
+ $panel_types = PhabricatorDashboardPanelType::getAllPanelTypes();
+ if (empty($panel_types[$panel_type])) {
+ return $this->buildPanelTypeResponse($list_uri);
+ }
+
+ $engine
+ ->addContextParameter('panelType', $panel_type)
+ ->setPanelType($panel_type);
+ }
+
+ return $engine->buildResponse();
+ }
+
+ private function buildPanelTypeResponse($cancel_uri) {
+ $panel_types = PhabricatorDashboardPanelType::getAllPanelTypes();
+
+ $viewer = $this->getViewer();
+ $request = $this->getRequest();
+
+ $e_type = null;
+ $errors = array();
+ if ($request->isFormPost()) {
+ $e_type = pht('Required');
+ $errors[] = pht(
+ 'To create a new dashboard panel, you must select a panel type.');
+ }
+
+ $type_control = id(new AphrontFormRadioButtonControl())
+ ->setLabel(pht('Panel Type'))
+ ->setName('panelType')
+ ->setError($e_type);
+
+ foreach ($panel_types as $key => $type) {
+ $type_control->addButton(
+ $key,
+ $type->getPanelTypeName(),
+ $type->getPanelTypeDescription());
+ }
+
+ $form = id(new AphrontFormView())
+ ->setUser($viewer)
+ ->appendRemarkupInstructions(
+ pht('Choose the type of dashboard panel to create:'))
+ ->appendChild($type_control);
+
+ if ($request->isAjax()) {
+ return $this->newDialog()
+ ->setTitle(pht('Add New Panel'))
+ ->setWidth(AphrontDialogView::WIDTH_FORM)
+ ->setErrors($errors)
+ ->appendForm($form)
+ ->addCancelButton($cancel_uri)
+ ->addSubmitButton(pht('Continue'));
+ }
+
+ $form->appendChild(
+ id(new AphrontFormSubmitControl())
+ ->setValue(pht('Continue'))
+ ->addCancelButton($cancel_uri));
+
+ $title = pht('Create Dashboard Panel');
+ $header_icon = 'fa-plus-square';
+
+ $crumbs = $this->buildApplicationCrumbs();
+ $crumbs->addTextCrumb(
+ pht('Panels'),
+ $this->getApplicationURI('panel/'));
+ $crumbs->addTextCrumb(pht('New Panel'));
+ $crumbs->setBorder(true);
+
+ $box = id(new PHUIObjectBoxView())
+ ->setHeaderText(pht('Panel'))
+ ->setFormErrors($errors)
+ ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
+ ->setForm($form);
+
+ $header = id(new PHUIHeaderView())
+ ->setHeader($title)
+ ->setHeaderIcon($header_icon);
+
+ $view = id(new PHUITwoColumnView())
+ ->setHeader($header)
+ ->setFooter($box);
+
+ return $this->newPage()
+ ->setTitle($title)
+ ->setCrumbs($crumbs)
+ ->appendChild($view);
+ }
+
+}
diff --git a/src/applications/dashboard/customfield/PhabricatorDashboardPanelCoreCustomField.php b/src/applications/dashboard/customfield/PhabricatorDashboardPanelCoreCustomField.php
--- a/src/applications/dashboard/customfield/PhabricatorDashboardPanelCoreCustomField.php
+++ b/src/applications/dashboard/customfield/PhabricatorDashboardPanelCoreCustomField.php
@@ -9,6 +9,10 @@
}
public function createFields($object) {
+ if (!$object->getPanelType()) {
+ return array();
+ }
+
$impl = $object->requireImplementation();
$specs = $impl->getFieldSpecifications();
return PhabricatorStandardCustomField::buildStandardFields($this, $specs);
diff --git a/src/applications/dashboard/editor/PhabricatorDashboardPanelEditEngine.php b/src/applications/dashboard/editor/PhabricatorDashboardPanelEditEngine.php
new file mode 100644
--- /dev/null
+++ b/src/applications/dashboard/editor/PhabricatorDashboardPanelEditEngine.php
@@ -0,0 +1,96 @@
+<?php
+
+final class PhabricatorDashboardPanelEditEngine
+ extends PhabricatorEditEngine {
+
+ const ENGINECONST = 'dashboard.panel';
+
+ private $panelType;
+
+ public function setPanelType($panel_type) {
+ $this->panelType = $panel_type;
+ return $this;
+ }
+
+ public function getPanelType() {
+ return $this->panelType;
+ }
+
+ public function isEngineConfigurable() {
+ return false;
+ }
+
+ public function getEngineName() {
+ return pht('Dashboard Panels');
+ }
+
+ public function getSummaryHeader() {
+ return pht('Edit Dashboard Panels');
+ }
+
+ public function getSummaryText() {
+ return pht('This engine is used to modify dashboard panels.');
+ }
+
+ public function getEngineApplicationClass() {
+ return 'PhabricatorSearchApplication';
+ }
+
+ protected function newEditableObject() {
+ $viewer = $this->getViewer();
+ $panel = PhabricatorDashboardPanel::initializeNewPanel($viewer);
+
+ if ($this->panelType) {
+ $panel->setPanelType($this->panelType);
+ }
+
+ return $panel;
+ }
+
+ protected function newObjectQuery() {
+ return new PhabricatorDashboardPanelQuery();
+ }
+
+ protected function getObjectCreateTitleText($object) {
+ return pht('Create Dashboard Panel');
+ }
+
+ protected function getObjectCreateButtonText($object) {
+ return pht('Create Panel');
+ }
+
+ protected function getObjectEditTitleText($object) {
+ return pht('Edit Panel: %s', $object->getName());
+ }
+
+ protected function getObjectEditShortText($object) {
+ return pht('Edit Panel');
+ }
+
+ protected function getObjectCreateShortText() {
+ return pht('Edit Panel');
+ }
+
+ protected function getObjectName() {
+ return pht('Dashboard Panel');
+ }
+
+ protected function getObjectViewURI($object) {
+ return $object->getURI();
+ }
+
+ protected function buildCustomEditFields($object) {
+ return array(
+ id(new PhabricatorTextEditField())
+ ->setKey('name')
+ ->setLabel(pht('Name'))
+ ->setDescription(pht('Name of the panel.'))
+ ->setConduitDescription(pht('Rename the panel.'))
+ ->setConduitTypeDescription(pht('New panel name.'))
+ ->setTransactionType(PhabricatorDashboardPanelTransaction::TYPE_NAME)
+ ->setIsRequired(true)
+ ->setValue($object->getName()),
+ );
+ }
+
+}
diff --git a/src/applications/dashboard/storage/PhabricatorDashboardPanel.php b/src/applications/dashboard/storage/PhabricatorDashboardPanel.php
--- a/src/applications/dashboard/storage/PhabricatorDashboardPanel.php
+++ b/src/applications/dashboard/storage/PhabricatorDashboardPanel.php
@@ -72,6 +72,10 @@
return 'W'.$this->getID();
}
+ public function getURI() {
+ return '/'.$this->getMonogram();
+ }
+
public function getPanelTypes() {
$panel_types = PhabricatorDashboardPanelType::getAllPanelTypes();
$panel_types = mpull($panel_types, 'getPanelTypeName', 'getPanelTypeKey');

File Metadata

Mime Type
text/plain
Expires
Mon, Oct 21, 9:35 AM (3 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6738978
Default Alt Text
D16226.id39030.diff (10 KB)

Event Timeline