mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-09-23 10:21:40 +00:00
Do not show preferences, if night mode or appearance menu is disabled
Follow up to Ic40da2af8ea46bd42cbebbdbceda2431bd8600ae Only show these if the feature is available for the current user, otherwise, we are effectively shipping these features to all logged in users. Bug: T341278 Change-Id: I99c28af807fbf7bbf575b8d4712e1dbad364ec63
This commit is contained in:
parent
92307893fa
commit
464e0cac68
|
@ -520,6 +520,12 @@ class Hooks implements
|
|||
* @param array[] &$prefs Preferences description array, to be fed to a HTMLForm object.
|
||||
*/
|
||||
public function onGetPreferences( $user, &$prefs ): void {
|
||||
$services = MediaWikiServices::getInstance();
|
||||
$featureManagerFactory = $services->getService( 'Vector.FeatureManagerFactory' );
|
||||
$featureManager = $featureManagerFactory->createFeatureManager( RequestContext::getMain() );
|
||||
$isVectorAppearanceEnabled = $featureManager->isFeatureEnabled( Constants::FEATURE_APPEARANCE );
|
||||
$isNightModeEnabled = $featureManager->isFeatureEnabled( Constants::FEATURE_NIGHT_MODE );
|
||||
|
||||
$vectorPrefs = [
|
||||
Constants::PREF_KEY_LIMITED_WIDTH => [
|
||||
'type' => 'toggle',
|
||||
|
@ -529,7 +535,7 @@ class Hooks implements
|
|||
'hide-if' => [ '!==', 'skin', Constants::SKIN_NAME_MODERN ],
|
||||
],
|
||||
Constants::PREF_KEY_FONT_SIZE => [
|
||||
'type' => 'select',
|
||||
'type' => $isVectorAppearanceEnabled ? 'select' : 'api',
|
||||
'label-message' => 'vector-feature-custom-font-size-name',
|
||||
'section' => 'rendering/skin/skin-prefs',
|
||||
'options-messages' => [
|
||||
|
@ -552,7 +558,7 @@ class Hooks implements
|
|||
'type' => 'api'
|
||||
],
|
||||
Constants::PREF_KEY_NIGHT_MODE => [
|
||||
'type' => 'select',
|
||||
'type' => $isNightModeEnabled ? 'select' : 'api',
|
||||
'label-message' => 'skin-theme-name',
|
||||
'help-message' => 'skin-theme-description',
|
||||
'section' => 'rendering/skin/skin-prefs',
|
||||
|
|
Loading…
Reference in a new issue