build: Replace jscs+jshint with eslint
[lhc/web/wiklou.git] / resources / src / mediawiki / mediawiki.feedback.js
index 8a3784c..6abdf83 100644 (file)
@@ -6,8 +6,6 @@
  * @author Moriel Schottlender, 2015
  * @since 1.19
  */
-/*jshint esversion:5 */
-/*global OO*/
 ( function ( mw, $ ) {
        /**
         * This is a way of getting simple feedback from users. It's useful
@@ -41,7 +39,7 @@
         * @cfg {string} [apiUrl] api.php URL if the feedback page is on another wiki
         * @cfg {string} [dialogTitleMessageKey="feedback-dialog-title"] Message key for the
         *  title of the dialog box
-        * @cfg {mw.Uri|string} [bugsLink="//phabricator.wikimedia.org/maniphest/task/create/"] URL where
+        * @cfg {mw.Uri|string} [bugsLink="//phabricator.wikimedia.org/maniphest/task/edit/form/1/"] URL where
         *  bugs can be posted
         * @cfg {mw.Uri|string} [bugsListLink="//phabricator.wikimedia.org/maniphest/query/advanced"] URL
         *  where bugs can be listed
@@ -61,7 +59,7 @@
                this.messagePosterPromise = mw.messagePoster.factory.create( this.feedbackPageTitle, config.apiUrl );
 
                // Links
-               this.bugsTaskSubmissionLink = config.bugsLink || '//phabricator.wikimedia.org/maniphest/task/create/';
+               this.bugsTaskSubmissionLink = config.bugsLink || '//phabricator.wikimedia.org/maniphest/task/edit/form/1/';
                this.bugsTaskListLink = config.bugsListLink || '//phabricator.wikimedia.org/maniphest/query/advanced';
 
                // Terms of use
                                        ]
                                };
                                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
                {
                        action: 'submit',
                        label: mw.msg( 'feedback-submit' ),
-                       flags: [ 'primary', 'constructive' ]
+                       flags: [ 'primary', 'progressive' ]
                },
                {
                        action: 'external',
                        label: mw.msg( 'feedback-external-bug-report-button' ),
-                       flags: 'constructive'
+                       flags: 'progressive'
                },
                {
                        action: 'cancel',
                                this.feedbackSubjectInput.getValue()
                        );
 
-               this.actions.setAbilities( { submit:  isValid } );
+               this.actions.setAbilities( { submit: isValid } );
        };
 
        /**
                                }, 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 );
                }
                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
         *
                                if ( secondaryCode === 'http' ) {
                                        fb.status = 'error3';
                                        // ajax request failed
-                                       mw.log.warn( 'Feedback report failed with HTTP error: ' +  details.textStatus );
+                                       mw.log.warn( 'Feedback report failed with HTTP error: ' + details.textStatus );
                                } else {
                                        fb.status = 'error2';
-                                       mw.log.warn( 'Feedback report failed with API error: ' +  secondaryCode );
+                                       mw.log.warn( 'Feedback report failed with API error: ' + secondaryCode );
                                }
                        } else {
                                fb.status = 'error1';