Page MenuHomePhabricator

D14679.id35500.diff
No OneTemporary

D14679.id35500.diff

diff --git a/src/applications/config/json/PhabricatorConfigJSON.php b/src/applications/config/json/PhabricatorConfigJSON.php
--- a/src/applications/config/json/PhabricatorConfigJSON.php
+++ b/src/applications/config/json/PhabricatorConfigJSON.php
@@ -8,12 +8,34 @@
* @return string
*/
public static function prettyPrintJSON($value) {
- // Check not only that it's an array, but that it's an "unnatural" array
- // meaning that the keys aren't 0 -> size_of_array.
- if (is_array($value) && array_keys($value) != range(0, count($value) - 1)) {
- $result = id(new PhutilJSON())->encodeFormatted($value);
- } else {
- $result = json_encode($value);
+ // If the value is an array with keys "0, 1, 2, ..." then we want to
+ // show it as a list.
+ // If the value is an array with other keys, we want to show it as an
+ // object.
+ // Otherwise, just use the default encoder.
+
+ $type = null;
+ if (is_array($value)) {
+ $list_keys = range(0, count($value) - 1);
+ $actual_keys = array_keys($value);
+
+ if ($actual_keys === $list_keys) {
+ $type = 'list';
+ } else {
+ $type = 'object';
+ }
+ }
+
+ switch ($type) {
+ case 'list':
+ $result = id(new PhutilJSON())->encodeAsList($value);
+ break;
+ case 'object':
+ $result = id(new PhutilJSON())->encodeFormatted($value);
+ break;
+ default:
+ $result = json_encode($value);
+ break;
}
// For readability, unescape forward slashes. These are normally escaped
diff --git a/src/applications/maniphest/config/PhabricatorManiphestConfigOptions.php b/src/applications/maniphest/config/PhabricatorManiphestConfigOptions.php
--- a/src/applications/maniphest/config/PhabricatorManiphestConfigOptions.php
+++ b/src/applications/maniphest/config/PhabricatorManiphestConfigOptions.php
@@ -242,6 +242,15 @@
$custom_field_type = 'custom:PhabricatorCustomFieldConfigOptionType';
+ $fields_example = array(
+ 'mycompany.estimated-hours' => array(
+ 'name' => pht('Estimated Hours'),
+ 'type' => 'int',
+ 'caption' => pht('Estimated number of hours this will take.'),
+ ),
+ );
+ $fields_json = id(new PhutilJSON())->encodeFormatted($fields_example);
+
return array(
$this->newOption('maniphest.custom-field-definitions', 'wild', array())
->setSummary(pht('Custom Maniphest fields.'))
@@ -250,11 +259,7 @@
'Array of custom fields for Maniphest tasks. For details on '.
'adding custom fields to Maniphest, see "Configuring Custom '.
'Fields" in the documentation.'))
- ->addExample(
- '{"mycompany:estimated-hours": {"name": "Estimated Hours", '.
- '"type": "int", "caption": "Estimated number of hours this will '.
- 'take."}}',
- pht('Valid Setting')),
+ ->addExample($fields_json, pht('Valid setting')),
$this->newOption('maniphest.fields', $custom_field_type, $default_fields)
->setCustomData(id(new ManiphestTask())->getCustomFieldBaseClass())
->setDescription(pht('Select and reorder task fields.')),

File Metadata

Mime Type
text/plain
Expires
Sat, Feb 1, 1:24 AM (13 h, 26 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7080364
Default Alt Text
D14679.id35500.diff (3 KB)

Event Timeline