mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-30 18:34:40 +00:00
Merge "Fix settings dialog offering ReferencePreviews when unavailable"
This commit is contained in:
commit
d7869a0086
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.
|
@ -181,7 +181,8 @@ function registerChangeListeners(
|
||||||
pagePreviewGateway = createPagePreviewGateway( mw.config ),
|
pagePreviewGateway = createPagePreviewGateway( mw.config ),
|
||||||
referenceGateway = createReferenceGateway(),
|
referenceGateway = createReferenceGateway(),
|
||||||
userSettings = createUserSettings( mw.storage ),
|
userSettings = createUserSettings( mw.storage ),
|
||||||
settingsDialog = createSettingsDialogRenderer( mw.config ),
|
referencePreviewsState = isReferencePreviewsEnabled( mw.user, userSettings, mw.config ),
|
||||||
|
settingsDialog = createSettingsDialogRenderer( referencePreviewsState !== null ),
|
||||||
experiments = createExperiments( mw.experiments ),
|
experiments = createExperiments( mw.experiments ),
|
||||||
statsvTracker = getStatsvTracker( mw.user, mw.config, experiments ),
|
statsvTracker = getStatsvTracker( mw.user, mw.config, experiments ),
|
||||||
pageviewTracker = getPageviewTracker( mw.config ),
|
pageviewTracker = getPageviewTracker( mw.config ),
|
||||||
|
@ -193,8 +194,7 @@ function registerChangeListeners(
|
||||||
initiallyEnabled = {
|
initiallyEnabled = {
|
||||||
[ previewTypes.TYPE_PAGE ]:
|
[ previewTypes.TYPE_PAGE ]:
|
||||||
createIsPagePreviewsEnabled( mw.user, userSettings, mw.config ),
|
createIsPagePreviewsEnabled( mw.user, userSettings, mw.config ),
|
||||||
[ previewTypes.TYPE_REFERENCE ]:
|
[ previewTypes.TYPE_REFERENCE ]: referencePreviewsState
|
||||||
isReferencePreviewsEnabled( mw.user, userSettings, mw.config )
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// If debug mode is enabled, then enable Redux DevTools.
|
// If debug mode is enabled, then enable Redux DevTools.
|
||||||
|
|
|
@ -8,10 +8,10 @@ import { previewTypes } from '../preview/model';
|
||||||
/**
|
/**
|
||||||
* Create the settings dialog shown to anonymous users.
|
* Create the settings dialog shown to anonymous users.
|
||||||
*
|
*
|
||||||
* @param {boolean} isReferencePreviewsInBeta
|
* @param {boolean} referencePreviewsAvaliable
|
||||||
* @return {JQuery} settings dialog
|
* @return {JQuery} settings dialog
|
||||||
*/
|
*/
|
||||||
export function createSettingsDialog( isReferencePreviewsInBeta ) {
|
export function createSettingsDialog( referencePreviewsAvaliable ) {
|
||||||
const choices = [
|
const choices = [
|
||||||
{
|
{
|
||||||
id: previewTypes.TYPE_PAGE,
|
id: previewTypes.TYPE_PAGE,
|
||||||
|
@ -26,7 +26,7 @@ export function createSettingsDialog( isReferencePreviewsInBeta ) {
|
||||||
];
|
];
|
||||||
|
|
||||||
// TODO: Remove when not in Beta any more
|
// TODO: Remove when not in Beta any more
|
||||||
if ( isReferencePreviewsInBeta ) {
|
if ( !referencePreviewsAvaliable ) {
|
||||||
// Anonymous users can't access reference previews as long as they are in beta
|
// Anonymous users can't access reference previews as long as they are in beta
|
||||||
choices.splice( 1, 1 );
|
choices.splice( 1, 1 );
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,10 @@ import { createSettingsDialog } from './settingsDialog';
|
||||||
* Creates a render function that will create the settings dialog and return
|
* Creates a render function that will create the settings dialog and return
|
||||||
* a set of methods to operate on it
|
* a set of methods to operate on it
|
||||||
*
|
*
|
||||||
* @param {mw.Map} config
|
* @param {boolean} referencePreviewsAvaliable
|
||||||
* @return {Function} render function
|
* @return {Function} render function
|
||||||
*/
|
*/
|
||||||
export default function createSettingsDialogRenderer( config ) {
|
export default function createSettingsDialogRenderer( referencePreviewsAvaliable ) {
|
||||||
/**
|
/**
|
||||||
* Cached settings dialog
|
* Cached settings dialog
|
||||||
*
|
*
|
||||||
|
@ -33,7 +33,7 @@ export default function createSettingsDialogRenderer( config ) {
|
||||||
*/
|
*/
|
||||||
return ( boundActions ) => {
|
return ( boundActions ) => {
|
||||||
if ( !$dialog ) {
|
if ( !$dialog ) {
|
||||||
$dialog = createSettingsDialog( config.get( 'wgPopupsReferencePreviewsBetaFeature' ) );
|
$dialog = createSettingsDialog( referencePreviewsAvaliable );
|
||||||
$overlay = $( '<div>' ).addClass( 'mwe-popups-overlay' );
|
$overlay = $( '<div>' ).addClass( 'mwe-popups-overlay' );
|
||||||
|
|
||||||
// Setup event bindings
|
// Setup event bindings
|
||||||
|
|
Loading…
Reference in a new issue