mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-12-01 02:36:35 +00:00
b2bd1ebdf7
Action changes: * Update the BOOT action to include isEnabled and update the associated tests. Reducer changes: * Make the preview and eventLogging reducers handle the BOOT action's new shape. Bug: T152687 Change-Id: I3fa2098269a32912eda99ceb8f13887688a14c15
32 lines
985 B
JavaScript
32 lines
985 B
JavaScript
( function ( mw ) {
|
|
|
|
/**
|
|
* Given the global state of the application, creates a function that gets
|
|
* whether or not the user should have Page Previews enabled.
|
|
*
|
|
* The user has previews enabled if:
|
|
* * The beta feature is available (see `$wgPopupsBetaFeature`) and they've
|
|
* enabled the beta feature.
|
|
* * They *haven't disabled* it via the settings modal.
|
|
*
|
|
* The first case covers the enabled by default case: if
|
|
* `$wgPopupsBetaFeature` is `false` and the user hasn't disabled previews via
|
|
* their preferences, then previews are enabled.
|
|
*
|
|
* @param {mw.user} user The `mw.user` singleton instance
|
|
* @param {Object} userSettings An object returned by
|
|
* `mw.popups.createUserSettings`
|
|
*
|
|
* @return {Boolean}
|
|
*/
|
|
mw.popups.isEnabled = function ( user, userSettings ) {
|
|
if ( user.isAnon() ) {
|
|
return false;
|
|
}
|
|
|
|
return !userSettings.hasIsEnabled() ||
|
|
( userSettings.hasIsEnabled() && userSettings.getIsEnabled() );
|
|
};
|
|
|
|
}( mediaWiki ) );
|