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

Show the default value in Config.

Summary:
As mentioned by @epriestley in an inline on D4290, we should show what happens
if the user leaves the box blank.

Test Plan: Went to edit a setting and saw the default below the text box.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin, asherkin

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

authored by

Ricky Elrod and committed by
epriestley
a9aedc64 a7746200

+36 -10
+16
src/applications/config/controller/PhabricatorConfigController.php
··· 24 24 return $crumbs; 25 25 } 26 26 27 + /** 28 + * Properly format a JSON value. 29 + * 30 + * @param wild Any value, but should be a raw value, not a string of JSON. 31 + * @return string 32 + */ 33 + public function prettyPrintJSON($value) { 34 + // Check not only that it's an array, but that it's an "unnatural" array 35 + // meaning that the keys aren't 0 -> size_of_array. 36 + if (is_array($value) && array_keys($value) != range(0, count($value) - 1)) { 37 + return id(new PhutilJSON())->encodeFormatted($value); 38 + } else { 39 + return json_encode($value); 40 + } 41 + } 42 + 27 43 }
+20 -10
src/applications/config/controller/PhabricatorConfigEditController.php
··· 19 19 return new Aphront404Response(); 20 20 } 21 21 22 + $default = $this->prettyPrintJSON($config[$this->key]); 23 + 22 24 // Check if the config key is already stored in the database. 23 25 // Grab the value if it is. 24 26 $value = null; ··· 72 74 ->setTitle('You broke everything!') 73 75 ->setErrors($errors); 74 76 } else { 75 - // Check not only that it's an array, but that it's an "unnatural" array 76 - // meaning that the keys aren't 0 -> size_of_array. 77 - if (is_array($value) && 78 - array_keys($value) != range(0, count($value) - 1)) { 79 - $value = id(new PhutilJSON())->encodeFormatted($value); 80 - } else { 81 - $value = json_encode($value); 82 - } 77 + $value = $this->prettyPrintJSON($value); 83 78 } 84 79 85 80 $form ··· 91 86 ->setValue($value) 92 87 ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL) 93 88 ->setCustomClass('PhabricatorMonospaced') 94 - ->setName('value')) 89 + ->setName('value')) 95 90 ->appendChild( 96 91 id(new AphrontFormSubmitControl()) 97 92 ->addCancelButton($config_entry->getURI()) 98 - ->setValue(pht('Save Config Entry'))); 93 + ->setValue(pht('Save Config Entry'))) 94 + ->appendChild( 95 + phutil_render_tag( 96 + 'p', 97 + array( 98 + 'class' => 'aphront-form-input', 99 + ), 100 + 'If left blank, the setting will return to its default value. '. 101 + 'Its default value is:')) 102 + ->appendChild( 103 + phutil_render_tag( 104 + 'pre', 105 + array( 106 + 'class' => 'aphront-form-input', 107 + ), 108 + phutil_escape_html($default))); 99 109 100 110 $title = pht('Edit %s', $this->key); 101 111 $short = pht('Edit');