ArticleTarget#switchToVisualEditor: Bail if the server won't let you switch

Because otherwise you're just throwing all the user's input on the floor.

Bug: T158692
Change-Id: I5df00842697be11ecde9ea8ba2ab16b0dc90205e
This commit is contained in:
James D. Forrester 2017-03-09 17:09:14 -08:00
parent 0d113dd032
commit d1f2bf1ecf

View file

@ -2240,9 +2240,13 @@ ve.init.mw.ArticleTarget.prototype.switchToVisualEditor = function () {
var dataPromise, windowManager, switchWindow,
target = this;
if ( this.section !== null ) {
// WT -> VE switching is not yet supported in sections, so
// show a discard-only confirm dialog, then reload the whole page.
// Show a discard-only confirm dialog, and then reload the whole page, if:
if (
// * section editing in WT, as WT -> VE is not yet supported, or
this.section !== null ||
// * the server can't switch for us because that's not supported.
!mw.config.get( 'wgVisualEditorConfig' ).fullRestbaseUrl
) {
windowManager = new OO.ui.WindowManager();
switchWindow = new mw.libs.ve.SwitchConfirmDialog();
$( 'body' ).append( windowManager.$element );