mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-18 03:41:45 +00:00
8ae4925676
* Change the query in ve.init.mw.ArticleTargetLoader#requestParsoidData so that in non-RESTBase mode with wikitext it still returns the metadata required to initialize the editor, using the backend API code added in I1b35b28e428a1f86d2e34d90ddbe73361ce14818. This fixes the exception from T222312. * Introduce new configuration option $wgVisualEditorAllowLossySwitching to control this feature. It is enabled by default, fixing T214542. We allow it to be disabled because switching in non-RESTBase mode may cause "dirty diffs" (non-semantic changes to the wikitext), which are undesirable on wikis where users carefully review all changes. Bug: T214542 Bug: T222312 Change-Id: I58879cba5612002c70c24731306214d2577c2c52
106 lines
2.8 KiB
JavaScript
106 lines
2.8 KiB
JavaScript
/*!
|
|
* VisualEditor user interface MWVESwitchConfirmDialog class.
|
|
*
|
|
* @copyright 2011-2019 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
mw.libs.ve = mw.libs.ve || {};
|
|
/**
|
|
* Dialog for letting the user choose how to switch to wikitext mode.
|
|
*
|
|
* @class
|
|
* @extends OO.ui.MessageDialog
|
|
*
|
|
* @constructor
|
|
* @param {Object} [config] Configuration options
|
|
*/
|
|
mw.libs.ve.SwitchConfirmDialog = function MWLibsVESwitchConfirmDialog( config ) {
|
|
// Parent constructor
|
|
mw.libs.ve.SwitchConfirmDialog.super.call( this, config );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( mw.libs.ve.SwitchConfirmDialog, OO.ui.MessageDialog );
|
|
|
|
/* Static Properties */
|
|
|
|
mw.libs.ve.SwitchConfirmDialog.static.name = 'veswitchconfirm';
|
|
|
|
mw.libs.ve.SwitchConfirmDialog.static.title =
|
|
mw.msg( 'visualeditor-mweditmodeve-title' );
|
|
|
|
mw.libs.ve.SwitchConfirmDialog.static.message =
|
|
mw.msg( 'visualeditor-mweditmodeve-warning' );
|
|
|
|
mw.libs.ve.SwitchConfirmDialog.static.actions = [
|
|
{
|
|
action: 'cancel',
|
|
label: mw.msg( 'visualeditor-mweditmodesource-warning-cancel' ),
|
|
flags: [ 'safe', 'back' ],
|
|
modes: [ 'restbase', 'simple' ]
|
|
},
|
|
{
|
|
action: 'discard',
|
|
label: mw.msg( 'visualeditor-mweditmodesource-warning-switch-discard' ),
|
|
flags: 'destructive',
|
|
modes: [ 'simple' ]
|
|
},
|
|
{
|
|
action: 'keep',
|
|
label: mw.msg( 'visualeditor-mweditmodesource-warning-switch' ),
|
|
flags: [ 'progressive', 'primary' ],
|
|
modes: [ 'restbase' ]
|
|
}
|
|
];
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
mw.libs.ve.SwitchConfirmDialog.prototype.getSetupProcess = function ( data ) {
|
|
return mw.libs.ve.SwitchConfirmDialog.super.prototype.getSetupProcess.apply( this, arguments )
|
|
.next( function () {
|
|
var
|
|
config = mw.config.get( 'wgVisualEditorConfig' ),
|
|
canSwitch = config.fullRestbaseUrl || config.allowLossySwitching;
|
|
if ( data && data.mode ) {
|
|
this.actions.setMode( data.mode );
|
|
} else if ( canSwitch ) {
|
|
this.actions.setMode( 'restbase' );
|
|
} else {
|
|
this.actions.setMode( 'simple' );
|
|
}
|
|
}, this );
|
|
};
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
mw.libs.ve.SwitchConfirmDialog.prototype.getActionProcess = function ( action ) {
|
|
if ( action === 'keep' ) {
|
|
return new OO.ui.Process( function () {
|
|
this.getActions()
|
|
.setAbilities( { cancel: false, discard: false } )
|
|
.get( { actions: 'keep' } )[ 0 ].pushPending();
|
|
this.close( { action: 'keep' } );
|
|
}, this );
|
|
} else if ( action === 'discard' ) {
|
|
return new OO.ui.Process( function () {
|
|
this.getActions()
|
|
.setAbilities( { cancel: false, keep: false } )
|
|
.get( { actions: 'discard' } )[ 0 ].pushPending();
|
|
this.close( { action: 'discard' } );
|
|
}, this );
|
|
} else if ( action === 'cancel' ) {
|
|
return new OO.ui.Process( function () {
|
|
this.close( { action: 'cancel' } );
|
|
}, this );
|
|
}
|
|
|
|
// Parent method
|
|
return mw.libs.ve.SwitchConfirmDialog.super.prototype.getActionProcess.call( this, action );
|
|
};
|