diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index a9a4d59034..c69ea801af 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1531,6 +1531,7 @@ phutil_register_library_map(array( 'PhabricatorSettingsPanelAccount' => 'applications/settings/panel/PhabricatorSettingsPanelAccount.php', 'PhabricatorSettingsPanelConduit' => 'applications/settings/panel/PhabricatorSettingsPanelConduit.php', 'PhabricatorSettingsPanelConpherencePreferences' => 'applications/settings/panel/PhabricatorSettingsPanelConpherencePreferences.php', + 'PhabricatorSettingsPanelDeveloperPreferences' => 'applications/settings/panel/PhabricatorSettingsPanelDeveloperPreferences.php', 'PhabricatorSettingsPanelDiffPreferences' => 'applications/settings/panel/PhabricatorSettingsPanelDiffPreferences.php', 'PhabricatorSettingsPanelDisplayPreferences' => 'applications/settings/panel/PhabricatorSettingsPanelDisplayPreferences.php', 'PhabricatorSettingsPanelEmailAddresses' => 'applications/settings/panel/PhabricatorSettingsPanelEmailAddresses.php', @@ -3579,6 +3580,7 @@ phutil_register_library_map(array( 'PhabricatorSettingsPanelAccount' => 'PhabricatorSettingsPanel', 'PhabricatorSettingsPanelConduit' => 'PhabricatorSettingsPanel', 'PhabricatorSettingsPanelConpherencePreferences' => 'PhabricatorSettingsPanel', + 'PhabricatorSettingsPanelDeveloperPreferences' => 'PhabricatorSettingsPanel', 'PhabricatorSettingsPanelDiffPreferences' => 'PhabricatorSettingsPanel', 'PhabricatorSettingsPanelDisplayPreferences' => 'PhabricatorSettingsPanel', 'PhabricatorSettingsPanelEmailAddresses' => 'PhabricatorSettingsPanel', diff --git a/src/applications/config/option/PhabricatorDeveloperConfigOptions.php b/src/applications/config/option/PhabricatorDeveloperConfigOptions.php index 8f729711e0..b6fd8aa139 100644 --- a/src/applications/config/option/PhabricatorDeveloperConfigOptions.php +++ b/src/applications/config/option/PhabricatorDeveloperConfigOptions.php @@ -25,10 +25,9 @@ final class PhabricatorDeveloperConfigOptions "DarkConsole is a development and profiling tool built into ". "Phabricator's web interface. You should leave it disabled unless ". "you are developing or debugging Phabricator.\n\n". - "Set this option to enable DarkConsole, which will put a link ". - "in the page footer to actually activate it. Once activated, ". - "it will appear at the top of every page and can be toggled ". - "by pressing the '`' key.\n\n". + "Once you activate DarkConsole for the install, **you need to ". + "enable it for your account before it will actually appear on ". + "pages.** You can do this in Settings > Developer Settings.\n\n". "DarkConsole exposes potentially sensitive data (like queries, ". "stack traces, and configuration) so you generally should not ". "turn it on in production.")), diff --git a/src/applications/settings/panel/PhabricatorSettingsPanelDeveloperPreferences.php b/src/applications/settings/panel/PhabricatorSettingsPanelDeveloperPreferences.php new file mode 100644 index 0000000000..e9cefcc8dd --- /dev/null +++ b/src/applications/settings/panel/PhabricatorSettingsPanelDeveloperPreferences.php @@ -0,0 +1,107 @@ +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, + ); + } +} + diff --git a/src/applications/settings/panel/PhabricatorSettingsPanelDisplayPreferences.php b/src/applications/settings/panel/PhabricatorSettingsPanelDisplayPreferences.php index 12fdf82451..1ae560e533 100644 --- a/src/applications/settings/panel/PhabricatorSettingsPanelDisplayPreferences.php +++ b/src/applications/settings/panel/PhabricatorSettingsPanelDisplayPreferences.php @@ -20,7 +20,6 @@ final class PhabricatorSettingsPanelDisplayPreferences $preferences = $user->loadPreferences(); $pref_monospaced = PhabricatorUserPreferences::PREFERENCE_MONOSPACED; - $pref_dark_console = PhabricatorUserPreferences::PREFERENCE_DARK_CONSOLE; $pref_editor = PhabricatorUserPreferences::PREFERENCE_EDITOR; $pref_multiedit = PhabricatorUserPreferences::PREFERENCE_MULTIEDIT; $pref_titles = PhabricatorUserPreferences::PREFERENCE_TITLES; @@ -42,9 +41,6 @@ final class PhabricatorSettingsPanelDisplayPreferences $preferences->setPreference( $pref_monospaced_textareas, $request->getStr($pref_monospaced_textareas)); - $preferences->setPreference( - $pref_dark_console, - $request->getBool($pref_dark_console)); $preferences->save(); return id(new AphrontRedirectResponse()) @@ -73,10 +69,6 @@ EXAMPLE; if (!$pref_monospaced_textareas_value) { $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. '. '%%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.')) ->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( id(new AphrontFormSubmitControl()) ->setValue(pht('Save Preferences')));