diff --git a/src/aphront/console/DarkConsoleController.php b/src/aphront/console/DarkConsoleController.php index eb6c00f2f9..6f46716312 100644 --- a/src/aphront/console/DarkConsoleController.php +++ b/src/aphront/console/DarkConsoleController.php @@ -26,19 +26,7 @@ final class DarkConsoleController extends PhabricatorController { return id(new AphrontAjaxResponse())->setDisableConsole(true); } - if (PhabricatorEnv::getEnvConfig('darkconsole.enabled')) { - $user->setConsoleEnabled(!$user->getConsoleEnabled()); - if ($user->getConsoleEnabled()) { - $user->setConsoleVisible(true); - } - $user->save(); - if ($request->isAjax()) { - return new AphrontRedirectResponse(); - } else { - return id(new AphrontRedirectResponse())->setURI('/'); - } - } - + return new Aphront404Response(); } } diff --git a/src/applications/base/controller/PhabricatorController.php b/src/applications/base/controller/PhabricatorController.php index d7716e52b6..5ed19acc9d 100644 --- a/src/applications/base/controller/PhabricatorController.php +++ b/src/applications/base/controller/PhabricatorController.php @@ -88,9 +88,12 @@ abstract class PhabricatorController extends AphrontController { return $this->delegateToController($checker_controller); } + $preferences = $user->loadPreferences(); + if (PhabricatorEnv::getEnvConfig('darkconsole.enabled')) { - if ($user->getConsoleEnabled() || - PhabricatorEnv::getEnvConfig('darkconsole.always-on')) { + $dark_console = PhabricatorUserPreferences::PREFERENCE_DARK_CONSOLE; + if ($preferences->getPreference($dark_console) || + PhabricatorEnv::getEnvConfig('darkconsole.always-on')) { $console = new DarkConsoleCore(); $request->getApplicationConfiguration()->setConsole($console); } diff --git a/src/applications/people/storage/PhabricatorUser.php b/src/applications/people/storage/PhabricatorUser.php index 3710267a3d..0301e453a4 100644 --- a/src/applications/people/storage/PhabricatorUser.php +++ b/src/applications/people/storage/PhabricatorUser.php @@ -440,7 +440,8 @@ final class PhabricatorUser extends PhabricatorUserDAO implements PhutilPerson { $default_dict = array( PhabricatorUserPreferences::PREFERENCE_TITLES => 'glyph', PhabricatorUserPreferences::PREFERENCE_EDITOR => '', - PhabricatorUserPreferences::PREFERENCE_MONOSPACED => ''); + PhabricatorUserPreferences::PREFERENCE_MONOSPACED => '', + PhabricatorUserPreferences::PREFERENCE_DARK_CONSOLE => 0); $preferences->setPreferences($default_dict); } diff --git a/src/applications/settings/panel/PhabricatorSettingsPanelDisplayPreferences.php b/src/applications/settings/panel/PhabricatorSettingsPanelDisplayPreferences.php index c52244cafb..64195bd14d 100644 --- a/src/applications/settings/panel/PhabricatorSettingsPanelDisplayPreferences.php +++ b/src/applications/settings/panel/PhabricatorSettingsPanelDisplayPreferences.php @@ -19,11 +19,13 @@ final class PhabricatorSettingsPanelDisplayPreferences $user = $request->getUser(); $preferences = $user->loadPreferences(); - $pref_monospaced = PhabricatorUserPreferences::PREFERENCE_MONOSPACED; - $pref_editor = PhabricatorUserPreferences::PREFERENCE_EDITOR; - $pref_multiedit = PhabricatorUserPreferences::PREFERENCE_MULTIEDIT; - $pref_titles = PhabricatorUserPreferences::PREFERENCE_TITLES; - $pref_symbols = PhabricatorUserPreferences::PREFERENCE_DIFFUSION_SYMBOLS; + $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; + $pref_symbols = + PhabricatorUserPreferences::PREFERENCE_DIFFUSION_SYMBOLS; $pref_monospaced_textareas = PhabricatorUserPreferences::PREFERENCE_MONOSPACED_TEXTAREAS; @@ -45,6 +47,9 @@ 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()) @@ -75,6 +80,10 @@ 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; + } $form = id(new AphrontFormView()) ->setUser($user) @@ -140,10 +149,20 @@ EXAMPLE; ->addButton('enabled', 'Enabled', 'Show all textareas using the monospaced font defined above.') ->addButton('disabled', 'Disabled', null)) + ->appendChild( + id(new AphrontFormRadioButtonControl()) + ->setLabel('Dark Console') + ->setName($pref_dark_console) + ->setValue($pref_dark_console_value ? + $pref_dark_console_value : 0) + ->addButton(1, 'Enabled', + 'Enabling and using the built-in debugging console.') + ->addButton(0, 'Disabled', null)) ->appendChild( id(new AphrontFormSubmitControl()) ->setValue('Save Preferences')); + $panel = new AphrontPanelView(); $panel->setHeader('Display Preferences'); $panel->appendChild($form); diff --git a/src/applications/settings/storage/PhabricatorUserPreferences.php b/src/applications/settings/storage/PhabricatorUserPreferences.php index ebea7374f8..4338e1ef61 100644 --- a/src/applications/settings/storage/PhabricatorUserPreferences.php +++ b/src/applications/settings/storage/PhabricatorUserPreferences.php @@ -3,6 +3,7 @@ final class PhabricatorUserPreferences extends PhabricatorUserDAO { const PREFERENCE_MONOSPACED = 'monospaced'; + const PREFERENCE_DARK_CONSOLE = 'dark_console'; const PREFERENCE_EDITOR = 'editor'; const PREFERENCE_MULTIEDIT = 'multiedit'; const PREFERENCE_TITLES = 'titles'; diff --git a/src/view/page/PhabricatorStandardPageView.php b/src/view/page/PhabricatorStandardPageView.php index 5691136c45..b28a2d1a42 100644 --- a/src/view/page/PhabricatorStandardPageView.php +++ b/src/view/page/PhabricatorStandardPageView.php @@ -370,27 +370,6 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView { $foot_links = array(); - if (PhabricatorEnv::getEnvConfig('darkconsole.enabled') && - !PhabricatorEnv::getEnvConfig('darkconsole.always-on')) { - if ($console) { - $link = javelin_render_tag( - 'a', - array( - 'href' => '/~/', - 'sigil' => 'workflow', - ), - 'Disable DarkConsole'); - } else { - $link = javelin_render_tag( - 'a', - array( - 'href' => '/~/', - 'sigil' => 'workflow', - ), - 'Enable DarkConsole'); - } - $foot_links[] = $link; - } $foot_links = implode(' · ', $foot_links);