mw.Upload.BookletLayout: Go back to upload page on upload error
authorPrateek Saxena <prtksxna@gmail.com>
Wed, 30 Sep 2015 20:52:49 +0000 (02:22 +0530)
committerPrateek Saxena <prtksxna@gmail.com>
Wed, 30 Sep 2015 20:54:04 +0000 (02:24 +0530)
Bug: T114130
Change-Id: Ibe50ce845a42bb5e66f842c68a35541747c9a570

resources/src/mediawiki/mediawiki.Upload.BookletLayout.js

index fa2fb0b..d75e1d3 100644 (file)
                this.setPage( 'info' );
 
                this.upload.setFile( file );
+               // Explicitly set the filename so that the old filename isn't used in case of retry
+               this.upload.setFilenameFromFile();
+
                this.uploadPromise = this.upload.uploadToStash();
                this.uploadPromise.then( function () {
                        deferred.resolve();
                        layout.emit( 'fileUploaded' );
                } );
+
+               // These errors will be thrown while the user is on the info page
                this.uploadPromise.always( function () {
                        if ( layout.upload.getState() === mw.Upload.State.ERROR ) {
                                deferred.reject( new OO.ui.Error( mw.msg( 'upload-process-error' )  ) );
                        }
                } );
 
+               // If there is an error in uploading, come back to the upload page
+               deferred.fail( function () {
+                       layout.setPage( 'upload' );
+               } );
+
                return deferred;
        };