1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-14 02:42:40 +01:00

Created a preference pane for DarkConsole, instead of link

Summary: Just removed the link and created a new field under preferences. Now the setting is under Display Preferences.

Test Plan: Enablied/Disabled dark console to see if it works.

Reviewers: epriestley

Reviewed By: epriestley

CC: irinav, aran, Korvin

Maniphest Tasks: T2344

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

Conflicts:

	src/view/page/PhabricatorStandardPageView.php
This commit is contained in:
Andrei Antonescu 2013-01-19 17:40:48 -08:00 committed by epriestley
parent 49679a6b79
commit f919f000e7
6 changed files with 33 additions and 42 deletions

View file

@ -26,19 +26,7 @@ final class DarkConsoleController extends PhabricatorController {
return id(new AphrontAjaxResponse())->setDisableConsole(true); return id(new AphrontAjaxResponse())->setDisableConsole(true);
} }
if (PhabricatorEnv::getEnvConfig('darkconsole.enabled')) { return new Aphront404Response();
$user->setConsoleEnabled(!$user->getConsoleEnabled());
if ($user->getConsoleEnabled()) {
$user->setConsoleVisible(true);
}
$user->save();
if ($request->isAjax()) {
return new AphrontRedirectResponse();
} else {
return id(new AphrontRedirectResponse())->setURI('/');
}
}
} }
} }

View file

@ -88,8 +88,11 @@ abstract class PhabricatorController extends AphrontController {
return $this->delegateToController($checker_controller); return $this->delegateToController($checker_controller);
} }
$preferences = $user->loadPreferences();
if (PhabricatorEnv::getEnvConfig('darkconsole.enabled')) { if (PhabricatorEnv::getEnvConfig('darkconsole.enabled')) {
if ($user->getConsoleEnabled() || $dark_console = PhabricatorUserPreferences::PREFERENCE_DARK_CONSOLE;
if ($preferences->getPreference($dark_console) ||
PhabricatorEnv::getEnvConfig('darkconsole.always-on')) { PhabricatorEnv::getEnvConfig('darkconsole.always-on')) {
$console = new DarkConsoleCore(); $console = new DarkConsoleCore();
$request->getApplicationConfiguration()->setConsole($console); $request->getApplicationConfiguration()->setConsole($console);

View file

@ -440,7 +440,8 @@ final class PhabricatorUser extends PhabricatorUserDAO implements PhutilPerson {
$default_dict = array( $default_dict = array(
PhabricatorUserPreferences::PREFERENCE_TITLES => 'glyph', PhabricatorUserPreferences::PREFERENCE_TITLES => 'glyph',
PhabricatorUserPreferences::PREFERENCE_EDITOR => '', PhabricatorUserPreferences::PREFERENCE_EDITOR => '',
PhabricatorUserPreferences::PREFERENCE_MONOSPACED => ''); PhabricatorUserPreferences::PREFERENCE_MONOSPACED => '',
PhabricatorUserPreferences::PREFERENCE_DARK_CONSOLE => 0);
$preferences->setPreferences($default_dict); $preferences->setPreferences($default_dict);
} }

View file

@ -20,10 +20,12 @@ 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;
$pref_symbols = PhabricatorUserPreferences::PREFERENCE_DIFFUSION_SYMBOLS; $pref_symbols =
PhabricatorUserPreferences::PREFERENCE_DIFFUSION_SYMBOLS;
$pref_monospaced_textareas = $pref_monospaced_textareas =
PhabricatorUserPreferences::PREFERENCE_MONOSPACED_TEXTAREAS; PhabricatorUserPreferences::PREFERENCE_MONOSPACED_TEXTAREAS;
@ -45,6 +47,9 @@ 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())
@ -75,6 +80,10 @@ 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;
}
$form = id(new AphrontFormView()) $form = id(new AphrontFormView())
->setUser($user) ->setUser($user)
@ -140,10 +149,20 @@ EXAMPLE;
->addButton('enabled', 'Enabled', ->addButton('enabled', 'Enabled',
'Show all textareas using the monospaced font defined above.') 'Show all textareas using the monospaced font defined above.')
->addButton('disabled', 'Disabled', null)) ->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( ->appendChild(
id(new AphrontFormSubmitControl()) id(new AphrontFormSubmitControl())
->setValue('Save Preferences')); ->setValue('Save Preferences'));
$panel = new AphrontPanelView(); $panel = new AphrontPanelView();
$panel->setHeader('Display Preferences'); $panel->setHeader('Display Preferences');
$panel->appendChild($form); $panel->appendChild($form);

View file

@ -3,6 +3,7 @@
final class PhabricatorUserPreferences extends PhabricatorUserDAO { final class PhabricatorUserPreferences extends PhabricatorUserDAO {
const PREFERENCE_MONOSPACED = 'monospaced'; const PREFERENCE_MONOSPACED = 'monospaced';
const PREFERENCE_DARK_CONSOLE = 'dark_console';
const PREFERENCE_EDITOR = 'editor'; const PREFERENCE_EDITOR = 'editor';
const PREFERENCE_MULTIEDIT = 'multiedit'; const PREFERENCE_MULTIEDIT = 'multiedit';
const PREFERENCE_TITLES = 'titles'; const PREFERENCE_TITLES = 'titles';

View file

@ -370,27 +370,6 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView {
$foot_links = array(); $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); $foot_links = implode(' · ', $foot_links);