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

Allow "maniphest.subtypes" to configure which options are presented by "Create Subtask"

Summary:
Ref T13222. Ref T12588. See PHI683. After D19853, "Create Subtask" may pop a dialog to let you choose between multiple forms.

Allow users to configure which forms are available by using `maniphest.subtypes` to choose available children for each subtype. Users may either specify particular subtypes or specific forms.

Test Plan: Configured "Quest" tasks to have "Objective" children, got appropriate prompt behavior. Used "subtypes" and "forms" to select forms; used "forms" to reorder forms.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13222, T12588

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

+135 -16
+50
src/applications/maniphest/config/PhabricatorManiphestConfigOptions.php
··· 338 338 - `tag` //Optional string.// Tag text for this subtype. 339 339 - `color` //Optional string.// Display color for this subtype. 340 340 - `icon` //Optional string.// Icon for the subtype. 341 + - `children` //Optional map.// Configure options shown to the user when 342 + they "Create Subtask". See below. 341 343 342 344 Each subtype must have a unique key, and you must define a subtype with 343 345 the key "%s", which is used as a default subtype. ··· 345 347 The tag text (`tag`) is used to set the text shown in the subtype tag on list 346 348 views and workboards. If you do not configure it, the default subtype will have 347 349 no subtype tag and other subtypes will use their name as tag text. 350 + 351 + The `children` key allows you to configure which options are presented to the 352 + user when they "Create Subtask" from a task of this subtype. You can specify 353 + these keys: 354 + 355 + - `subtypes`: //Optional list<string>.// Show users creation forms for these 356 + task subtypes. 357 + - `forms`: //Optional list<string|int>.// Show users these specific forms, 358 + in order. 359 + 360 + If you don't specify either constraint, users will be shown creation forms 361 + for the same subtype. 362 + 363 + For example, if you have a "quest" subtype and do not configure `children`, 364 + users who click "Create Subtask" will be presented with all create forms for 365 + "quest" tasks. 366 + 367 + If you want to present them with forms for a different task subtype or set of 368 + subtypes instead, use `subtypes`: 369 + 370 + ``` 371 + { 372 + ... 373 + "children": { 374 + "subtypes": ["objective", "boss", "reward"] 375 + } 376 + ... 377 + } 378 + ``` 379 + 380 + If you want to present them with specific forms, use `forms` and specify form 381 + IDs: 382 + 383 + ``` 384 + { 385 + ... 386 + "children": { 387 + "forms": [12, 16] 388 + } 389 + ... 390 + } 391 + ``` 392 + 393 + When specifying forms by ID explicitly, the order you specify the forms in will 394 + be used when presenting options to the user. 395 + 396 + If only one option would be presented, the user will be taken directly to the 397 + appropriate form instead of being prompted to choose a form. 348 398 EOTEXT 349 399 , 350 400 $subtype_default_key));
+54
src/applications/transactions/editengine/PhabricatorEditEngineSubtype.php
··· 11 11 private $icon; 12 12 private $tagText; 13 13 private $color; 14 + private $childSubtypes = array(); 15 + private $childIdentifiers = array(); 14 16 15 17 public function setKey($key) { 16 18 $this->key = $key; ··· 57 59 return $this->color; 58 60 } 59 61 62 + public function setChildSubtypes(array $child_subtypes) { 63 + $this->childSubtypes = $child_subtypes; 64 + return $this; 65 + } 66 + 67 + public function getChildSubtypes() { 68 + return $this->childSubtypes; 69 + } 70 + 71 + public function setChildFormIdentifiers(array $child_identifiers) { 72 + $this->childIdentifiers = $child_identifiers; 73 + return $this; 74 + } 75 + 76 + public function getChildFormIdentifiers() { 77 + return $this->childIdentifiers; 78 + } 79 + 60 80 public function hasTagView() { 61 81 return (bool)strlen($this->getTagText()); 62 82 } ··· 118 138 'tag' => 'optional string', 119 139 'color' => 'optional string', 120 140 'icon' => 'optional string', 141 + 'children' => 'optional map<string, wild>', 121 142 )); 122 143 123 144 $key = $value['key']; ··· 141 162 'no name. Subtypes must have a name.', 142 163 $key)); 143 164 } 165 + 166 + $children = idx($value, 'children'); 167 + if ($children) { 168 + PhutilTypeSpec::checkMap( 169 + $children, 170 + array( 171 + 'subtypes' => 'optional list<string>', 172 + 'forms' => 'optional list<string|int>', 173 + )); 174 + 175 + $child_subtypes = idx($children, 'subtypes'); 176 + $child_forms = idx($children, 'forms'); 177 + 178 + if ($child_subtypes && $child_forms) { 179 + throw new Exception( 180 + pht( 181 + 'Subtype configuration is invalid: subtype with key "%s" '. 182 + 'specifies both child subtypes and child forms. Specify one '. 183 + 'or the other, but not both.')); 184 + } 185 + } 144 186 } 145 187 146 188 if (!isset($map[self::SUBTYPE_DEFAULT])) { ··· 177 219 178 220 if ($color) { 179 221 $subtype->setColor($color); 222 + } 223 + 224 + $children = idx($entry, 'children', array()); 225 + $child_subtypes = idx($children, 'subtypes'); 226 + $child_forms = idx($children, 'forms'); 227 + 228 + if ($child_subtypes) { 229 + $subtype->setChildSubtypes($child_subtypes); 230 + } 231 + 232 + if ($child_forms) { 233 + $subtype->setChildFormIdentifiers($child_forms); 180 234 } 181 235 182 236 $map[$key] = $subtype;
+6 -8
src/applications/transactions/editengine/PhabricatorEditEngineSubtypeMap.php
··· 46 46 $subtype_key = $object->getEditEngineSubtype(); 47 47 $subtype = $this->getSubtype($subtype_key); 48 48 49 - // TODO: Allow subtype configuration to specify that children should be 50 - // created from particular forms or subtypes. 51 - $select_ids = array(); 52 - $select_subtypes = array(); 49 + $select_identifiers = $subtype->getChildFormIdentifiers(); 50 + $select_subtypes = $subtype->getChildSubtypes(); 53 51 54 52 $query = $edit_engine->newConfigurationQuery() 55 53 ->withIsDisabled(false); 56 54 57 - if ($select_ids) { 58 - $query->withIDs($select_ids); 55 + if ($select_identifiers) { 56 + $query->withIdentifiers($select_identifiers); 59 57 } else { 60 58 // If we're selecting by subtype rather than selecting specific forms, 61 59 // only select create forms. ··· 73 71 74 72 // If we're selecting by ID, respect the order specified in the 75 73 // constraint. Otherwise, use the create form sort order. 76 - if ($select_ids) { 77 - $forms = array_select_keys($forms, $select_ids) + $forms; 74 + if ($select_identifiers) { 75 + $forms = array_select_keys($forms, $select_identifiers) + $forms; 78 76 } else { 79 77 $forms = msort($forms, 'getCreateSortKey'); 80 78 }
+25 -8
src/applications/transactions/query/PhabricatorEditEngineConfigurationSearchEngine.php
··· 115 115 ->setHeader($config->getDisplayName()); 116 116 117 117 $id = $config->getID(); 118 - if ($id) { 119 - $item->addIcon('fa-file-text-o bluegrey', pht('Form %d', $id)); 120 - $key = $id; 121 - } else { 122 - $item->addIcon('fa-file-text bluegrey', pht('Builtin')); 123 - $key = $config->getBuiltinKey(); 124 - } 125 - $item->setHref("/transactions/editengine/{$engine_key}/view/{$key}/"); 126 118 127 119 if ($config->getIsDefault()) { 128 120 $item->addAttribute(pht('Default Create Form')); ··· 138 130 } else { 139 131 $item->setStatusIcon('fa-file-text-o green', pht('Enabled')); 140 132 } 133 + 134 + $subtype_key = $config->getSubtype(); 135 + if ($subtype_key !== PhabricatorEditEngineSubtype::SUBTYPE_DEFAULT) { 136 + $engine = $config->getEngine(); 137 + if ($engine->supportsSubtypes()) { 138 + $map = $engine->newSubtypeMap(); 139 + if ($map->isValidSubtype($subtype_key)) { 140 + $subtype = $map->getSubtype($subtype_key); 141 + 142 + $icon = $subtype->getIcon(); 143 + $color = $subtype->getColor(); 144 + 145 + $item->addIcon("{$icon} {$color}", $subtype->getName()); 146 + } 147 + } 148 + } 149 + 150 + if ($id) { 151 + $item->setObjectName(pht('Form %d', $id)); 152 + $key = $id; 153 + } else { 154 + $item->addIcon('fa-file-text bluegrey', pht('Builtin')); 155 + $key = $config->getBuiltinKey(); 156 + } 157 + $item->setHref("/transactions/editengine/{$engine_key}/view/{$key}/"); 141 158 142 159 $list->addItem($item); 143 160 }