Glaisher has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/303430

Change subject: ext.translate.editor: Improve save failure detection
......................................................................

ext.translate.editor: Improve save failure detection

mw.API() edit doesn't always return fail promises for actual
save failures. The proper way to check for success is checking
for the presence of "Success" in the API result. As we didn't check
for this previously, this caused some save failures to be reported
as successful to the user. Also now specific messages are shown for
AbuseFilter and SpamBlacklist save failures.

Bug: T142291
Change-Id: I7533d6aaee017aeb11f4c48658a35550afc94946
---
M Resources.php
M resources/js/ext.translate.editor.js
2 files changed, 18 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate 
refs/changes/30/303430/1

diff --git a/Resources.php b/Resources.php
index 63a7b9e..d785d74 100644
--- a/Resources.php
+++ b/Resources.php
@@ -111,6 +111,7 @@
                'tux-status-unsaved',
                'tux-warnings-hide',
                'tux-warnings-more',
+               'spamprotectiontext',
        ),
        'position' => 'top',
 ) + $resourcePaths;
diff --git a/resources/js/ext.translate.editor.js 
b/resources/js/ext.translate.editor.js
index b8d4668..a34da7e 100644
--- a/resources/js/ext.translate.editor.js
+++ b/resources/js/ext.translate.editor.js
@@ -210,10 +210,23 @@
                                translateEditor.message.title,
                                translation,
                                editSummary
-                       ).done( function () {
-                               // Update the translation
-                               translateEditor.message.translation = 
translation;
-                               translateEditor.onSaveSuccess();
+                       ).done( function ( response, xhr ) {
+                               var editResp = response.edit;
+                               if ( editResp.result === 'Success' ) {
+                                       translateEditor.message.translation = 
translation;
+                                       translateEditor.onSaveSuccess();
+                               // Handle errors
+                               } else if ( editResp.spamblacklist ) {
+                                       // @todo Show exactly which blacklisted 
URL triggered it
+                                       translateEditor.onSaveFail( mw.msg( 
'spamprotectiontext' ) );
+                               } else if ( editResp.info
+                                       && editResp.info.indexOf( 'Hit 
AbuseFilter:' ) === 0 && editResp.warning
+                               ) {
+                                       translateEditor.onSaveFail( 
editResp.warning );
+                               } else {
+                                       translateEditor.onSaveFail( 'Unknown 
error occured.' );
+                                       mw.log( response, xhr );
+                               }
                        } ).fail( function ( errorCode, response ) {
                                translateEditor.onSaveFail( response.error && 
response.error.info || 'Unknown error' );
                                if ( errorCode === 'assertuserfailed' ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/303430
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7533d6aaee017aeb11f4c48658a35550afc94946
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Glaisher <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to