mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-12-12 15:15:12 +00:00
e3fdee52aa
The two are different: * CiteReferencePreviews as specified in extension.json is a feature flag that allows us to disable the feature entirely. It could be named "CiteReferencePreviewsFeature" or "CiteEnableReferencePreviews", but renaming a feature flag that's already in use is hard. * The client-side flag tells the JavaScript code "you know what, it was kind of a mistake you got loaded, please stop". This is because we can not make all decisions before we register the ResourceLoader module, e.g. if the user has certain gadgets enabled. Adding the word "Active" is not a huge improvement, but at least makes the two different now. Suggestions welcome. Bug: T362771 Change-Id: I0f6a911df8772616ac50c1301f402f77dbe32089
30 lines
824 B
JavaScript
30 lines
824 B
JavaScript
const { TYPE_REFERENCE } = require( './constants.js' );
|
|
|
|
/**
|
|
* @module isReferencePreviewsEnabled
|
|
*/
|
|
|
|
/**
|
|
* Given the global state of the application, creates a function that gets
|
|
* whether or not the user should have Reference Previews enabled.
|
|
*
|
|
* @param {mw.user} user The `mw.user` singleton instance
|
|
* @param {Function} isPreviewTypeEnabled check whether preview has been disabled or enabled.
|
|
* @param {mw.Map} config
|
|
*
|
|
* @return {boolean|null} Null when there is no way the popup type can be enabled at run-time.
|
|
*/
|
|
function isReferencePreviewsEnabled( user, isPreviewTypeEnabled, config ) {
|
|
if ( !config.get( 'wgCiteReferencePreviewsActive' ) ) {
|
|
return null;
|
|
}
|
|
|
|
if ( user.isAnon() ) {
|
|
return isPreviewTypeEnabled( TYPE_REFERENCE );
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
module.exports = isReferencePreviewsEnabled;
|