From: Bartosz DziewoƄski Date: Fri, 30 Sep 2016 19:38:26 +0000 (+0200) Subject: mw.feedback: Use standard OOjs UI dialog error handling X-Git-Tag: 1.31.0-rc.0~5239^2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=7196fafcdcbe658caf9ffde508717714b9cf4510 mw.feedback: Use standard OOjs UI dialog error handling Previously, we'd close the original dialog on failure and display a new one, which had the unfortunate effect of losing the user's input (which presumably was not saved due to the failure). Bug: T147056 Change-Id: I8893658807f6a584d6db0a84bc508d87ef508c7e --- diff --git a/languages/i18n/en.json b/languages/i18n/en.json index cbe755de47..d88cefa791 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -3907,7 +3907,6 @@ "feedback-external-bug-report-button": "File a technical task", "feedback-dialog-title": "Submit feedback", "feedback-dialog-intro": "You can use the easy form below to submit your feedback. Your comment will be added to the page \"$1\", along with your username.", - "feedback-error-title": "Error", "feedback-error1": "Error: Unrecognized result from API", "feedback-error2": "Error: Edit failed", "feedback-error3": "Error: No response from API", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 915f629349..610ebea98a 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -4091,7 +4091,6 @@ "feedback-external-bug-report-button": "A button for submitting an external technical bug report.", "feedback-dialog-title": "Title of the feedback dialog", "feedback-dialog-intro": "An introduction at the top of the feedback dialog. $1 - Feedback page link", - "feedback-error-title": "{{Identical|Error}}", "feedback-error1": "Error message, appears when an unknown error occurs submitting feedback", "feedback-error2": "Error message, appears when we could not add feedback", "feedback-error3": "Error message, appears when we lose our connection to the wiki", diff --git a/resources/Resources.php b/resources/Resources.php index b81fbde4bb..32a754fd5d 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -1020,7 +1020,6 @@ return [ 'feedback-cancel', 'feedback-close', 'feedback-dialog-title', - 'feedback-error-title', 'feedback-error1', 'feedback-error2', 'feedback-error3', diff --git a/resources/src/mediawiki/mediawiki.feedback.js b/resources/src/mediawiki/mediawiki.feedback.js index 170e1240c8..989e6db603 100644 --- a/resources/src/mediawiki/mediawiki.feedback.js +++ b/resources/src/mediawiki/mediawiki.feedback.js @@ -116,22 +116,6 @@ ] }; break; - case 'error1': - case 'error2': - case 'error3': - case 'error4': - dialogConfig = { - title: mw.msg( 'feedback-error-title' ), - message: mw.msg( 'feedback-' + status ), - actions: [ - { - action: 'accept', - label: mw.msg( 'feedback-close' ), - flags: 'primary' - } - ] - }; - break; } // Show the message dialog @@ -422,8 +406,10 @@ }, function () { fb.status = 'error4'; mw.log.warn( 'Feedback report failed because MessagePoster could not be fetched' ); - } ).always( function () { + } ).then( function () { fb.close(); + }, function () { + return fb.getErrorMessage(); } ); }, this ); } @@ -431,6 +417,24 @@ return mw.Feedback.Dialog.parent.prototype.getActionProcess.call( this, action ); }; + /** + * Returns an error message for the current status. + * + * @private + * + * @return {OO.ui.Error} + */ + mw.Feedback.Dialog.prototype.getErrorMessage = function () { + switch ( this.status ) { + case 'error1': + case 'error2': + case 'error3': + case 'error4': + // Messages: feedback-error1, feedback-error2, feedback-error3, feedback-error4 + return new OO.ui.Error( mw.msg( 'feedback-' + this.status ) ); + } + }; + /** * Posts the message *