mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-23 15:16:50 +00:00
Separate reference preview settings in beta & non-beta
This is the smallest possible patch for a backport. While it seems there is zero technical reason to limit user option keys to lowercase with dashes, it's best-practice. Same as message keys. Bug: T281235 Change-Id: Ia4a45cf4459543c81b23b757ae9c2cfaf9676894
This commit is contained in:
parent
5f850befee
commit
3a00223a36
|
@ -56,6 +56,12 @@ class PopupsContext {
|
|||
*/
|
||||
public const PREVIEWS_OPTIN_PREFERENCE_NAME = 'popups';
|
||||
|
||||
/**
|
||||
* User preference key to enable/disable Reference Previews. Named
|
||||
* "mwe-popups-referencePreviews-enabled" in localStorage for anonymous users.
|
||||
*/
|
||||
public const REFERENCE_PREVIEWS_PREFERENCE_NAME_AFTER_BETA = 'popups-reference-previews';
|
||||
|
||||
/**
|
||||
* User preference key to enable/disable Reference Previews
|
||||
*/
|
||||
|
@ -152,7 +158,7 @@ class PopupsContext {
|
|||
self::REFERENCE_PREVIEWS_PREFERENCE_NAME
|
||||
);
|
||||
}
|
||||
return $user->getBoolOption( self::REFERENCE_PREVIEWS_PREFERENCE_NAME );
|
||||
return $user->getBoolOption( self::REFERENCE_PREVIEWS_PREFERENCE_NAME_AFTER_BETA );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -131,7 +131,7 @@ class PopupsHooks {
|
|||
}
|
||||
|
||||
return [
|
||||
PopupsContext::REFERENCE_PREVIEWS_PREFERENCE_NAME => $option
|
||||
PopupsContext::REFERENCE_PREVIEWS_PREFERENCE_NAME_AFTER_BETA => $option
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,7 @@ class PopupsHooks {
|
|||
if ( $config->get( 'PopupsReferencePreviews' ) &&
|
||||
!$config->get( 'PopupsReferencePreviewsBetaFeature' )
|
||||
) {
|
||||
$defaultOptions[PopupsContext::REFERENCE_PREVIEWS_PREFERENCE_NAME] = $default;
|
||||
$defaultOptions[PopupsContext::REFERENCE_PREVIEWS_PREFERENCE_NAME_AFTER_BETA] = $default;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -245,7 +245,7 @@ class PopupsHooks {
|
|||
if ( $config->get( 'PopupsReferencePreviews' ) &&
|
||||
!$config->get( 'PopupsReferencePreviewsBetaFeature' )
|
||||
) {
|
||||
$user->setOption( PopupsContext::REFERENCE_PREVIEWS_PREFERENCE_NAME, $default );
|
||||
$user->setOption( PopupsContext::REFERENCE_PREVIEWS_PREFERENCE_NAME_AFTER_BETA, $default );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
BIN
resources/dist/index.js
vendored
BIN
resources/dist/index.js
vendored
Binary file not shown.
BIN
resources/dist/index.js.map.json
vendored
BIN
resources/dist/index.js.map.json
vendored
Binary file not shown.
|
@ -33,6 +33,11 @@ export default function isReferencePreviewsEnabled( user, userSettings, config )
|
|||
return userSettings.isReferencePreviewsEnabled();
|
||||
}
|
||||
|
||||
// TODO: Remove when not in Beta any more
|
||||
if ( config.get( 'wgPopupsReferencePreviews' ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Registered users never can enable popup types at run-time.
|
||||
return mw.user.options.get( 'popupsreferencepreviews' ) === '1' ? true : null;
|
||||
return mw.user.options.get( 'popups-reference-previews' ) === '1' ? true : null;
|
||||
}
|
||||
|
|
|
@ -288,7 +288,7 @@ class PopupsHooksTest extends MediaWikiTestCase {
|
|||
$this->assertCount( 3 - $beta, $userOptions );
|
||||
$this->assertSame( '1', $userOptions[ PopupsContext::PREVIEWS_OPTIN_PREFERENCE_NAME ] );
|
||||
if ( $beta === false ) {
|
||||
$this->assertSame( '1', $userOptions[ PopupsContext::REFERENCE_PREVIEWS_PREFERENCE_NAME ] );
|
||||
$this->assertSame( '1', $userOptions[ PopupsContext::REFERENCE_PREVIEWS_PREFERENCE_NAME_AFTER_BETA ] );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -304,7 +304,7 @@ class PopupsHooksTest extends MediaWikiTestCase {
|
|||
->method( 'setOption' )
|
||||
->withConsecutive(
|
||||
[ 'popups', $expectedState ],
|
||||
[ 'popupsreferencepreviews', $expectedState ]
|
||||
[ 'popups-reference-previews', $expectedState ]
|
||||
);
|
||||
|
||||
$this->setMwGlobals( [
|
||||
|
|
Loading…
Reference in a new issue