@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 usability of DarkConsole settings

Summary:
Fixes T3632. Cleans up a bunch of DarkConsole stuff:

- The config setting had out-of-date instructions. Modernize the instructions.
- The setting was sort of hidden under "Display Preferences". Move it to a new "Developer Preferences".
- The setting magically appeared if DarkConsole was enabled on the install. Instead, always show it but explain why it isn't availalbe.
- When the user enables the console, also force it to actually be shown.
- Call out instructions about use of the "`" key more clearly.

Test Plan: Viewed config setting. Viewed settings panel. Changed setting. Enabling the setting showed DarkConsole.

Reviewers: garoevans, chad, btrahan

Reviewed By: chad

CC: aran

Maniphest Tasks: T3632

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

+112 -24
+2
src/__phutil_library_map__.php
··· 1531 1531 'PhabricatorSettingsPanelAccount' => 'applications/settings/panel/PhabricatorSettingsPanelAccount.php', 1532 1532 'PhabricatorSettingsPanelConduit' => 'applications/settings/panel/PhabricatorSettingsPanelConduit.php', 1533 1533 'PhabricatorSettingsPanelConpherencePreferences' => 'applications/settings/panel/PhabricatorSettingsPanelConpherencePreferences.php', 1534 + 'PhabricatorSettingsPanelDeveloperPreferences' => 'applications/settings/panel/PhabricatorSettingsPanelDeveloperPreferences.php', 1534 1535 'PhabricatorSettingsPanelDiffPreferences' => 'applications/settings/panel/PhabricatorSettingsPanelDiffPreferences.php', 1535 1536 'PhabricatorSettingsPanelDisplayPreferences' => 'applications/settings/panel/PhabricatorSettingsPanelDisplayPreferences.php', 1536 1537 'PhabricatorSettingsPanelEmailAddresses' => 'applications/settings/panel/PhabricatorSettingsPanelEmailAddresses.php', ··· 3579 3580 'PhabricatorSettingsPanelAccount' => 'PhabricatorSettingsPanel', 3580 3581 'PhabricatorSettingsPanelConduit' => 'PhabricatorSettingsPanel', 3581 3582 'PhabricatorSettingsPanelConpherencePreferences' => 'PhabricatorSettingsPanel', 3583 + 'PhabricatorSettingsPanelDeveloperPreferences' => 'PhabricatorSettingsPanel', 3582 3584 'PhabricatorSettingsPanelDiffPreferences' => 'PhabricatorSettingsPanel', 3583 3585 'PhabricatorSettingsPanelDisplayPreferences' => 'PhabricatorSettingsPanel', 3584 3586 'PhabricatorSettingsPanelEmailAddresses' => 'PhabricatorSettingsPanel',
+3 -4
src/applications/config/option/PhabricatorDeveloperConfigOptions.php
··· 25 25 "DarkConsole is a development and profiling tool built into ". 26 26 "Phabricator's web interface. You should leave it disabled unless ". 27 27 "you are developing or debugging Phabricator.\n\n". 28 - "Set this option to enable DarkConsole, which will put a link ". 29 - "in the page footer to actually activate it. Once activated, ". 30 - "it will appear at the top of every page and can be toggled ". 31 - "by pressing the '`' key.\n\n". 28 + "Once you activate DarkConsole for the install, **you need to ". 29 + "enable it for your account before it will actually appear on ". 30 + "pages.** You can do this in Settings > Developer Settings.\n\n". 32 31 "DarkConsole exposes potentially sensitive data (like queries, ". 33 32 "stack traces, and configuration) so you generally should not ". 34 33 "turn it on in production.")),
+107
src/applications/settings/panel/PhabricatorSettingsPanelDeveloperPreferences.php
··· 1 + <?php 2 + 3 + final class PhabricatorSettingsPanelDeveloperPreferences 4 + extends PhabricatorSettingsPanel { 5 + 6 + public function getPanelKey() { 7 + return 'developer'; 8 + } 9 + 10 + public function getPanelName() { 11 + return pht('Developer Settings'); 12 + } 13 + 14 + public function getPanelGroup() { 15 + return pht('Developer'); 16 + } 17 + 18 + public function processRequest(AphrontRequest $request) { 19 + $user = $request->getUser(); 20 + $preferences = $user->loadPreferences(); 21 + 22 + $pref_dark_console = PhabricatorUserPreferences::PREFERENCE_DARK_CONSOLE; 23 + 24 + $dark_console_value = $preferences->getPreference($pref_dark_console); 25 + 26 + if ($request->isFormPost()) { 27 + $new_dark_console = $request->getBool($pref_dark_console); 28 + $preferences->setPreference($pref_dark_console, $new_dark_console); 29 + 30 + // If the user turned Dark Console on, enable it (as though they had hit 31 + // "`"). 32 + if ($new_dark_console && !$dark_console_value) { 33 + $user->setConsoleVisible(true); 34 + $user->save(); 35 + } 36 + 37 + $preferences->save(); 38 + 39 + return id(new AphrontRedirectResponse()) 40 + ->setURI($this->getPanelURI('?saved=true')); 41 + } 42 + 43 + $is_console_enabled = PhabricatorEnv::getEnvConfig('darkconsole.enabled'); 44 + 45 + $preamble = pht( 46 + '**DarkConsole** is a developer console which can help build and '. 47 + 'debug Phabricator applications. It includes tools for understanding '. 48 + 'errors, performance, service calls, and other low-level aspects of '. 49 + 'Phabricator\'s inner workings.'); 50 + 51 + if ($is_console_enabled) { 52 + $instructions = pht( 53 + "%s\n\n". 54 + 'You can enable it for your account below. Enabling DarkConsole will '. 55 + 'slightly decrease performance, but give you access to debugging '. 56 + 'tools. You may want to disable it again later if you only need it '. 57 + 'temporarily.'. 58 + "\n\n". 59 + 'NOTE: After enabling DarkConsole, **press the ##`## key on your '. 60 + 'keyboard** to show or hide it.', 61 + $preamble); 62 + } else { 63 + $instructions = pht( 64 + "%s\n\n". 65 + 'Before you can turn on DarkConsole, it needs to be enabled in '. 66 + 'the configuration for this install (`darkconsole.enabled`).', 67 + $preamble); 68 + } 69 + 70 + $form = id(new AphrontFormView()) 71 + ->setUser($user) 72 + ->setFlexible(true) 73 + ->appendRemarkupInstructions($instructions) 74 + ->appendChild( 75 + id(new AphrontFormSelectControl()) 76 + ->setLabel(pht('Dark Console')) 77 + ->setName($pref_dark_console) 78 + ->setValue($dark_console_value) 79 + ->setOptions( 80 + array( 81 + 0 => pht('Disable DarkConsole'), 82 + 1 => pht('Enable DarkConsole'), 83 + )) 84 + ->setDisabled(!$is_console_enabled)) 85 + ->appendChild( 86 + id(new AphrontFormSubmitControl()) 87 + ->setValue(pht('Save Preferences'))); 88 + 89 + $header = id(new PhabricatorHeaderView()) 90 + ->setHeader(pht('Developer Settings')); 91 + 92 + $error_view = null; 93 + if ($request->getBool('saved')) { 94 + $error_view = id(new AphrontErrorView()) 95 + ->setTitle(pht('Preferences Saved')) 96 + ->setSeverity(AphrontErrorView::SEVERITY_NOTICE) 97 + ->setErrors(array(pht('Your preferences have been saved.'))); 98 + } 99 + 100 + return array( 101 + $error_view, 102 + $header, 103 + $form, 104 + ); 105 + } 106 + } 107 +
-20
src/applications/settings/panel/PhabricatorSettingsPanelDisplayPreferences.php
··· 20 20 $preferences = $user->loadPreferences(); 21 21 22 22 $pref_monospaced = PhabricatorUserPreferences::PREFERENCE_MONOSPACED; 23 - $pref_dark_console = PhabricatorUserPreferences::PREFERENCE_DARK_CONSOLE; 24 23 $pref_editor = PhabricatorUserPreferences::PREFERENCE_EDITOR; 25 24 $pref_multiedit = PhabricatorUserPreferences::PREFERENCE_MULTIEDIT; 26 25 $pref_titles = PhabricatorUserPreferences::PREFERENCE_TITLES; ··· 42 41 $preferences->setPreference( 43 42 $pref_monospaced_textareas, 44 43 $request->getStr($pref_monospaced_textareas)); 45 - $preferences->setPreference( 46 - $pref_dark_console, 47 - $request->getBool($pref_dark_console)); 48 44 49 45 $preferences->save(); 50 46 return id(new AphrontRedirectResponse()) ··· 72 68 ->getPreference($pref_monospaced_textareas); 73 69 if (!$pref_monospaced_textareas_value) { 74 70 $pref_monospaced_textareas_value = 'disabled'; 75 - } 76 - $pref_dark_console_value = $preferences->getPreference($pref_dark_console); 77 - if (!$pref_dark_console_value) { 78 - $pref_dark_console_value = 0; 79 71 } 80 72 81 73 $editor_instructions = pht('Link to edit files in external editor. '. ··· 140 132 ->addButton('enabled', pht('Enabled'), 141 133 pht('Show all textareas using the monospaced font defined above.')) 142 134 ->addButton('disabled', pht('Disabled'), null)); 143 - 144 - if (PhabricatorEnv::getEnvConfig('darkconsole.enabled')) { 145 - $form->appendChild( 146 - id(new AphrontFormRadioButtonControl()) 147 - ->setLabel(pht('Dark Console')) 148 - ->setName($pref_dark_console) 149 - ->setValue($pref_dark_console_value ? 150 - $pref_dark_console_value : 0) 151 - ->addButton(1, pht('Enabled'), 152 - pht('Enabling and using the built-in debugging console.')) 153 - ->addButton(0, pht('Disabled'), null)); 154 - } 155 135 156 136 $form->appendChild( 157 137 id(new AphrontFormSubmitControl())