mediawiki-extensions-TitleB.../modules/ve-titleblacklist/ve.init.mw.TitleBlacklistSaveErrorHandler.js
Bartosz Dziewoński cba4d461b9 VE: Update for errorformat=html
Update matchFunction() to match the new format of responses.

Remove custom error message from process(), it's worse than the default.

Bug: T229532
Depends-On: I3b9c4fefc0869ef7999c21cef754434febd852ec
Change-Id: Ibeae79c95557a7af699716c9d921f34c310bee6d
2019-08-22 00:38:02 +00:00

24 lines
909 B
JavaScript

mw.libs.ve.targetLoader.addPlugin( function () {
ve.init.mw.TitleBlacklistSaveErrorHandler = function () {};
OO.inheritClass( ve.init.mw.TitleBlacklistSaveErrorHandler, ve.init.mw.SaveErrorHandler );
ve.init.mw.TitleBlacklistSaveErrorHandler.static.name = 'titleBlacklist';
ve.init.mw.TitleBlacklistSaveErrorHandler.static.matchFunction = function ( data ) {
return data.errors && data.errors.some( function ( err ) {
return err.code === 'titleblacklist-forbidden';
} );
};
ve.init.mw.TitleBlacklistSaveErrorHandler.static.process = function ( data, target ) {
// Handle warnings/errors from Extension:TitleBlacklist
target.showSaveError( target.extractErrorMessages( data ), false );
// Emit event for tracking. TODO: This is a bad design
target.emit( 'saveErrorTitleBlacklist' );
};
ve.init.mw.saveErrorHandlerFactory.register( ve.init.mw.TitleBlacklistSaveErrorHandler );
} );