mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-24 21:48:21 +01:00
Turn DarkConsole settings into real settings
Summary: Ref T4103. These settings long-predate proper settings and are based on hard-coded user properties. Turn them into real settings. (I didn't try to migrate the value since they're trivial to restore and only useful to developers.) Test Plan: - Toggled console on/off. - Swapped tabs. - Reloaded page, everything stayed sticky. Reviewers: chad Reviewed By: chad Subscribers: eadler Maniphest Tasks: T4103 Differential Revision: https://secure.phabricator.com/D16029
This commit is contained in:
parent
64d6593e9c
commit
109917a94b
10 changed files with 74 additions and 18 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE {$NAMESPACE}_user.user
|
||||||
|
DROP COLUMN consoleEnabled;
|
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE {$NAMESPACE}_user.user
|
||||||
|
DROP COLUMN consoleTab;
|
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE {$NAMESPACE}_user.user
|
||||||
|
DROP COLUMN consoleVisible;
|
|
@ -2240,6 +2240,8 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorDaemonsSetupCheck' => 'applications/config/check/PhabricatorDaemonsSetupCheck.php',
|
'PhabricatorDaemonsSetupCheck' => 'applications/config/check/PhabricatorDaemonsSetupCheck.php',
|
||||||
'PhabricatorDailyRoutineTriggerClock' => 'infrastructure/daemon/workers/clock/PhabricatorDailyRoutineTriggerClock.php',
|
'PhabricatorDailyRoutineTriggerClock' => 'infrastructure/daemon/workers/clock/PhabricatorDailyRoutineTriggerClock.php',
|
||||||
'PhabricatorDarkConsoleSetting' => 'applications/settings/setting/PhabricatorDarkConsoleSetting.php',
|
'PhabricatorDarkConsoleSetting' => 'applications/settings/setting/PhabricatorDarkConsoleSetting.php',
|
||||||
|
'PhabricatorDarkConsoleTabSetting' => 'applications/settings/setting/PhabricatorDarkConsoleTabSetting.php',
|
||||||
|
'PhabricatorDarkConsoleVisibleSetting' => 'applications/settings/setting/PhabricatorDarkConsoleVisibleSetting.php',
|
||||||
'PhabricatorDashboard' => 'applications/dashboard/storage/PhabricatorDashboard.php',
|
'PhabricatorDashboard' => 'applications/dashboard/storage/PhabricatorDashboard.php',
|
||||||
'PhabricatorDashboardAddPanelController' => 'applications/dashboard/controller/PhabricatorDashboardAddPanelController.php',
|
'PhabricatorDashboardAddPanelController' => 'applications/dashboard/controller/PhabricatorDashboardAddPanelController.php',
|
||||||
'PhabricatorDashboardApplication' => 'applications/dashboard/application/PhabricatorDashboardApplication.php',
|
'PhabricatorDashboardApplication' => 'applications/dashboard/application/PhabricatorDashboardApplication.php',
|
||||||
|
@ -6797,6 +6799,8 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorDaemonsSetupCheck' => 'PhabricatorSetupCheck',
|
'PhabricatorDaemonsSetupCheck' => 'PhabricatorSetupCheck',
|
||||||
'PhabricatorDailyRoutineTriggerClock' => 'PhabricatorTriggerClock',
|
'PhabricatorDailyRoutineTriggerClock' => 'PhabricatorTriggerClock',
|
||||||
'PhabricatorDarkConsoleSetting' => 'PhabricatorSelectSetting',
|
'PhabricatorDarkConsoleSetting' => 'PhabricatorSelectSetting',
|
||||||
|
'PhabricatorDarkConsoleTabSetting' => 'PhabricatorInternalSetting',
|
||||||
|
'PhabricatorDarkConsoleVisibleSetting' => 'PhabricatorInternalSetting',
|
||||||
'PhabricatorDashboard' => array(
|
'PhabricatorDashboard' => array(
|
||||||
'PhabricatorDashboardDAO',
|
'PhabricatorDashboardDAO',
|
||||||
'PhabricatorApplicationTransactionInterface',
|
'PhabricatorApplicationTransactionInterface',
|
||||||
|
|
|
@ -17,30 +17,48 @@ final class DarkConsoleController extends PhabricatorController {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function processRequest() {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
$request = $this->getRequest();
|
$viewer = $this->getViewer();
|
||||||
$user = $request->getUser();
|
|
||||||
$response = id(new AphrontAjaxResponse())->setDisableConsole(true);
|
$response = id(new AphrontAjaxResponse())->setDisableConsole(true);
|
||||||
|
|
||||||
if (!$user->isLoggedIn()) {
|
if (!$viewer->isLoggedIn()) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
$visible = $request->getStr('visible');
|
$visible = $request->getStr('visible');
|
||||||
if (strlen($visible)) {
|
if (strlen($visible)) {
|
||||||
$user->setConsoleVisible((int)$visible);
|
$this->writeDarkConsoleSetting(
|
||||||
$user->save();
|
PhabricatorDarkConsoleVisibleSetting::SETTINGKEY,
|
||||||
|
(int)$visible);
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tab = $request->getStr('tab');
|
$tab = $request->getStr('tab');
|
||||||
if (strlen($tab)) {
|
if (strlen($tab)) {
|
||||||
$user->setConsoleTab($tab);
|
$this->writeDarkConsoleSetting(
|
||||||
$user->save();
|
PhabricatorDarkConsoleTabSetting::SETTINGKEY,
|
||||||
|
$tab);
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Aphront404Response();
|
return new Aphront404Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function writeDarkConsoleSetting($key, $value) {
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
$request = $this->getRequest();
|
||||||
|
|
||||||
|
$preferences = PhabricatorUserPreferences::loadUserPreferences($viewer);
|
||||||
|
|
||||||
|
$editor = id(new PhabricatorUserPreferencesEditor())
|
||||||
|
->setActor($viewer)
|
||||||
|
->setContentSourceFromRequest($request)
|
||||||
|
->setContinueOnNoEffect(true)
|
||||||
|
->setContinueOnMissingFields(true);
|
||||||
|
|
||||||
|
$xactions = array();
|
||||||
|
$xactions[] = $preferences->newTransaction($key, $value);
|
||||||
|
$editor->applyTransactions($preferences, $xactions);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,8 @@ final class DarkConsoleCore extends Phobject {
|
||||||
|
|
||||||
public function render(AphrontRequest $request) {
|
public function render(AphrontRequest $request) {
|
||||||
$user = $request->getUser();
|
$user = $request->getUser();
|
||||||
$visible = $user ? $user->getConsoleVisible() : true;
|
$visible = $user->getUserSetting(
|
||||||
|
PhabricatorDarkConsoleVisibleSetting::SETTINGKEY);
|
||||||
|
|
||||||
return javelin_tag(
|
return javelin_tag(
|
||||||
'div',
|
'div',
|
||||||
|
|
|
@ -34,10 +34,6 @@ final class PhabricatorUser
|
||||||
protected $availabilityCache;
|
protected $availabilityCache;
|
||||||
protected $availabilityCacheTTL;
|
protected $availabilityCacheTTL;
|
||||||
|
|
||||||
protected $consoleEnabled = 0;
|
|
||||||
protected $consoleVisible = 0;
|
|
||||||
protected $consoleTab = '';
|
|
||||||
|
|
||||||
protected $conduitCertificate;
|
protected $conduitCertificate;
|
||||||
|
|
||||||
protected $isSystemAgent = 0;
|
protected $isSystemAgent = 0;
|
||||||
|
@ -190,9 +186,6 @@ final class PhabricatorUser
|
||||||
'passwordSalt' => 'text32?',
|
'passwordSalt' => 'text32?',
|
||||||
'passwordHash' => 'text128?',
|
'passwordHash' => 'text128?',
|
||||||
'profileImagePHID' => 'phid?',
|
'profileImagePHID' => 'phid?',
|
||||||
'consoleEnabled' => 'bool',
|
|
||||||
'consoleVisible' => 'bool',
|
|
||||||
'consoleTab' => 'text64',
|
|
||||||
'conduitCertificate' => 'text255',
|
'conduitCertificate' => 'text255',
|
||||||
'isSystemAgent' => 'bool',
|
'isSystemAgent' => 'bool',
|
||||||
'isMailingList' => 'bool',
|
'isMailingList' => 'bool',
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorDarkConsoleTabSetting
|
||||||
|
extends PhabricatorInternalSetting {
|
||||||
|
|
||||||
|
const SETTINGKEY = 'darkconsole.tab';
|
||||||
|
|
||||||
|
public function getSettingName() {
|
||||||
|
return pht('DarkConsole Tab');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorDarkConsoleVisibleSetting
|
||||||
|
extends PhabricatorInternalSetting {
|
||||||
|
|
||||||
|
const SETTINGKEY = 'darkconsole.visible';
|
||||||
|
|
||||||
|
public function getSettingName() {
|
||||||
|
return pht('DarkConsole Visible');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -639,13 +639,23 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView
|
||||||
$headers[DarkConsoleServicesPlugin::getQueryAnalyzerHeader()] = true;
|
$headers[DarkConsoleServicesPlugin::getQueryAnalyzerHeader()] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($user) {
|
||||||
|
$setting_tab = PhabricatorDarkConsoleTabSetting::SETTINGKEY;
|
||||||
|
$setting_visible = PhabricatorDarkConsoleVisibleSetting::SETTINGKEY;
|
||||||
|
$tab = $user->getUserSetting($setting_tab);
|
||||||
|
$visible = $user->getUserSetting($setting_visible);
|
||||||
|
} else {
|
||||||
|
$tab = null;
|
||||||
|
$visible = true;
|
||||||
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
// NOTE: We use a generic label here to prevent input reflection
|
// NOTE: We use a generic label here to prevent input reflection
|
||||||
// and mitigate compression attacks like BREACH. See discussion in
|
// and mitigate compression attacks like BREACH. See discussion in
|
||||||
// T3684.
|
// T3684.
|
||||||
'uri' => pht('Main Request'),
|
'uri' => pht('Main Request'),
|
||||||
'selected' => $user ? $user->getConsoleTab() : null,
|
'selected' => $tab,
|
||||||
'visible' => $user ? (int)$user->getConsoleVisible() : true,
|
'visible' => $visible,
|
||||||
'headers' => $headers,
|
'headers' => $headers,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue