1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-20 13:52:40 +01:00

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
This commit is contained in:
epriestley 2013-07-27 20:18:58 -07:00
parent 70a5ec600d
commit 149efe68ab
4 changed files with 112 additions and 24 deletions

View file

@ -1531,6 +1531,7 @@ phutil_register_library_map(array(
'PhabricatorSettingsPanelAccount' => 'applications/settings/panel/PhabricatorSettingsPanelAccount.php', 'PhabricatorSettingsPanelAccount' => 'applications/settings/panel/PhabricatorSettingsPanelAccount.php',
'PhabricatorSettingsPanelConduit' => 'applications/settings/panel/PhabricatorSettingsPanelConduit.php', 'PhabricatorSettingsPanelConduit' => 'applications/settings/panel/PhabricatorSettingsPanelConduit.php',
'PhabricatorSettingsPanelConpherencePreferences' => 'applications/settings/panel/PhabricatorSettingsPanelConpherencePreferences.php', 'PhabricatorSettingsPanelConpherencePreferences' => 'applications/settings/panel/PhabricatorSettingsPanelConpherencePreferences.php',
'PhabricatorSettingsPanelDeveloperPreferences' => 'applications/settings/panel/PhabricatorSettingsPanelDeveloperPreferences.php',
'PhabricatorSettingsPanelDiffPreferences' => 'applications/settings/panel/PhabricatorSettingsPanelDiffPreferences.php', 'PhabricatorSettingsPanelDiffPreferences' => 'applications/settings/panel/PhabricatorSettingsPanelDiffPreferences.php',
'PhabricatorSettingsPanelDisplayPreferences' => 'applications/settings/panel/PhabricatorSettingsPanelDisplayPreferences.php', 'PhabricatorSettingsPanelDisplayPreferences' => 'applications/settings/panel/PhabricatorSettingsPanelDisplayPreferences.php',
'PhabricatorSettingsPanelEmailAddresses' => 'applications/settings/panel/PhabricatorSettingsPanelEmailAddresses.php', 'PhabricatorSettingsPanelEmailAddresses' => 'applications/settings/panel/PhabricatorSettingsPanelEmailAddresses.php',
@ -3579,6 +3580,7 @@ phutil_register_library_map(array(
'PhabricatorSettingsPanelAccount' => 'PhabricatorSettingsPanel', 'PhabricatorSettingsPanelAccount' => 'PhabricatorSettingsPanel',
'PhabricatorSettingsPanelConduit' => 'PhabricatorSettingsPanel', 'PhabricatorSettingsPanelConduit' => 'PhabricatorSettingsPanel',
'PhabricatorSettingsPanelConpherencePreferences' => 'PhabricatorSettingsPanel', 'PhabricatorSettingsPanelConpherencePreferences' => 'PhabricatorSettingsPanel',
'PhabricatorSettingsPanelDeveloperPreferences' => 'PhabricatorSettingsPanel',
'PhabricatorSettingsPanelDiffPreferences' => 'PhabricatorSettingsPanel', 'PhabricatorSettingsPanelDiffPreferences' => 'PhabricatorSettingsPanel',
'PhabricatorSettingsPanelDisplayPreferences' => 'PhabricatorSettingsPanel', 'PhabricatorSettingsPanelDisplayPreferences' => 'PhabricatorSettingsPanel',
'PhabricatorSettingsPanelEmailAddresses' => 'PhabricatorSettingsPanel', 'PhabricatorSettingsPanelEmailAddresses' => 'PhabricatorSettingsPanel',

View file

@ -25,10 +25,9 @@ final class PhabricatorDeveloperConfigOptions
"DarkConsole is a development and profiling tool built into ". "DarkConsole is a development and profiling tool built into ".
"Phabricator's web interface. You should leave it disabled unless ". "Phabricator's web interface. You should leave it disabled unless ".
"you are developing or debugging Phabricator.\n\n". "you are developing or debugging Phabricator.\n\n".
"Set this option to enable DarkConsole, which will put a link ". "Once you activate DarkConsole for the install, **you need to ".
"in the page footer to actually activate it. Once activated, ". "enable it for your account before it will actually appear on ".
"it will appear at the top of every page and can be toggled ". "pages.** You can do this in Settings > Developer Settings.\n\n".
"by pressing the '`' key.\n\n".
"DarkConsole exposes potentially sensitive data (like queries, ". "DarkConsole exposes potentially sensitive data (like queries, ".
"stack traces, and configuration) so you generally should not ". "stack traces, and configuration) so you generally should not ".
"turn it on in production.")), "turn it on in production.")),

View file

