ReplyWidget: Handle save errors

Bug: T240519
Depends-On: Ie18666b41f4aff1ab4bcf93f9df6e3000ac7b500
Depends-On: I2a731cb273401074e65f9283c1f629dbdb272002
Change-Id: Ice92fafb1f546510dab28e3f8aa7d2280668965a
This commit is contained in:
Bartosz Dziewoński 2019-12-11 05:40:17 +01:00
parent 0a88c0fbba
commit 6d243ed74a
4 changed files with 23 additions and 3 deletions

View file

@ -90,14 +90,18 @@ ReplyWidget.prototype.createReplyBodyWidget = null;
ReplyWidget.prototype.focus = null;
ReplyWidget.prototype.clear = null;
ReplyWidget.prototype.insertNewNodes = null;
ReplyWidget.prototype.getValue = null;
ReplyWidget.prototype.isEmpty = null;
ReplyWidget.prototype.clear = function () {
if ( this.errorMessage ) {
this.errorMessage.$element.remove();
}
};
ReplyWidget.prototype.setPending = function ( pending ) {
if ( pending ) {
this.replyButton.setDisabled( true );
@ -234,6 +238,10 @@ ReplyWidget.prototype.onReplyClick = function () {
var repliedTo,
widget = this;
if ( this.errorMessage ) {
this.errorMessage.$element.remove();
}
this.setPending( true );
this.comment.parsoidPromise.then( function ( parsoidData ) {
@ -262,6 +270,12 @@ ReplyWidget.prototype.onReplyClick = function () {
repliedTo: repliedTo
} );
mw.hook( 'wikipage.content' ).fire( $container );
}, function ( code, data ) {
widget.errorMessage = new OO.ui.MessageWidget( {
type: 'error',
label: ( new mw.Api() ).getErrorMessage( data )
} );
widget.errorMessage.$element.insertBefore( widget.replyBodyWidget.$element );
} ).always( function () {
widget.setPending( false );
} );

View file

@ -19,7 +19,7 @@
margin-left: -1.6em;
}
&-anonWarning {
.oo-ui-messageWidget {
margin-bottom: 0.5em;
}
}

View file

@ -43,6 +43,9 @@ ReplyWidgetPlain.prototype.focus = function () {
};
ReplyWidgetPlain.prototype.clear = function () {
// Parent method
ReplyWidgetPlain.super.prototype.clear.apply( this, arguments );
this.replyBodyWidget.setValue( '' );
};

View file

@ -34,6 +34,9 @@ ReplyWidgetVisual.prototype.getValue = function () {
};
ReplyWidgetVisual.prototype.clear = function () {
// Parent method
ReplyWidgetVisual.super.prototype.clear.apply( this, arguments );
this.replyBodyWidget.clear();
};