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

Add `maniphest.subtypes` for configuring task subtypes

Summary:
Ref T12314. Builds toward letting you define "animal" and "plant" tasks.

This just adds some configuration. I'll probably add some more quality-of-life options (like "icon") later but these are the only bits I'm sure I'll need.

Test Plan:
- Configured sensible subtypes.
- Tried to configure bad subtypes: bad key, missing "default", duplicate keys. Got sensible error messages.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12314

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

+108
+2
src/__phutil_library_map__.php
··· 1471 1471 'ManiphestStatusConfigOptionType' => 'applications/maniphest/config/ManiphestStatusConfigOptionType.php', 1472 1472 'ManiphestStatusEmailCommand' => 'applications/maniphest/command/ManiphestStatusEmailCommand.php', 1473 1473 'ManiphestSubpriorityController' => 'applications/maniphest/controller/ManiphestSubpriorityController.php', 1474 + 'ManiphestSubtypesConfigOptionsType' => 'applications/maniphest/config/ManiphestSubtypesConfigOptionsType.php', 1474 1475 'ManiphestTask' => 'applications/maniphest/storage/ManiphestTask.php', 1475 1476 'ManiphestTaskAssignHeraldAction' => 'applications/maniphest/herald/ManiphestTaskAssignHeraldAction.php', 1476 1477 'ManiphestTaskAssignOtherHeraldAction' => 'applications/maniphest/herald/ManiphestTaskAssignOtherHeraldAction.php', ··· 6348 6349 'ManiphestStatusConfigOptionType' => 'PhabricatorConfigJSONOptionType', 6349 6350 'ManiphestStatusEmailCommand' => 'ManiphestEmailCommand', 6350 6351 'ManiphestSubpriorityController' => 'ManiphestController', 6352 + 'ManiphestSubtypesConfigOptionsType' => 'PhabricatorConfigJSONOptionType', 6351 6353 'ManiphestTask' => array( 6352 6354 'ManiphestDAO', 6353 6355 'PhabricatorSubscribableInterface',
+10
src/applications/maniphest/config/ManiphestSubtypesConfigOptionsType.php
··· 1 + <?php 2 + 3 + final class ManiphestSubtypesConfigOptionsType 4 + extends PhabricatorConfigJSONOptionType { 5 + 6 + public function validateOption(PhabricatorConfigOption $option, $value) { 7 + PhabricatorEditEngineSubtype::validateConfiguration($value); 8 + } 9 + 10 + }
+48
src/applications/maniphest/config/PhabricatorManiphestConfigOptions.php
··· 297 297 EOTEXT 298 298 )); 299 299 300 + $subtype_type = 'custom:ManiphestSubtypesConfigOptionsType'; 301 + $subtype_default_key = PhabricatorEditEngineSubtype::SUBTYPE_DEFAULT; 302 + $subtype_example = array( 303 + array( 304 + 'key' => $subtype_default_key, 305 + 'name' => pht('Task'), 306 + ), 307 + array( 308 + 'key' => 'bug', 309 + 'name' => pht('Bug'), 310 + ), 311 + array( 312 + 'key' => 'feature', 313 + 'name' => pht('Feature Request'), 314 + ), 315 + ); 316 + $subtype_example = id(new PhutilJSON())->encodeAsList($subtype_example); 317 + 318 + $subtype_default = array( 319 + array( 320 + 'key' => $subtype_default_key, 321 + 'name' => pht('Task'), 322 + ), 323 + ); 324 + 325 + $subtype_description = $this->deformat(pht(<<<EOTEXT 326 + Allows you to define task subtypes. Subtypes let you hide fields you don't 327 + need to simplify the workflows for editing tasks. 328 + 329 + To define subtypes, provide a list of subtypes. Each subtype should be a 330 + dictionary with these keys: 331 + 332 + - `key` //Required string.// Internal identifier for the subtype, like 333 + "task", "feature", or "bug". 334 + - `name` //Required string.// Human-readable name for this subtype, like 335 + "Task", "Feature Request" or "Bug Report". 336 + 337 + Each subtype must have a unique key, and you must define a subtype with 338 + the key "%s", which is used as a default subtype. 339 + EOTEXT 340 + , 341 + $subtype_default_key)); 342 + 343 + 300 344 return array( 301 345 $this->newOption('maniphest.custom-field-definitions', 'wild', array()) 302 346 ->setSummary(pht('Custom Maniphest fields.')) ··· 361 405 ->setDescription($points_description) 362 406 ->addExample($points_json_1, pht('Points Config')) 363 407 ->addExample($points_json_2, pht('Hours Config')), 408 + $this->newOption('maniphest.subtypes', $subtype_type, $subtype_default) 409 + ->setSummary(pht('Define task subtypes.')) 410 + ->setDescription($subtype_description) 411 + ->addExample($subtype_example, pht('Simple Subtypes')), 364 412 ); 365 413 } 366 414
+48
src/applications/transactions/editengine/PhabricatorEditEngineSubtype.php
··· 32 32 } 33 33 } 34 34 35 + public static function validateConfiguration($config) { 36 + if (!is_array($config)) { 37 + throw new Exception( 38 + pht( 39 + 'Subtype configuration is invalid: it must be a list of subtype '. 40 + 'specifications.')); 41 + } 42 + 43 + $map = array(); 44 + foreach ($config as $value) { 45 + PhutilTypeSpec::checkMap( 46 + $value, 47 + array( 48 + 'key' => 'string', 49 + 'name' => 'string', 50 + )); 51 + 52 + $key = $value['key']; 53 + self::validateSubtypeKey($key); 54 + 55 + if (isset($map[$key])) { 56 + throw new Exception( 57 + pht( 58 + 'Subtype configuration is invalid: two subtypes use the same '. 59 + 'key ("%s"). Each subtype must have a unique key.', 60 + $key)); 61 + } 62 + 63 + $map[$key] = true; 64 + 65 + $name = $value['name']; 66 + if (!strlen($name)) { 67 + throw new Exception( 68 + pht( 69 + 'Subtype configuration is invalid: subtype with key "%s" has '. 70 + 'no name. Subtypes must have a name.', 71 + $key)); 72 + } 73 + } 74 + 75 + if (!isset($map[self::SUBTYPE_DEFAULT])) { 76 + throw new Exception( 77 + pht( 78 + 'Subtype configuration is invalid: there is no subtype defined '. 79 + 'with key "%s". This subtype is required and must be defined.', 80 + self::SUBTYPE_DEFAULT)); 81 + } 82 + } 35 83 36 84 }