mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-23 15:16:50 +00:00
IP masked users use localStorage for settings
Bug: T330517 Change-Id: Ib283e37f379e8cccc7f49ab0ce9aadd6535ea668
This commit is contained in:
parent
140c9bf1ab
commit
049729626c
|
@ -72,7 +72,7 @@
|
|||
"bundlesize": [
|
||||
{
|
||||
"path": "resources/dist/index.js",
|
||||
"maxSize": "14.3kB"
|
||||
"maxSize": "14.4kB"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
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.
|
@ -89,7 +89,7 @@ export function boot(
|
|||
id: config.get( 'wgArticleId' )
|
||||
},
|
||||
user: {
|
||||
isAnon: user.isAnon(),
|
||||
isAnon: user.isAnon() || mw.user.isTemp(),
|
||||
editCount
|
||||
}
|
||||
};
|
||||
|
|
11
src/canSaveToUserPreferences.js
Normal file
11
src/canSaveToUserPreferences.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
/**
|
||||
* Can the current user save to user preferences?
|
||||
*
|
||||
* @param {User} user
|
||||
* @return {boolean}
|
||||
*/
|
||||
const canSaveToUserPreferences = ( user ) => {
|
||||
return !user.isAnon() && user.isNamed();
|
||||
};
|
||||
|
||||
module.exports = canSaveToUserPreferences;
|
|
@ -1,6 +1,7 @@
|
|||
/**
|
||||
* @module isPagePreviewsEnabled
|
||||
*/
|
||||
const canSaveToUserPreferences = require( './canSaveToUserPreferences.js' );
|
||||
|
||||
/**
|
||||
* Given the global state of the application, creates a function that gets
|
||||
|
@ -24,9 +25,9 @@ export default function isPagePreviewsEnabled( user, userSettings, config ) {
|
|||
return null;
|
||||
}
|
||||
|
||||
// For anonymous users, the code loads always, but the feature can be toggled at run-time via
|
||||
// local storage.
|
||||
if ( user.isAnon() ) {
|
||||
// For anonymous users, and for IP masked usersm the code loads always,
|
||||
// but the feature can be toggled at run-time via local storage.
|
||||
if ( !canSaveToUserPreferences( user ) ) {
|
||||
return userSettings.isPagePreviewsEnabled();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/**
|
||||
* @module isReferencePreviewsEnabled
|
||||
*/
|
||||
const canSaveToUserPreferences = require( './canSaveToUserPreferences.js' );
|
||||
|
||||
/**
|
||||
* Given the global state of the application, creates a function that gets
|
||||
|
@ -29,7 +30,7 @@ export default function isReferencePreviewsEnabled( user, userSettings, config )
|
|||
|
||||
// For anonymous users, the code loads always, but the feature can be toggled at run-time via
|
||||
// local storage.
|
||||
if ( user.isAnon() ) {
|
||||
if ( !canSaveToUserPreferences( user ) ) {
|
||||
return userSettings.isReferencePreviewsEnabled();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/**
|
||||
* @module previewBehaviour
|
||||
*/
|
||||
const canSaveToUserPreferences = require( './canSaveToUserPreferences.js' );
|
||||
|
||||
/**
|
||||
* A collection of event handlers specific to how the user interacts with all
|
||||
|
@ -33,7 +34,7 @@
|
|||
export default function createPreviewBehavior( user, actions ) {
|
||||
let settingsUrl, showSettings = () => {};
|
||||
|
||||
if ( user.isAnon() ) {
|
||||
if ( !canSaveToUserPreferences( user ) ) {
|
||||
showSettings = ( event ) => {
|
||||
event.preventDefault();
|
||||
|
||||
|
|
|
@ -123,7 +123,10 @@ QUnit.test( 'all relevant combinations of flags', ( assert ) => {
|
|||
expected: null
|
||||
}
|
||||
].forEach( ( data ) => {
|
||||
const user = { isAnon: () => data.isAnon },
|
||||
const user = {
|
||||
isNamed: () => !data.isAnon && !data.isIPMasked,
|
||||
isAnon: () => data.isAnon
|
||||
},
|
||||
userSettings = {
|
||||
isReferencePreviewsEnabled: () => data.isAnon ?
|
||||
data.enabledByAnon :
|
||||
|
|
|
@ -10,6 +10,12 @@ export function createStubUser( isAnon ) {
|
|||
getPageviewToken() {
|
||||
return '9876543210';
|
||||
},
|
||||
isNamed() {
|
||||
return !isAnon;
|
||||
},
|
||||
isTemp() {
|
||||
return false;
|
||||
},
|
||||
isAnon() {
|
||||
return isAnon;
|
||||
},
|
||||
|
|
|
@ -112,8 +112,8 @@ module.exports = ( env, argv ) => ( {
|
|||
// Minified uncompressed size limits for chunks / assets and entrypoints. Keep these numbers
|
||||
// up-to-date and rounded to the nearest 10th of a kibibyte so that code sizing costs are
|
||||
// well understood. Related to bundlesize minified, gzipped compressed file size tests.
|
||||
maxAssetSize: 45.5 * 1024,
|
||||
maxEntrypointSize: 45.5 * 1024,
|
||||
maxAssetSize: 45.6 * 1024,
|
||||
maxEntrypointSize: 45.6 * 1024,
|
||||
|
||||
// The default filter excludes map files but we rename ours.
|
||||
assetFilter: ( filename ) => !filename.endsWith( srcMapExt )
|
||||
|
|
Loading…
Reference in a new issue