@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Implement a "pro" EditEngine for dashboard panels

Summary:
Ref T10855. This can't replace the old edit flow yet, but get the basics in place.

(This is actually much closer to just being able to swap than I anticipated since CustomFields sort of just work, but the exiting flow has some "clone existing panel" / "place directly on dashboard" stuff that this doesn't yet.)

Test Plan: Created and edited a panel by manually using the "editpro" flow.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10855

Differential Revision: https://secure.phabricator.com/D16226

+237 -21
+6 -1
src/__phutil_library_map__.php
··· 2295 2295 'PhabricatorDashboardPanelArchiveController' => 'applications/dashboard/controller/PhabricatorDashboardPanelArchiveController.php', 2296 2296 'PhabricatorDashboardPanelCoreCustomField' => 'applications/dashboard/customfield/PhabricatorDashboardPanelCoreCustomField.php', 2297 2297 'PhabricatorDashboardPanelCustomField' => 'applications/dashboard/customfield/PhabricatorDashboardPanelCustomField.php', 2298 + 'PhabricatorDashboardPanelEditConduitAPIMethod' => 'applications/dashboard/conduit/PhabricatorDashboardPanelEditConduitAPIMethod.php', 2298 2299 'PhabricatorDashboardPanelEditController' => 'applications/dashboard/controller/PhabricatorDashboardPanelEditController.php', 2300 + 'PhabricatorDashboardPanelEditEngine' => 'applications/dashboard/editor/PhabricatorDashboardPanelEditEngine.php', 2301 + 'PhabricatorDashboardPanelEditproController' => 'applications/dashboard/controller/PhabricatorDashboardPanelEditproController.php', 2299 2302 'PhabricatorDashboardPanelHasDashboardEdgeType' => 'applications/dashboard/edge/PhabricatorDashboardPanelHasDashboardEdgeType.php', 2300 2303 'PhabricatorDashboardPanelListController' => 'applications/dashboard/controller/PhabricatorDashboardPanelListController.php', 2301 2304 'PhabricatorDashboardPanelPHIDType' => 'applications/dashboard/phid/PhabricatorDashboardPanelPHIDType.php', ··· 6942 6945 'PhabricatorPolicyInterface', 6943 6946 'PhabricatorCustomFieldInterface', 6944 6947 'PhabricatorFlaggableInterface', 6945 - 'PhabricatorProjectInterface', 6946 6948 'PhabricatorDestructibleInterface', 6947 6949 ), 6948 6950 'PhabricatorDashboardPanelArchiveController' => 'PhabricatorDashboardController', ··· 6951 6953 'PhabricatorStandardCustomFieldInterface', 6952 6954 ), 6953 6955 'PhabricatorDashboardPanelCustomField' => 'PhabricatorCustomField', 6956 + 'PhabricatorDashboardPanelEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod', 6954 6957 'PhabricatorDashboardPanelEditController' => 'PhabricatorDashboardController', 6958 + 'PhabricatorDashboardPanelEditEngine' => 'PhabricatorEditEngine', 6959 + 'PhabricatorDashboardPanelEditproController' => 'PhabricatorDashboardController', 6955 6960 'PhabricatorDashboardPanelHasDashboardEdgeType' => 'PhabricatorEdgeType', 6956 6961 'PhabricatorDashboardPanelListController' => 'PhabricatorDashboardController', 6957 6962 'PhabricatorDashboardPanelPHIDType' => 'PhabricatorPHIDType',
+2
src/applications/dashboard/application/PhabricatorDashboardApplication.php
··· 40 40 '(?:query/(?P<queryKey>[^/]+)/)?' 41 41 => 'PhabricatorDashboardPanelListController', 42 42 'create/' => 'PhabricatorDashboardPanelEditController', 43 + $this->getEditRoutePattern('editpro/') 44 + => 'PhabricatorDashboardPanelEditproController', 43 45 'edit/(?:(?P<id>\d+)/)?' => 'PhabricatorDashboardPanelEditController', 44 46 'render/(?P<id>\d+)/' => 'PhabricatorDashboardPanelRenderController', 45 47 'archive/(?P<id>\d+)/'
+20
src/applications/dashboard/conduit/PhabricatorDashboardPanelEditConduitAPIMethod.php
··· 1 + <?php 2 + 3 + final class PhabricatorDashboardPanelEditConduitAPIMethod 4 + extends PhabricatorEditEngineAPIMethod { 5 + 6 + public function getAPIMethodName() { 7 + return 'dashboard.panel.edit'; 8 + } 9 + 10 + public function newEditEngine() { 11 + return new PhabricatorDashboardPanelEditEngine(); 12 + } 13 + 14 + public function getMethodSummary() { 15 + return pht( 16 + 'Apply transactions to create a new dashboard panel or edit an '. 17 + 'existing one.'); 18 + } 19 + 20 + }
-19
src/applications/dashboard/controller/PhabricatorDashboardPanelEditController.php
··· 51 51 if (!$panel) { 52 52 return new Aphront404Response(); 53 53 } 54 - $v_projects = PhabricatorEdgeQuery::loadDestinationPHIDs( 55 - $panel->getPHID(), 56 - PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); 57 - $v_projects = array_reverse($v_projects); 58 54 59 55 if ($dashboard) { 60 56 $can_edit = PhabricatorPolicyFilter::hasCapability( ··· 84 80 if (empty($types[$type])) { 85 81 return $this->processPanelTypeRequest($request); 86 82 } 87 - $v_projects = array(); 88 83 89 84 $panel->setPanelType($type); 90 85 } ··· 135 130 $v_name = $request->getStr('name'); 136 131 $v_view_policy = $request->getStr('viewPolicy'); 137 132 $v_edit_policy = $request->getStr('editPolicy'); 138 - $v_projects = $request->getArr('projects'); 139 133 140 134 $type_name = PhabricatorDashboardPanelTransaction::TYPE_NAME; 141 135 $type_view_policy = PhabricatorTransactions::TYPE_VIEW_POLICY; ··· 155 149 ->setTransactionType($type_edit_policy) 156 150 ->setNewValue($v_edit_policy); 157 151 158 - $proj_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; 159 - $xactions[] = id(new PhabricatorDashboardPanelTransaction()) 160 - ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) 161 - ->setMetadataValue('edge:type', $proj_edge_type) 162 - ->setNewValue(array('=' => array_fuse($v_projects))); 163 - 164 152 $field_xactions = $field_list->buildFieldTransactionsFromRequest( 165 153 new PhabricatorDashboardPanelTransaction(), 166 154 $request); ··· 237 225 ->setPolicyObject($panel) 238 226 ->setCapability(PhabricatorPolicyCapability::CAN_EDIT) 239 227 ->setPolicies($policies)); 240 - 241 - $form->appendControl( 242 - id(new AphrontFormTokenizerControl()) 243 - ->setLabel(pht('Tags')) 244 - ->setName('projects') 245 - ->setValue($v_projects) 246 - ->setDatasource(new PhabricatorProjectDatasource())); 247 228 248 229 $field_list->appendFieldsToForm($form); 249 230
+105
src/applications/dashboard/controller/PhabricatorDashboardPanelEditproController.php
··· 1 + <?php 2 + 3 + final class PhabricatorDashboardPanelEditproController 4 + extends PhabricatorDashboardController { 5 + 6 + public function handleRequest(AphrontRequest $request) { 7 + $engine = id(new PhabricatorDashboardPanelEditEngine()) 8 + ->setController($this); 9 + 10 + $id = $request->getURIData('id'); 11 + if (!$id) { 12 + $list_uri = $this->getApplicationURI('panel/'); 13 + 14 + $panel_type = $request->getStr('panelType'); 15 + $panel_types = PhabricatorDashboardPanelType::getAllPanelTypes(); 16 + if (empty($panel_types[$panel_type])) { 17 + return $this->buildPanelTypeResponse($list_uri); 18 + } 19 + 20 + $engine 21 + ->addContextParameter('panelType', $panel_type) 22 + ->setPanelType($panel_type); 23 + } 24 + 25 + return $engine->buildResponse(); 26 + } 27 + 28 + private function buildPanelTypeResponse($cancel_uri) { 29 + $panel_types = PhabricatorDashboardPanelType::getAllPanelTypes(); 30 + 31 + $viewer = $this->getViewer(); 32 + $request = $this->getRequest(); 33 + 34 + $e_type = null; 35 + $errors = array(); 36 + if ($request->isFormPost()) { 37 + $e_type = pht('Required'); 38 + $errors[] = pht( 39 + 'To create a new dashboard panel, you must select a panel type.'); 40 + } 41 + 42 + $type_control = id(new AphrontFormRadioButtonControl()) 43 + ->setLabel(pht('Panel Type')) 44 + ->setName('panelType') 45 + ->setError($e_type); 46 + 47 + foreach ($panel_types as $key => $type) { 48 + $type_control->addButton( 49 + $key, 50 + $type->getPanelTypeName(), 51 + $type->getPanelTypeDescription()); 52 + } 53 + 54 + $form = id(new AphrontFormView()) 55 + ->setUser($viewer) 56 + ->appendRemarkupInstructions( 57 + pht('Choose the type of dashboard panel to create:')) 58 + ->appendChild($type_control); 59 + 60 + if ($request->isAjax()) { 61 + return $this->newDialog() 62 + ->setTitle(pht('Add New Panel')) 63 + ->setWidth(AphrontDialogView::WIDTH_FORM) 64 + ->setErrors($errors) 65 + ->appendForm($form) 66 + ->addCancelButton($cancel_uri) 67 + ->addSubmitButton(pht('Continue')); 68 + } 69 + 70 + $form->appendChild( 71 + id(new AphrontFormSubmitControl()) 72 + ->setValue(pht('Continue')) 73 + ->addCancelButton($cancel_uri)); 74 + 75 + $title = pht('Create Dashboard Panel'); 76 + $header_icon = 'fa-plus-square'; 77 + 78 + $crumbs = $this->buildApplicationCrumbs(); 79 + $crumbs->addTextCrumb( 80 + pht('Panels'), 81 + $this->getApplicationURI('panel/')); 82 + $crumbs->addTextCrumb(pht('New Panel')); 83 + $crumbs->setBorder(true); 84 + 85 + $box = id(new PHUIObjectBoxView()) 86 + ->setHeaderText(pht('Panel')) 87 + ->setFormErrors($errors) 88 + ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 89 + ->setForm($form); 90 + 91 + $header = id(new PHUIHeaderView()) 92 + ->setHeader($title) 93 + ->setHeaderIcon($header_icon); 94 + 95 + $view = id(new PHUITwoColumnView()) 96 + ->setHeader($header) 97 + ->setFooter($box); 98 + 99 + return $this->newPage() 100 + ->setTitle($title) 101 + ->setCrumbs($crumbs) 102 + ->appendChild($view); 103 + } 104 + 105 + }
+4
src/applications/dashboard/customfield/PhabricatorDashboardPanelCoreCustomField.php
··· 9 9 } 10 10 11 11 public function createFields($object) { 12 + if (!$object->getPanelType()) { 13 + return array(); 14 + } 15 + 12 16 $impl = $object->requireImplementation(); 13 17 $specs = $impl->getFieldSpecifications(); 14 18 return PhabricatorStandardCustomField::buildStandardFields($this, $specs);
+96
src/applications/dashboard/editor/PhabricatorDashboardPanelEditEngine.php
··· 1 + <?php 2 + 3 + final class PhabricatorDashboardPanelEditEngine 4 + extends PhabricatorEditEngine { 5 + 6 + const ENGINECONST = 'dashboard.panel'; 7 + 8 + private $panelType; 9 + 10 + public function setPanelType($panel_type) { 11 + $this->panelType = $panel_type; 12 + return $this; 13 + } 14 + 15 + public function getPanelType() { 16 + return $this->panelType; 17 + } 18 + 19 + public function isEngineConfigurable() { 20 + return false; 21 + } 22 + 23 + public function getEngineName() { 24 + return pht('Dashboard Panels'); 25 + } 26 + 27 + public function getSummaryHeader() { 28 + return pht('Edit Dashboard Panels'); 29 + } 30 + 31 + public function getSummaryText() { 32 + return pht('This engine is used to modify dashboard panels.'); 33 + } 34 + 35 + public function getEngineApplicationClass() { 36 + return 'PhabricatorSearchApplication'; 37 + } 38 + 39 + protected function newEditableObject() { 40 + $viewer = $this->getViewer(); 41 + $panel = PhabricatorDashboardPanel::initializeNewPanel($viewer); 42 + 43 + if ($this->panelType) { 44 + $panel->setPanelType($this->panelType); 45 + } 46 + 47 + return $panel; 48 + } 49 + 50 + protected function newObjectQuery() { 51 + return new PhabricatorDashboardPanelQuery(); 52 + } 53 + 54 + protected function getObjectCreateTitleText($object) { 55 + return pht('Create Dashboard Panel'); 56 + } 57 + 58 + protected function getObjectCreateButtonText($object) { 59 + return pht('Create Panel'); 60 + } 61 + 62 + protected function getObjectEditTitleText($object) { 63 + return pht('Edit Panel: %s', $object->getName()); 64 + } 65 + 66 + protected function getObjectEditShortText($object) { 67 + return pht('Edit Panel'); 68 + } 69 + 70 + protected function getObjectCreateShortText() { 71 + return pht('Edit Panel'); 72 + } 73 + 74 + protected function getObjectName() { 75 + return pht('Dashboard Panel'); 76 + } 77 + 78 + protected function getObjectViewURI($object) { 79 + return $object->getURI(); 80 + } 81 + 82 + protected function buildCustomEditFields($object) { 83 + return array( 84 + id(new PhabricatorTextEditField()) 85 + ->setKey('name') 86 + ->setLabel(pht('Name')) 87 + ->setDescription(pht('Name of the panel.')) 88 + ->setConduitDescription(pht('Rename the panel.')) 89 + ->setConduitTypeDescription(pht('New panel name.')) 90 + ->setTransactionType(PhabricatorDashboardPanelTransaction::TYPE_NAME) 91 + ->setIsRequired(true) 92 + ->setValue($object->getName()), 93 + ); 94 + } 95 + 96 + }
+4 -1
src/applications/dashboard/storage/PhabricatorDashboardPanel.php
··· 10 10 PhabricatorPolicyInterface, 11 11 PhabricatorCustomFieldInterface, 12 12 PhabricatorFlaggableInterface, 13 - PhabricatorProjectInterface, 14 13 PhabricatorDestructibleInterface { 15 14 16 15 protected $name; ··· 70 69 71 70 public function getMonogram() { 72 71 return 'W'.$this->getID(); 72 + } 73 + 74 + public function getURI() { 75 + return '/'.$this->getMonogram(); 73 76 } 74 77 75 78 public function getPanelTypes() {