mw.Upload.BookletLayout: Fail when unable to load config from foreign wiki
[lhc/web/wiklou.git] / resources / src / mediawiki / mediawiki.Upload.BookletLayout.js
index 2b28cb4..bbd0f1b 100644 (file)
 
                return this.upload.getApi().then(
                        function ( api ) {
-                               // If the user can't upload anything, don't give them the option to.
-                               return api.getUserInfo().then(
-                                       function ( userInfo ) {
+                               return $.when(
+                                       booklet.upload.loadConfig().then(
+                                               null,
+                                               function ( errorMsg ) {
+                                                       booklet.getPage( 'upload' ).$element.msg( errorMsg );
+                                                       return $.Deferred().resolve();
+                                               }
+                                       ),
+                                       // If the user can't upload anything, don't give them the option to.
+                                       api.getUserInfo().then( function ( userInfo ) {
                                                if ( userInfo.rights.indexOf( 'upload' ) === -1 ) {
                                                        // TODO Use a better error message when not all logged-in users can upload
                                                        booklet.getPage( 'upload' ).$element.msg( 'api-error-mustbeloggedin' );
                                                }
                                                return $.Deferred().resolve();
-                                       },
-                                       function () {
-                                               return $.Deferred().resolve();
-                                       }
+                                       } )
+                               ).then(
+                                       null,
+                                       // Always resolve, never reject
+                                       function () { return $.Deferred().resolve(); }
                                );
                        },
                        function ( errorMsg ) {