mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-24 07:43:47 +00:00
Merge "Add config to disable sidebar state persistence for logged-in users."
This commit is contained in:
commit
c7e9719b9b
|
@ -104,6 +104,11 @@ final class Constants {
|
|||
*/
|
||||
public const FEATURE_LATEST_SKIN = 'LatestSkin';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const CONFIG_KEY_DISABLE_SIDEBAR_PERSISTENCE = 'VectorDisableSidebarPersistence';
|
||||
|
||||
// These are used for query parameters.
|
||||
/**
|
||||
* Override the skin version user preference and site Config. See readme.
|
||||
|
|
|
@ -224,6 +224,34 @@ class Hooks {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* NOTE: Please use ResourceLoaderGetConfigVars hook instead if possible
|
||||
* for adding config to the page.
|
||||
* Adds config variables to JS that depend on current page/request.
|
||||
*
|
||||
* Adds a config flag that can disable saving the VectorSidebarVisible
|
||||
* user preference when the sidebar menu icon is clicked.
|
||||
*
|
||||
* @param array &$vars Array of variables to be added into the output.
|
||||
* @param OutputPage $out OutputPage instance calling the hook
|
||||
*/
|
||||
public static function onMakeGlobalVariablesScript( &$vars, OutputPage $out ) {
|
||||
if ( $out->getSkin() instanceof SkinVector ) {
|
||||
$skinVersionLookup = new SkinVersionLookup(
|
||||
$out->getRequest(),
|
||||
$out->getUser(),
|
||||
self::getServiceConfig()
|
||||
);
|
||||
|
||||
if ( !$skinVersionLookup->isLegacy() ) {
|
||||
$vars[ 'wgVectorDisableSidebarPersistence' ] =
|
||||
self::getConfig(
|
||||
Constants::CONFIG_KEY_DISABLE_SIDEBAR_PERSISTENCE
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a configuration variable such as `Constants::CONFIG_KEY_SHOW_SKIN_PREFERENCES`.
|
||||
*
|
||||
|
|
|
@ -79,8 +79,7 @@ function init( window ) {
|
|||
button = window.document.getElementById( SIDEBAR_BUTTON_ID );
|
||||
|
||||
initCheckboxHack( checkbox, button );
|
||||
|
||||
if ( mw.config.get( 'wgUserName' ) ) {
|
||||
if ( mw.config.get( 'wgUserName' ) && !mw.config.get( 'wgVectorDisableSidebarPersistence' ) ) {
|
||||
bindSidebarClickEvent( checkbox, button );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,8 @@
|
|||
"PreferencesFormPreSave": "Vector\\Hooks::onPreferencesFormPreSave",
|
||||
"SkinTemplateNavigation": "Vector\\Hooks::onSkinTemplateNavigation",
|
||||
"LocalUserCreated": "Vector\\Hooks::onLocalUserCreated",
|
||||
"OutputPageBodyAttributes": "Vector\\Hooks::onOutputPageBodyAttributes"
|
||||
"OutputPageBodyAttributes": "Vector\\Hooks::onOutputPageBodyAttributes",
|
||||
"MakeGlobalVariablesScript": "Vector\\Hooks::onMakeGlobalVariablesScript"
|
||||
},
|
||||
"@note": "When modifying skins.vector.styles definition, make sure the installer still works",
|
||||
"ResourceModules": {
|
||||
|
@ -164,6 +165,10 @@
|
|||
"VectorLayoutMaxWidth": {
|
||||
"value": false,
|
||||
"description": "@var boolean Enables the max-width layout for the latest version of Vector. This is intended to be a very short-lived feature flag whose sole purpose is to derisk the deployment of T246420. It should be removed (and made the default) as quickly as possible."
|
||||
},
|
||||
"VectorDisableSidebarPersistence": {
|
||||
"value": false,
|
||||
"description": "@var boolean Temporary feature flag that disables saving the sidebar expanded/collapsed state as a user-preference (triggered via clicking the main menu icon). This is intended as a temporary kill-switch in the event that the DB is overloaded with writes to the user_options table."
|
||||
}
|
||||
},
|
||||
"ServiceWiringFiles": [
|
||||
|
|
Loading…
Reference in a new issue