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 // 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 // FIXME: This might be obsolete when the code moves to the Cite extension and the tracking there
// can check that state differently. // can check that state differently.
mw.config.set( 'wgPopupsReferencePreviewsVisible', !!referencePreviewsState ); mw.config.set( 'wgCiteReferencePreviewsVisible', !!referencePreviewsState );
mw.trackSubscribe( 'Popups.SettingChange', ( data ) => { mw.trackSubscribe( 'Popups.SettingChange', ( data ) => {
if ( data.previewType === TYPE_REFERENCE ) { if ( data.previewType === TYPE_REFERENCE ) {

View file

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

View file

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

View file

@ -18,11 +18,11 @@ module.exports = function setUserConfigFlags( config ) {
/* eslint-disable no-bitwise */ /* eslint-disable no-bitwise */
config.set( config.set(
'wgPopupsConflictsWithRefTooltipsGadget', 'wgCiteReferencePreviewsConflictsWithRefTooltipsGadget',
!!( popupsFlags & REF_TOOLTIPS_ENABLED ) !!( popupsFlags & REF_TOOLTIPS_ENABLED )
); );
config.set( config.set(
'wgPopupsReferencePreviews', 'wgCiteReferencePreviews',
!!( popupsFlags & REFERENCE_PREVIEWS_ENABLED ) !!( popupsFlags & REFERENCE_PREVIEWS_ENABLED )
); );
/* eslint-enable no-bitwise */ /* 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 // FIXME: This might be obsolete when the code moves to the this extension
mw.trackSubscribe( REFERENCE_PREVIEWS_LOGGING_SCHEMA, function ( type, data ) { mw.trackSubscribe( REFERENCE_PREVIEWS_LOGGING_SCHEMA, function ( type, data ) {
if ( data.action.indexOf( 'anonymous' ) !== -1 ) { 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 // FIXME: This might be obsolete when the code moves to the this extension and
// we get state directly. // we get state directly.
// eslint-disable-next-line camelcase // 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', testCase: 'enabled for an anonymous user',
wgPopupsReferencePreviews: true, wgCiteReferencePreviews: true,
wgPopupsConflictsWithRefTooltipsGadget: false, wgCiteReferencePreviewsConflictsWithRefTooltipsGadget: false,
isMobile: false, isMobile: false,
isAnon: true, isAnon: true,
enabledByAnon: true, enabledByAnon: true,
@ -38,8 +38,8 @@ QUnit.test( 'all relevant combinations of flags', ( assert ) => {
}, },
{ {
testCase: 'turned off via the feature flag (anonymous user)', testCase: 'turned off via the feature flag (anonymous user)',
wgPopupsReferencePreviews: false, wgCiteReferencePreviews: false,
wgPopupsConflictsWithRefTooltipsGadget: false, wgCiteReferencePreviewsConflictsWithRefTooltipsGadget: false,
isMobile: false, isMobile: false,
isAnon: true, isAnon: true,
enabledByAnon: 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)', testCase: 'not available because of a conflicting gadget (anonymous user)',
wgPopupsReferencePreviews: true, wgCiteReferencePreviews: true,
wgPopupsConflictsWithRefTooltipsGadget: true, wgCiteReferencePreviewsConflictsWithRefTooltipsGadget: true,
isMobile: false, isMobile: false,
isAnon: true, isAnon: true,
enabledByAnon: true, enabledByAnon: true,
@ -58,8 +58,8 @@ QUnit.test( 'all relevant combinations of flags', ( assert ) => {
}, },
{ {
testCase: 'not available in the mobile skin (anonymous user)', testCase: 'not available in the mobile skin (anonymous user)',
wgPopupsReferencePreviews: true, wgCiteReferencePreviews: true,
wgPopupsConflictsWithRefTooltipsGadget: false, wgCiteReferencePreviewsConflictsWithRefTooltipsGadget: false,
isMobile: true, isMobile: true,
isAnon: true, isAnon: true,
enabledByAnon: true, enabledByAnon: true,
@ -68,8 +68,8 @@ QUnit.test( 'all relevant combinations of flags', ( assert ) => {
}, },
{ {
testCase: 'manually disabled by the anonymous user', testCase: 'manually disabled by the anonymous user',
wgPopupsReferencePreviews: true, wgCiteReferencePreviews: true,
wgPopupsConflictsWithRefTooltipsGadget: false, wgCiteReferencePreviewsConflictsWithRefTooltipsGadget: false,
isMobile: false, isMobile: false,
isAnon: true, isAnon: true,
enabledByAnon: false, enabledByAnon: false,
@ -78,8 +78,8 @@ QUnit.test( 'all relevant combinations of flags', ( assert ) => {
}, },
{ {
testCase: 'enabled for a registered user', testCase: 'enabled for a registered user',
wgPopupsReferencePreviews: true, wgCiteReferencePreviews: true,
wgPopupsConflictsWithRefTooltipsGadget: false, wgCiteReferencePreviewsConflictsWithRefTooltipsGadget: false,
isMobile: false, isMobile: false,
isAnon: false, isAnon: false,
enabledByAnon: false, enabledByAnon: false,
@ -88,8 +88,8 @@ QUnit.test( 'all relevant combinations of flags', ( assert ) => {
}, },
{ {
testCase: 'turned off via the feature flag (registered user)', testCase: 'turned off via the feature flag (registered user)',
wgPopupsReferencePreviews: false, wgCiteReferencePreviews: false,
wgPopupsConflictsWithRefTooltipsGadget: false, wgCiteReferencePreviewsConflictsWithRefTooltipsGadget: false,
isMobile: false, isMobile: false,
isAnon: false, isAnon: false,
enabledByAnon: true, enabledByAnon: true,
@ -98,8 +98,8 @@ QUnit.test( 'all relevant combinations of flags', ( assert ) => {
}, },
{ {
testCase: 'not available because of a conflicting gadget (registered user)', testCase: 'not available because of a conflicting gadget (registered user)',
wgPopupsReferencePreviews: true, wgCiteReferencePreviews: true,
wgPopupsConflictsWithRefTooltipsGadget: true, wgCiteReferencePreviewsConflictsWithRefTooltipsGadget: true,
isMobile: false, isMobile: false,
isAnon: false, isAnon: false,
enabledByAnon: true, enabledByAnon: true,
@ -108,8 +108,8 @@ QUnit.test( 'all relevant combinations of flags', ( assert ) => {
}, },
{ {
testCase: 'not available in the mobile skin (registered user)', testCase: 'not available in the mobile skin (registered user)',
wgPopupsReferencePreviews: true, wgCiteReferencePreviews: true,
wgPopupsConflictsWithRefTooltipsGadget: false, wgCiteReferencePreviewsConflictsWithRefTooltipsGadget: false,
isMobile: true, isMobile: true,
isAnon: false, isAnon: false,
enabledByAnon: true, 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 // 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', testCase: 'manually disabled by the registered user',
wgPopupsReferencePreviews: true, wgCiteReferencePreviews: true,
wgPopupsConflictsWithRefTooltipsGadget: false, wgCiteReferencePreviewsConflictsWithRefTooltipsGadget: false,
isMobile: false, isMobile: false,
isAnon: false, isAnon: false,
enabledByAnon: true, enabledByAnon: true,
@ -165,8 +165,8 @@ QUnit.test( 'it should display reference previews when conditions are fulfilled'
userSettings = createStubUserSettings( false ), userSettings = createStubUserSettings( false ),
config = new Map(); config = new Map();
config.set( 'wgPopupsReferencePreviews', true ); config.set( 'wgCiteReferencePreviews', true );
config.set( 'wgPopupsConflictsWithRefTooltipsGadget', false ); config.set( 'wgCiteReferencePreviewsConflictsWithRefTooltipsGadget', false );
assert.true( assert.true(
require( 'ext.cite.referencePreviews' ).private.isReferencePreviewsEnabled( user, userSettings, config ), 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 ), userSettings = createStubUserSettings( false ),
config = new Map(); config = new Map();
config.set( 'wgPopupsReferencePreviews', true ); config.set( 'wgCiteReferencePreviews', true );
config.set( 'wgPopupsConflictsWithRefTooltipsGadget', true ); config.set( 'wgCiteReferencePreviewsConflictsWithRefTooltipsGadget', true );
assert.strictEqual( assert.strictEqual(
require( 'ext.cite.referencePreviews' ).private.isReferencePreviewsEnabled( user, userSettings, config ), 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 ), userSettings = createStubUserSettings( false ),
config = new Map(); config = new Map();
config.set( 'wgPopupsReferencePreviews', false ); config.set( 'wgCiteReferencePreviews', false );
config.set( 'wgPopupsConflictsWithRefTooltipsGadget', false ); config.set( 'wgCiteReferencePreviewsConflictsWithRefTooltipsGadget', false );
assert.strictEqual( assert.strictEqual(
require( 'ext.cite.referencePreviews' ).private.isReferencePreviewsEnabled( user, userSettings, config ), 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 ), userSettings = createStubUserSettings( false ),
config = new Map(); config = new Map();
config.set( 'wgPopupsReferencePreviews', true ); config.set( 'wgCiteReferencePreviews', true );
config.set( 'wgPopupsConflictsWithRefTooltipsGadget', false ); config.set( 'wgCiteReferencePreviewsConflictsWithRefTooltipsGadget', false );
config.set( 'skin', 'minerva' ); config.set( 'skin', 'minerva' );
assert.strictEqual( assert.strictEqual(

View file

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