@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.

Make "Create Subtask" work properly in EditEngine

Summary: Ref T9908. This fixes "Create Subtask" so it works with the new stuff. Mostly straightforward.

Test Plan: Created some subtasks.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9908

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

+197 -4
+8
src/__phutil_library_map__.php
··· 120 120 'AphrontFormDateControlValue' => 'view/form/control/AphrontFormDateControlValue.php', 121 121 'AphrontFormDividerControl' => 'view/form/control/AphrontFormDividerControl.php', 122 122 'AphrontFormFileControl' => 'view/form/control/AphrontFormFileControl.php', 123 + 'AphrontFormHandlesControl' => 'view/form/control/AphrontFormHandlesControl.php', 123 124 'AphrontFormMarkupControl' => 'view/form/control/AphrontFormMarkupControl.php', 124 125 'AphrontFormPasswordControl' => 'view/form/control/AphrontFormPasswordControl.php', 125 126 'AphrontFormPolicyControl' => 'view/form/control/AphrontFormPolicyControl.php', ··· 1310 1311 'ManiphestTaskHeraldField' => 'applications/maniphest/herald/ManiphestTaskHeraldField.php', 1311 1312 'ManiphestTaskHeraldFieldGroup' => 'applications/maniphest/herald/ManiphestTaskHeraldFieldGroup.php', 1312 1313 'ManiphestTaskListController' => 'applications/maniphest/controller/ManiphestTaskListController.php', 1314 + 'ManiphestTaskListHTTPParameterType' => 'applications/maniphest/httpparametertype/ManiphestTaskListHTTPParameterType.php', 1313 1315 'ManiphestTaskListView' => 'applications/maniphest/view/ManiphestTaskListView.php', 1314 1316 'ManiphestTaskMailReceiver' => 'applications/maniphest/mail/ManiphestTaskMailReceiver.php', 1315 1317 'ManiphestTaskOpenStatusDatasource' => 'applications/maniphest/typeahead/ManiphestTaskOpenStatusDatasource.php', 1318 + 'ManiphestTaskPHIDResolver' => 'applications/maniphest/httpparametertype/ManiphestTaskPHIDResolver.php', 1316 1319 'ManiphestTaskPHIDType' => 'applications/maniphest/phid/ManiphestTaskPHIDType.php', 1317 1320 'ManiphestTaskPriority' => 'applications/maniphest/constants/ManiphestTaskPriority.php', 1318 1321 'ManiphestTaskPriorityDatasource' => 'applications/maniphest/typeahead/ManiphestTaskPriorityDatasource.php', ··· 2306 2309 'PhabricatorHandlePool' => 'applications/phid/handle/pool/PhabricatorHandlePool.php', 2307 2310 'PhabricatorHandlePoolTestCase' => 'applications/phid/handle/pool/__tests__/PhabricatorHandlePoolTestCase.php', 2308 2311 'PhabricatorHandleQuery' => 'applications/phid/query/PhabricatorHandleQuery.php', 2312 + 'PhabricatorHandlesEditField' => 'applications/transactions/editfield/PhabricatorHandlesEditField.php', 2309 2313 'PhabricatorHarbormasterApplication' => 'applications/harbormaster/application/PhabricatorHarbormasterApplication.php', 2310 2314 'PhabricatorHarbormasterConfigOptions' => 'applications/harbormaster/config/PhabricatorHarbormasterConfigOptions.php', 2311 2315 'PhabricatorHash' => 'infrastructure/util/PhabricatorHash.php', ··· 3941 3945 'AphrontFormDateControlValue' => 'Phobject', 3942 3946 'AphrontFormDividerControl' => 'AphrontFormControl', 3943 3947 'AphrontFormFileControl' => 'AphrontFormControl', 3948 + 'AphrontFormHandlesControl' => 'AphrontFormControl', 3944 3949 'AphrontFormMarkupControl' => 'AphrontFormControl', 3945 3950 'AphrontFormPasswordControl' => 'AphrontFormControl', 3946 3951 'AphrontFormPolicyControl' => 'AphrontFormControl', ··· 5308 5313 'ManiphestTaskHeraldField' => 'HeraldField', 5309 5314 'ManiphestTaskHeraldFieldGroup' => 'HeraldFieldGroup', 5310 5315 'ManiphestTaskListController' => 'ManiphestController', 5316 + 'ManiphestTaskListHTTPParameterType' => 'AphrontListHTTPParameterType', 5311 5317 'ManiphestTaskListView' => 'ManiphestView', 5312 5318 'ManiphestTaskMailReceiver' => 'PhabricatorObjectMailReceiver', 5313 5319 'ManiphestTaskOpenStatusDatasource' => 'PhabricatorTypeaheadDatasource', 5320 + 'ManiphestTaskPHIDResolver' => 'PhabricatorPHIDResolver', 5314 5321 'ManiphestTaskPHIDType' => 'PhabricatorPHIDType', 5315 5322 'ManiphestTaskPriority' => 'ManiphestConstants', 5316 5323 'ManiphestTaskPriorityDatasource' => 'PhabricatorTypeaheadDatasource', ··· 6471 6478 'PhabricatorHandlePool' => 'Phobject', 6472 6479 'PhabricatorHandlePoolTestCase' => 'PhabricatorTestCase', 6473 6480 'PhabricatorHandleQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 6481 + 'PhabricatorHandlesEditField' => 'PhabricatorPHIDListEditField', 6474 6482 'PhabricatorHarbormasterApplication' => 'PhabricatorApplication', 6475 6483 'PhabricatorHarbormasterConfigOptions' => 'PhabricatorApplicationConfigOptions', 6476 6484 'PhabricatorHash' => 'Phobject',
+17 -3
src/applications/maniphest/controller/ManiphestTaskDetailController.php
··· 134 134 $task, 135 135 PhabricatorPolicyCapability::CAN_EDIT); 136 136 137 - $can_create = $viewer->isLoggedIn(); 138 - 139 137 $view = id(new PhabricatorActionListView()) 140 138 ->setUser($viewer) 141 139 ->setObject($task) ··· 158 156 ->setDisabled(!$can_edit) 159 157 ->setWorkflow(true)); 160 158 159 + $edit_config = id(new ManiphestEditEngine()) 160 + ->setViewer($viewer) 161 + ->loadDefaultEditConfiguration(); 162 + 163 + $can_create = (bool)$edit_config; 164 + if ($can_create) { 165 + $form_key = $edit_config->getIdentifier(); 166 + $edit_uri = "/editpro/form/{$form_key}/?parent={$id}&template={$id}"; 167 + $edit_uri = $this->getApplicationURI($edit_uri); 168 + } else { 169 + // TODO: This will usually give us a somewhat-reasonable error page, but 170 + // could be a bit cleaner. 171 + $edit_uri = "/editpro/{$id}/"; 172 + $edit_uri = $this->getApplicationURI($edit_uri); 173 + } 174 + 161 175 $view->addAction( 162 176 id(new PhabricatorActionView()) 163 177 ->setName(pht('Create Subtask')) 164 - ->setHref($this->getApplicationURI("/task/create/?parent={$id}")) 178 + ->setHref($edit_uri) 165 179 ->setIcon('fa-level-down') 166 180 ->setDisabled(!$can_create) 167 181 ->setWorkflow(!$can_create));
+7
src/applications/maniphest/editor/ManiphestEditEngine.php
··· 69 69 } 70 70 71 71 return array( 72 + id(new PhabricatorHandlesEditField()) 73 + ->setKey('parent') 74 + ->setLabel(pht('Parent Task')) 75 + ->setDescription(pht('Task to make this a subtask of.')) 76 + ->setAliases(array('parentPHID')) 77 + ->setTransactionType(ManiphestTransaction::TYPE_PARENT) 78 + ->setSingleValue(null), 72 79 id(new PhabricatorTextEditField()) 73 80 ->setKey('title') 74 81 ->setLabel(pht('Title'))
+27
src/applications/maniphest/editor/ManiphestTransactionEditor.php
··· 26 26 $types[] = ManiphestTransaction::TYPE_MERGED_INTO; 27 27 $types[] = ManiphestTransaction::TYPE_MERGED_FROM; 28 28 $types[] = ManiphestTransaction::TYPE_UNBLOCK; 29 + $types[] = ManiphestTransaction::TYPE_PARENT; 29 30 $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; 30 31 $types[] = PhabricatorTransactions::TYPE_EDIT_POLICY; 31 32 ··· 67 68 case ManiphestTransaction::TYPE_MERGED_INTO: 68 69 case ManiphestTransaction::TYPE_MERGED_FROM: 69 70 return null; 71 + case ManiphestTransaction::TYPE_PARENT: 72 + return null; 70 73 } 71 74 } 72 75 ··· 88 91 case ManiphestTransaction::TYPE_MERGED_FROM: 89 92 case ManiphestTransaction::TYPE_UNBLOCK: 90 93 return $xaction->getNewValue(); 94 + case ManiphestTransaction::TYPE_PARENT: 95 + return $xaction->getNewValue(); 91 96 } 92 97 } 93 98 ··· 155 160 return; 156 161 case ManiphestTransaction::TYPE_MERGED_FROM: 157 162 return; 163 + case ManiphestTransaction::TYPE_PARENT: 164 + return; 158 165 } 159 166 } 160 167 ··· 163 170 PhabricatorApplicationTransaction $xaction) { 164 171 165 172 switch ($xaction->getTransactionType()) { 173 + case ManiphestTransaction::TYPE_PARENT: 174 + $parent_phid = $xaction->getNewValue(); 175 + $parent_type = ManiphestTaskDependsOnTaskEdgeType::EDGECONST; 176 + $task_phid = $object->getPHID(); 177 + 178 + id(new PhabricatorEdgeEditor()) 179 + ->addEdge($parent_phid, $parent_type, $task_phid) 180 + ->save(); 181 + break; 166 182 case ManiphestTransaction::TYPE_PROJECT_COLUMN: 167 183 $board_phid = idx($xaction->getNewValue(), 'projectPHID'); 168 184 if (!$board_phid) { ··· 738 754 739 755 $error->setIsMissingFieldError(true); 740 756 $errors[] = $error; 757 + } 758 + break; 759 + case ManiphestTransaction::TYPE_PARENT: 760 + if ($xactions && !$this->getIsNewObject()) { 761 + $error = new PhabricatorApplicationTransactionValidationError( 762 + $type, 763 + pht('Invalid'), 764 + pht( 765 + 'You can only select a parent task when creating a '. 766 + 'transaction for the first time.'), 767 + last($xactions)); 741 768 } 742 769 break; 743 770 }
+47
src/applications/maniphest/httpparametertype/ManiphestTaskListHTTPParameterType.php
··· 1 + <?php 2 + 3 + final class ManiphestTaskListHTTPParameterType 4 + extends AphrontListHTTPParameterType { 5 + 6 + protected function getParameterValue(AphrontRequest $request, $key) { 7 + $type = new AphrontStringListHTTPParameterType(); 8 + $list = $this->getValueWithType($type, $request, $key); 9 + 10 + return id(new ManiphestTaskPHIDResolver()) 11 + ->setViewer($this->getViewer()) 12 + ->resolvePHIDs($list); 13 + } 14 + 15 + protected function getParameterTypeName() { 16 + return 'list<task>'; 17 + } 18 + 19 + protected function getParameterFormatDescriptions() { 20 + return array( 21 + pht('Comma-separated list of task PHIDs.'), 22 + pht('List of task PHIDs, as array.'), 23 + pht('Comma-separated list of task IDs.'), 24 + pht('List of task IDs, as array.'), 25 + pht('Comma-separated list of task monograms.'), 26 + pht('List of task monograms, as array.'), 27 + pht('Mixture of PHIDs, IDs and monograms.'), 28 + ); 29 + } 30 + 31 + protected function getParameterExamples() { 32 + return array( 33 + 'v=PHID-TASK-1111', 34 + 'v=PHID-TASK-1111,PHID-TASK-2222', 35 + 'v[]=PHID-TASK-1111&v[]=PHID-TASK-2222', 36 + 'v=123', 37 + 'v=123,124', 38 + 'v[]=123&v[]=124', 39 + 'v=T123', 40 + 'v=T123,T124', 41 + 'v[]=T123&v[]=T124', 42 + 'v=PHID-TASK-1111,123,T124', 43 + 'v[]=PHID-TASK-1111&v[]=123&v[]=T124', 44 + ); 45 + } 46 + 47 + }
+30
src/applications/maniphest/httpparametertype/ManiphestTaskPHIDResolver.php
··· 1 + <?php 2 + 3 + final class ManiphestTaskPHIDResolver 4 + extends PhabricatorPHIDResolver { 5 + 6 + protected function getResolutionMap(array $names) { 7 + foreach ($names as $key => $name) { 8 + if (ctype_digit($name)) { 9 + $names[$key] = 'T'.$name; 10 + } 11 + } 12 + 13 + $query = id(new PhabricatorObjectQuery()) 14 + ->setViewer($this->getViewer()); 15 + 16 + $tasks = id(new ManiphestTaskPHIDType()) 17 + ->loadNamedObjects($query, $names); 18 + 19 + 20 + $results = array(); 21 + foreach ($tasks as $task) { 22 + $task_phid = $task->getPHID(); 23 + $results[$task->getID()] = $task_phid; 24 + $results[$task->getMonogram()] = $task_phid; 25 + } 26 + 27 + return $results; 28 + } 29 + 30 + }
+2
src/applications/maniphest/storage/ManiphestTransaction.php
··· 14 14 const TYPE_MERGED_INTO = 'mergedinto'; 15 15 const TYPE_MERGED_FROM = 'mergedfrom'; 16 16 const TYPE_UNBLOCK = 'unblock'; 17 + const TYPE_PARENT = 'parent'; 17 18 18 19 // NOTE: this type is deprecated. Keep it around for legacy installs 19 20 // so any transactions render correctly. ··· 147 148 } 148 149 break; 149 150 case self::TYPE_SUBPRIORITY: 151 + case self::TYPE_PARENT: 150 152 return true; 151 153 case self::TYPE_PROJECT_COLUMN: 152 154 $old_cols = idx($this->getOldValue(), 'columnPHIDs');
+1 -1
src/applications/transactions/editengine/PhabricatorEditEngine.php
··· 252 252 'getCreateSortKey'); 253 253 } 254 254 255 - private function loadDefaultEditConfiguration() { 255 + public function loadDefaultEditConfiguration() { 256 256 $query = $this->newConfigurationQuery() 257 257 ->withIsEdit(true) 258 258 ->withIsDisabled(false);
+14
src/applications/transactions/editfield/PhabricatorHandlesEditField.php
··· 1 + <?php 2 + 3 + final class PhabricatorHandlesEditField 4 + extends PhabricatorPHIDListEditField { 5 + 6 + protected function newControl() { 7 + return id(new AphrontFormHandlesControl()); 8 + } 9 + 10 + protected function newHTTPParameterType() { 11 + return new ManiphestTaskListHTTPParameterType(); 12 + } 13 + 14 + }
+8
src/applications/transactions/editfield/PhabricatorPHIDListEditField.php
··· 52 52 return parent::readValueFromComment($value); 53 53 } 54 54 55 + protected function getValueFromRequest(AphrontRequest $request, $key) { 56 + $value = parent::getValueFromRequest($request, $key); 57 + if ($this->getIsSingleValue()) { 58 + $value = array_slice($value, 0, 1); 59 + } 60 + return $value; 61 + } 62 + 55 63 public function getValueForTransaction() { 56 64 $new = parent::getValueForTransaction(); 57 65
+36
src/view/form/control/AphrontFormHandlesControl.php
··· 1 + <?php 2 + 3 + final class AphrontFormHandlesControl extends AphrontFormControl { 4 + 5 + protected function getCustomControlClass() { 6 + return 'aphront-form-control-handles'; 7 + } 8 + 9 + protected function shouldRender() { 10 + return (bool)$this->getValue(); 11 + } 12 + 13 + protected function renderInput() { 14 + $value = $this->getValue(); 15 + $viewer = $this->getUser(); 16 + 17 + $list = $viewer->renderHandleList($value); 18 + $list = id(new PHUIBoxView()) 19 + ->addPadding(PHUI::PADDING_SMALL_TOP) 20 + ->appendChild($list); 21 + 22 + $inputs = array(); 23 + foreach ($value as $phid) { 24 + $inputs[] = phutil_tag( 25 + 'input', 26 + array( 27 + 'type' => 'hidden', 28 + 'name' => $this->getName().'[]', 29 + 'value' => $phid, 30 + )); 31 + } 32 + 33 + return array($list, $inputs); 34 + } 35 + 36 + }