@ -0,0 +1,107 @@
<?php
final class PhabricatorSettingsPanelDeveloperPreferences
extends PhabricatorSettingsPanel {
public function getPanelKey() {
return 'developer';
}
public function getPanelName() {
return pht('Developer Settings');
}
public function getPanelGroup() {
return pht('Developer');
}
public function processRequest(AphrontRequest $request) {
$user = $request->getUser();
$preferences = $user->loadPreferences();
$pref_dark_console = PhabricatorUserPreferences::PREFERENCE_DARK_CONSOLE;
$dark_console_value = $preferences->getPreference($pref_dark_console);
if ($request->isFormPost()) {
$new_dark_console = $request->getBool($pref_dark_console);
$preferences->setPreference($pref_dark_console, $new_dark_console);
// If the user turned Dark Console on, enable it (as though they had hit
// "`").
if ($new_dark_console && !$dark_console_value) {
$user->setConsoleVisible(true);
$user->save();
}
$preferences->save();
return id(new AphrontRedirectResponse())
->setURI($this->getPanelURI('?saved=true'));
}
$is_console_enabled = PhabricatorEnv::getEnvConfig('darkconsole.enabled');
$preamble = pht(
'**DarkConsole** is a developer console which can help build and '.
'debug Phabricator applications. It includes tools for understanding '.
'errors, performance, service calls, and other low-level aspects of '.
'Phabricator\'s inner workings.');
if ($is_console_enabled) {
$instructions = pht(
"%s\n\n".
'You can enable it for your account below. Enabling DarkConsole will '.
'slightly decrease performance, but give you access to debugging '.
'tools. You may want to disable it again later if you only need it '.
'temporarily.'.
"\n\n".
'NOTE: After enabling DarkConsole, **press the ##`## key on your '.
'keyboard** to show or hide it.',
$preamble);
} else {
$instructions = pht(
"%s\n\n".
'Before you can turn on DarkConsole, it needs to be enabled in '.
'the configuration for this install (`darkconsole.enabled`).',
$preamble);
}
$form = id(new AphrontFormView())
->setUser($user)
->setFlexible(true)
->appendRemarkupInstructions($instructions)
->appendChild(
id(new AphrontFormSelectControl())
->setLabel(pht('Dark Console'))
->setName($pref_dark_console)
->setValue($dark_console_value)
->setOptions(
array(
0 => pht('Disable DarkConsole'),
1 => pht('Enable DarkConsole'),
))
->setDisabled(!$is_console_enabled))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue(pht('Save Preferences')));
$header = id(new PhabricatorHeaderView())
->setHeader(pht('Developer Settings'));
$error_view = null;
if ($request->getBool('saved')) {
$error_view = id(new AphrontErrorView())
->setTitle(pht('Preferences Saved'))
->setSeverity(AphrontErrorView::SEVERITY_NOTICE)
->setErrors(array(pht('Your preferences have been saved.')));
}
return array(
$error_view,
$header,
$form,
);
}
}

View file

@ -20,7 +20,6 @@ final class PhabricatorSettingsPanelDisplayPreferences
$preferences = $user->loadPreferences(); $preferences = $user->loadPreferences();
$pref_monospaced = PhabricatorUserPreferences::PREFERENCE_MONOSPACED; $pref_monospaced = PhabricatorUserPreferences::PREFERENCE_MONOSPACED;
$pref_dark_console = PhabricatorUserPreferences::PREFERENCE_DARK_CONSOLE;
$pref_editor = PhabricatorUserPreferences::PREFERENCE_EDITOR; $pref_editor = PhabricatorUserPreferences::PREFERENCE_EDITOR;
$pref_multiedit = PhabricatorUserPreferences::PREFERENCE_MULTIEDIT; $pref_multiedit = PhabricatorUserPreferences::PREFERENCE_MULTIEDIT;
$pref_titles = PhabricatorUserPreferences::PREFERENCE_TITLES; $pref_titles = PhabricatorUserPreferences::PREFERENCE_TITLES;
@ -42,9 +41,6 @@ final class PhabricatorSettingsPanelDisplayPreferences
$preferences->setPreference( $preferences->setPreference(
$pref_monospaced_textareas, $pref_monospaced_textareas,
$request->getStr($pref_monospaced_textareas)); $request->getStr($pref_monospaced_textareas));
$preferences->setPreference(
$pref_dark_console,
$request->getBool($pref_dark_console));
$preferences->save(); $preferences->save();
return id(new AphrontRedirectResponse()) return id(new AphrontRedirectResponse())
@ -73,10 +69,6 @@ EXAMPLE;
if (!$pref_monospaced_textareas_value) { if (!$pref_monospaced_textareas_value) {
$pref_monospaced_textareas_value = 'disabled'; $pref_monospaced_textareas_value = 'disabled';
} }
$pref_dark_console_value = $preferences->getPreference($pref_dark_console);
if (!$pref_dark_console_value) {
$pref_dark_console_value = 0;
}
$editor_instructions = pht('Link to edit files in external editor. '. $editor_instructions = pht('Link to edit files in external editor. '.
'%%f is replaced by filename, %%l by line number, %%r by repository '. '%%f is replaced by filename, %%l by line number, %%r by repository '.
@ -141,18 +133,6 @@ EXAMPLE;
pht('Show all textareas using the monospaced font defined above.')) pht('Show all textareas using the monospaced font defined above.'))
->addButton('disabled', pht('Disabled'), null)); ->addButton('disabled', pht('Disabled'), null));
if (PhabricatorEnv::getEnvConfig('darkconsole.enabled')) {
$form->appendChild(
id(new AphrontFormRadioButtonControl())
->setLabel(pht('Dark Console'))
->setName($pref_dark_console)
->setValue($pref_dark_console_value ?
$pref_dark_console_value : 0)
->addButton(1, pht('Enabled'),
pht('Enabling and using the built-in debugging console.'))
->addButton(0, pht('Disabled'), null));
}
$form->appendChild( $form->appendChild(
id(new AphrontFormSubmitControl()) id(new AphrontFormSubmitControl())
->setValue(pht('Save Preferences'))); ->setValue(pht('Save Preferences')));