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

Improve UI formatting of some configuration values

Summary: This just pretties up some config like `maniphest.custom-field-definitions` which I noticed was kind of hard to read while chasing down other stuff.

Test Plan: {F1014940}

Reviewers: chad

Reviewed By: chad

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

+38 -11
+28 -6
src/applications/config/json/PhabricatorConfigJSON.php
··· 8 8 * @return string 9 9 */ 10 10 public static function prettyPrintJSON($value) { 11 - // Check not only that it's an array, but that it's an "unnatural" array 12 - // meaning that the keys aren't 0 -> size_of_array. 13 - if (is_array($value) && array_keys($value) != range(0, count($value) - 1)) { 14 - $result = id(new PhutilJSON())->encodeFormatted($value); 15 - } else { 16 - $result = json_encode($value); 11 + // If the value is an array with keys "0, 1, 2, ..." then we want to 12 + // show it as a list. 13 + // If the value is an array with other keys, we want to show it as an 14 + // object. 15 + // Otherwise, just use the default encoder. 16 + 17 + $type = null; 18 + if (is_array($value)) { 19 + $list_keys = range(0, count($value) - 1); 20 + $actual_keys = array_keys($value); 21 + 22 + if ($actual_keys === $list_keys) { 23 + $type = 'list'; 24 + } else { 25 + $type = 'object'; 26 + } 27 + } 28 + 29 + switch ($type) { 30 + case 'list': 31 + $result = id(new PhutilJSON())->encodeAsList($value); 32 + break; 33 + case 'object': 34 + $result = id(new PhutilJSON())->encodeFormatted($value); 35 + break; 36 + default: 37 + $result = json_encode($value); 38 + break; 17 39 } 18 40 19 41 // For readability, unescape forward slashes. These are normally escaped
+10 -5
src/applications/maniphest/config/PhabricatorManiphestConfigOptions.php
··· 242 242 243 243 $custom_field_type = 'custom:PhabricatorCustomFieldConfigOptionType'; 244 244 245 + $fields_example = array( 246 + 'mycompany.estimated-hours' => array( 247 + 'name' => pht('Estimated Hours'), 248 + 'type' => 'int', 249 + 'caption' => pht('Estimated number of hours this will take.'), 250 + ), 251 + ); 252 + $fields_json = id(new PhutilJSON())->encodeFormatted($fields_example); 253 + 245 254 return array( 246 255 $this->newOption('maniphest.custom-field-definitions', 'wild', array()) 247 256 ->setSummary(pht('Custom Maniphest fields.')) ··· 250 259 'Array of custom fields for Maniphest tasks. For details on '. 251 260 'adding custom fields to Maniphest, see "Configuring Custom '. 252 261 'Fields" in the documentation.')) 253 - ->addExample( 254 - '{"mycompany:estimated-hours": {"name": "Estimated Hours", '. 255 - '"type": "int", "caption": "Estimated number of hours this will '. 256 - 'take."}}', 257 - pht('Valid Setting')), 262 + ->addExample($fields_json, pht('Valid setting')), 258 263 $this->newOption('maniphest.fields', $custom_field_type, $default_fields) 259 264 ->setCustomData(id(new ManiphestTask())->getCustomFieldBaseClass()) 260 265 ->setDescription(pht('Select and reorder task fields.')),