Internal config variables renamed from Popups to Cite

This updates the easy variables which are set and get within a single
module, these changes should have no effect and don't need to be
coordinated across extensions.

Bug: T362332
Change-Id: Ibbe69c321e9e2b744ec88cebbdc3476d776f5956
This commit is contained in:
Adam Wight 2024-04-15 10:29:38 +02:00
parent 463e25b742
commit f0849b2b17
7 changed files with 46 additions and 46 deletions

View file

@ -16,7 +16,7 @@ const gateway = createReferenceGateway();
// For tracking baseline stats in the Cite extension https://phabricator.wikimedia.org/T353798
// FIXME: This might be obsolete when the code moves to the Cite extension and the tracking there
// can check that state differently.
mw.config.set( 'wgPopupsReferencePreviewsVisible', !!referencePreviewsState );
mw.config.set( 'wgCiteReferencePreviewsVisible', !!referencePreviewsState );
mw.trackSubscribe( 'Popups.SettingChange', ( data ) => {
if ( data.previewType === TYPE_REFERENCE ) {

View file

@ -16,13 +16,13 @@ const { TYPE_REFERENCE } = require( './constants.js' );
*/
function isReferencePreviewsEnabled( user, isPreviewTypeEnabled, config ) {
// TODO: This and the final `mw.user.options` check are currently redundant. Only this here
// should be removed when the wgPopupsReferencePreviews feature flag is not needed any more.
if ( !config.get( 'wgPopupsReferencePreviews' ) ) {
// should be removed when the wgCiteReferencePreviews feature flag is not needed any more.
if ( !config.get( 'wgCiteReferencePreviews' ) ) {
return null;
}
// T265872: Unavailable when in conflict with (one of the) reference tooltips gadgets.
if ( config.get( 'wgPopupsConflictsWithRefTooltipsGadget' ) ||
if ( config.get( 'wgCiteReferencePreviewsConflictsWithRefTooltipsGadget' ) ||
config.get( 'wgPopupsConflictsWithNavPopupGadget' ) ||
// T243822: Temporarily disabled in the mobile skin
config.get( 'skin' ) === 'minerva'

View file

@ -6,7 +6,7 @@ const LOGGING_SCHEMA = 'event.ReferencePreviewsPopups';
* Run once the preview is initialized.
*/
function initReferencePreviewsInstrumentation() {
if ( mw.config.get( 'wgPopupsReferencePreviews' ) &&
if ( mw.config.get( 'wgCiteReferencePreviews' ) &&
navigator.sendBeacon &&
mw.config.get( 'wgIsArticle' ) &&
!isTracking

View file

@ -18,11 +18,11 @@ module.exports = function setUserConfigFlags( config ) {
/* eslint-disable no-bitwise */
config.set(
'wgPopupsConflictsWithRefTooltipsGadget',
'wgCiteReferencePreviewsConflictsWithRefTooltipsGadget',
!!( popupsFlags & REF_TOOLTIPS_ENABLED )
);
config.set(
'wgPopupsReferencePreviews',
'wgCiteReferencePreviews',
!!( popupsFlags & REFERENCE_PREVIEWS_ENABLED )
);
/* eslint-enable no-bitwise */

View file

@ -28,7 +28,7 @@ mw.loader.using( 'ext.eventLogging' ).then( function () {
// FIXME: This might be obsolete when the code moves to the this extension
mw.trackSubscribe( REFERENCE_PREVIEWS_LOGGING_SCHEMA, function ( type, data ) {
if ( data.action.indexOf( 'anonymous' ) !== -1 ) {
mw.config.set( 'wgPopupsReferencePreviewsVisible', data.action === 'anonymousEnabled' );
mw.config.set( 'wgCiteReferencePreviewsVisible', data.action === 'anonymousEnabled' );
}
} );
@ -46,7 +46,7 @@ mw.loader.using( 'ext.eventLogging' ).then( function () {
// FIXME: This might be obsolete when the code moves to the this extension and
// we get state directly.
// eslint-disable-next-line camelcase
with_ref_previews: mw.config.get( 'wgPopupsReferencePreviewsVisible' )
with_ref_previews: mw.config.get( 'wgCiteReferencePreviewsVisible' )
} );
}
);

View file

@ -28,8 +28,8 @@ QUnit.test( 'all relevant combinations of flags', ( assert ) => {
[
{
testCase: 'enabled for an anonymous user',
wgPopupsReferencePreviews: true,
wgPopupsConflictsWithRefTooltipsGadget: false,
wgCiteReferencePreviews: true,
wgCiteReferencePreviewsConflictsWithRefTooltipsGadget: false,
isMobile: false,
isAnon: true,
enabledByAnon: true,
@ -38,8 +38,8 @@ QUnit.test( 'all relevant combinations of flags', ( assert ) => {
},
{
testCase: 'turned off via the feature flag (anonymous user)',
wgPopupsReferencePreviews: false,
wgPopupsConflictsWithRefTooltipsGadget: false,
wgCiteReferencePreviews: false,
wgCiteReferencePreviewsConflictsWithRefTooltipsGadget: false,
isMobile: false,
isAnon: true,
enabledByAnon: true,
@ -48,8 +48,8 @@ QUnit.test( 'all relevant combinations of flags', ( assert ) => {
},
{
testCase: 'not available because of a conflicting gadget (anonymous user)',
wgPopupsReferencePreviews: true,
wgPopupsConflictsWithRefTooltipsGadget: true,
wgCiteReferencePreviews: true,
wgCiteReferencePreviewsConflictsWithRefTooltipsGadget: true,
isMobile: false,
isAnon: true,
enabledByAnon: true,
@ -58,8 +58,8 @@ QUnit.test( 'all relevant combinations of flags', ( assert ) => {
},
{
testCase: 'not available in the mobile skin (anonymous user)',
wgPopupsReferencePreviews: true,
wgPopupsConflictsWithRefTooltipsGadget: false,
wgCiteReferencePreviews: true,
wgCiteReferencePreviewsConflictsWithRefTooltipsGadget: false,
isMobile: true,
isAnon: true,
enabledByAnon: true,
@ -68,8 +68,8 @@ QUnit.test( 'all relevant combinations of flags', ( assert ) => {
},
{
testCase: 'manually disabled by the anonymous user',
wgPopupsReferencePreviews: true,
wgPopupsConflictsWithRefTooltipsGadget: false,
wgCiteReferencePreviews: true,
wgCiteReferencePreviewsConflictsWithRefTooltipsGadget: false,
isMobile: false,
isAnon: true,
enabledByAnon: false,
@ -78,8 +78,8 @@ QUnit.test( 'all relevant combinations of flags', ( assert ) => {
},
{
testCase: 'enabled for a registered user',
wgPopupsReferencePreviews: true,
wgPopupsConflictsWithRefTooltipsGadget: false,
wgCiteReferencePreviews: true,
wgCiteReferencePreviewsConflictsWithRefTooltipsGadget: false,
isMobile: false,
isAnon: false,
enabledByAnon: false,
@ -88,8 +88,8 @@ QUnit.test( 'all relevant combinations of flags', ( assert ) => {
},
{
testCase: 'turned off via the feature flag (registered user)',
wgPopupsReferencePreviews: false,
wgPopupsConflictsWithRefTooltipsGadget: false,
wgCiteReferencePreviews: false,
wgCiteReferencePreviewsConflictsWithRefTooltipsGadget: false,
isMobile: false,
isAnon: false,
enabledByAnon: true,
@ -98,8 +98,8 @@ QUnit.test( 'all relevant combinations of flags', ( assert ) => {
},
{
testCase: 'not available because of a conflicting gadget (registered user)',
wgPopupsReferencePreviews: true,
wgPopupsConflictsWithRefTooltipsGadget: true,
wgCiteReferencePreviews: true,
wgCiteReferencePreviewsConflictsWithRefTooltipsGadget: true,
isMobile: false,
isAnon: false,
enabledByAnon: true,
@ -108,8 +108,8 @@ QUnit.test( 'all relevant combinations of flags', ( assert ) => {
},
{
testCase: 'not available in the mobile skin (registered user)',
wgPopupsReferencePreviews: true,
wgPopupsConflictsWithRefTooltipsGadget: false,
wgCiteReferencePreviews: true,
wgCiteReferencePreviewsConflictsWithRefTooltipsGadget: false,
isMobile: true,
isAnon: false,
enabledByAnon: true,
@ -118,10 +118,10 @@ QUnit.test( 'all relevant combinations of flags', ( assert ) => {
},
{
// TODO: This combination will make much more sense when the server-side
// wgPopupsReferencePreviews flag doesn't include the user's setting any more
// wgCiteReferencePreviews flag doesn't include the user's setting any more
testCase: 'manually disabled by the registered user',
wgPopupsReferencePreviews: true,
wgPopupsConflictsWithRefTooltipsGadget: false,
wgCiteReferencePreviews: true,
wgCiteReferencePreviewsConflictsWithRefTooltipsGadget: false,
isMobile: false,
isAnon: false,
enabledByAnon: true,
@ -165,8 +165,8 @@ QUnit.test( 'it should display reference previews when conditions are fulfilled'
userSettings = createStubUserSettings( false ),
config = new Map();
config.set( 'wgPopupsReferencePreviews', true );
config.set( 'wgPopupsConflictsWithRefTooltipsGadget', false );
config.set( 'wgCiteReferencePreviews', true );
config.set( 'wgCiteReferencePreviewsConflictsWithRefTooltipsGadget', false );
assert.true(
require( 'ext.cite.referencePreviews' ).private.isReferencePreviewsEnabled( user, userSettings, config ),
@ -179,8 +179,8 @@ QUnit.test( 'it should handle the conflict with the Reference Tooltips Gadget',
userSettings = createStubUserSettings( false ),
config = new Map();
config.set( 'wgPopupsReferencePreviews', true );
config.set( 'wgPopupsConflictsWithRefTooltipsGadget', true );
config.set( 'wgCiteReferencePreviews', true );
config.set( 'wgCiteReferencePreviewsConflictsWithRefTooltipsGadget', true );
assert.strictEqual(
require( 'ext.cite.referencePreviews' ).private.isReferencePreviewsEnabled( user, userSettings, config ),
@ -194,8 +194,8 @@ QUnit.test( 'it should not be enabled when the global is disabling it', ( assert
userSettings = createStubUserSettings( false ),
config = new Map();
config.set( 'wgPopupsReferencePreviews', false );
config.set( 'wgPopupsConflictsWithRefTooltipsGadget', false );
config.set( 'wgCiteReferencePreviews', false );
config.set( 'wgCiteReferencePreviewsConflictsWithRefTooltipsGadget', false );
assert.strictEqual(
require( 'ext.cite.referencePreviews' ).private.isReferencePreviewsEnabled( user, userSettings, config ),
@ -209,8 +209,8 @@ QUnit.test( 'it should not be enabled when minerva skin used', ( assert ) => {
userSettings = createStubUserSettings( false ),
config = new Map();
config.set( 'wgPopupsReferencePreviews', true );
config.set( 'wgPopupsConflictsWithRefTooltipsGadget', false );
config.set( 'wgCiteReferencePreviews', true );
config.set( 'wgCiteReferencePreviewsConflictsWithRefTooltipsGadget', false );
config.set( 'skin', 'minerva' );
assert.strictEqual(

View file

@ -10,8 +10,8 @@ QUnit.test( 'reference preview config settings are successfully set from bitmask
assert.deepEqual(
[
config.get( 'wgPopupsConflictsWithRefTooltipsGadget' ),
config.get( 'wgPopupsReferencePreviews' )
config.get( 'wgCiteReferencePreviewsConflictsWithRefTooltipsGadget' ),
config.get( 'wgCiteReferencePreviews' )
],
[ true, true ]
);
@ -21,8 +21,8 @@ QUnit.test( 'reference preview config settings are successfully set from bitmask
assert.deepEqual(
[
config.get( 'wgPopupsConflictsWithRefTooltipsGadget' ),
config.get( 'wgPopupsReferencePreviews' )
config.get( 'wgCiteReferencePreviewsConflictsWithRefTooltipsGadget' ),
config.get( 'wgCiteReferencePreviews' )
],
[ true, false ]
);
@ -32,8 +32,8 @@ QUnit.test( 'reference preview config settings are successfully set from bitmask
assert.deepEqual(
[
config.get( 'wgPopupsConflictsWithRefTooltipsGadget' ),
config.get( 'wgPopupsReferencePreviews' )
config.get( 'wgCiteReferencePreviewsConflictsWithRefTooltipsGadget' ),
config.get( 'wgCiteReferencePreviews' )
],
[ false, true ]
);
@ -43,8 +43,8 @@ QUnit.test( 'reference preview config settings are successfully set from bitmask
assert.deepEqual(
[
config.get( 'wgPopupsConflictsWithRefTooltipsGadget' ),
config.get( 'wgPopupsReferencePreviews' )
config.get( 'wgCiteReferencePreviewsConflictsWithRefTooltipsGadget' ),
config.get( 'wgCiteReferencePreviews' )
],
[ false, false ]
);