r85567 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85566‎ | r85567 | r85568 >
Date:19:58, 6 April 2011
Author:kaldari
Status:deferred
Tags:
Comment:
better error handling for feedback
Modified paths:
  • /trunk/extensions/UploadWizard/UploadWizard.i18n.php (modified) (history)
  • /trunk/extensions/UploadWizard/UploadWizardHooks.php (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.UploadWizard.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/UploadWizardHooks.php
@@ -303,7 +303,8 @@
304304 'mwe-upwiz-feedback-submit',
305305 'mwe-upwiz-feedback-adding',
306306 'mwe-upwiz-feedback-error1',
307 - 'mwe-upwiz-feedback-error2'
 307+ 'mwe-upwiz-feedback-error2',
 308+ 'mwe-upwiz-feedback-error3'
308309 ),
309310 'group' => 'ext.uploadWizard'
310311 ),
Index: trunk/extensions/UploadWizard/UploadWizard.i18n.php
@@ -256,8 +256,9 @@
257257 'mwe-upwiz-feedback-cancel' => 'Cancel',
258258 'mwe-upwiz-feedback-submit' => 'Submit Feedback',
259259 'mwe-upwiz-feedback-adding' => 'Adding feedback to page...',
260 - 'mwe-upwiz-feedback-error1' => 'Error: Unknown result from API',
261 - 'mwe-upwiz-feedback-error2' => 'Error: Edit failed'
 260+ 'mwe-upwiz-feedback-error1' => 'Error: Unrecognized result from API',
 261+ 'mwe-upwiz-feedback-error2' => 'Error: Edit failed',
 262+ 'mwe-upwiz-feedback-error3' => 'Error: No response from API'
262263
263264 );
264265
@@ -308,7 +309,7 @@
309310 'mwe-upwiz-feedback-subject' => 'Label for a text input',
310311 'mwe-upwiz-feedback-message' => 'Label for a textarea; signature referrs to a Wikitext signature.',
311312 'mwe-upwiz-feedback-cancel' => 'Button label',
312 - 'mwe-upwiz-feedback-cancel' => 'Button label',
 313+ 'mwe-upwiz-feedback-submit' => 'Button label',
313314 'mwe-upwiz-feedback-adding' => 'Progress notice'
314315 );
315316
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizard.js
@@ -1228,22 +1228,29 @@
12291229 dataType: 'json',
12301230 type: 'POST',
12311231 success: function( data ) {
1232 - if ( data.edit.result == "Success" ) {
1233 - $feedbackForm.dialog("close");
 1232+ if ( typeof data.edit != 'undefined' ) {
 1233+ if ( data.edit.result == "Success" ) {
 1234+ $feedbackForm.dialog("close");
 1235+ } else {
 1236+ displayError( 'mwe-upwiz-feedback-error1' );
 1237+ }
12341238 } else {
1235 - $('#mwe-upwiz-feedback-form div').hide(); // remove everything else from the dialog box
1236 - $('#mwe-upwiz-feedback-form').append ( $('<div style="color:#990000;margin-top:0.4em;"></div>').msg( 'mwe-upwiz-feedback-error1' ) );
 1239+ displayError( 'mwe-upwiz-feedback-error2' );
12371240 }
12381241 },
12391242 error: function( xhr ) {
1240 - $('#mwe-upwiz-feedback-form div').hide(); // remove everything else from the dialog box
1241 - $('#mwe-upwiz-feedback-form').append ( $('<div style="color:#990000;margin-top:0.4em;"></div>').msg( 'mwe-upwiz-feedback-error2' ) );
 1243+ displayError( 'mwe-upwiz-feedback-error3' );
12421244 }
12431245 }); // close Ajax request
12441246 }; // close useTokenToPost function
12451247 _this.api.getEditToken( useTokenToPost );
12461248 }; // close submit button function
12471249
 1250+ var displayError = function( message ) {
 1251+ $('#mwe-upwiz-feedback-form div').hide(); // remove everything else from the dialog box
 1252+ $('#mwe-upwiz-feedback-form').append ( $('<div style="color:#990000;margin-top:0.4em;"></div>').msg( message ) );
 1253+ }
 1254+
12481255 // Construct the feedback form
12491256 var feedbackLink = '<a href="'+wgArticlePath.replace( '$1', mw.UploadWizard.config['feedbackPage'].replace( /\s/g, '_' ) )+'" target="_blank">'+mw.UploadWizard.config['feedbackPage']+'</a>';
12501257 $feedbackForm = $('<div id="mwe-upwiz-feedback-form" style="position:relative;"></div>')

Status & tagging log