From: Prateek Saxena Date: Wed, 30 Sep 2015 20:52:49 +0000 (+0530) Subject: mw.Upload.BookletLayout: Go back to upload page on upload error X-Git-Tag: 1.31.0-rc.0~9628^2 X-Git-Url: http://git.cyclocoop.org/fichier?a=commitdiff_plain;h=dddb0064a9fe611add55877d8a8089a660af0811;p=lhc%2Fweb%2Fwiklou.git mw.Upload.BookletLayout: Go back to upload page on upload error Bug: T114130 Change-Id: Ibe50ce845a42bb5e66f842c68a35541747c9a570 --- diff --git a/resources/src/mediawiki/mediawiki.Upload.BookletLayout.js b/resources/src/mediawiki/mediawiki.Upload.BookletLayout.js index fa2fb0b831..d75e1d3474 100644 --- a/resources/src/mediawiki/mediawiki.Upload.BookletLayout.js +++ b/resources/src/mediawiki/mediawiki.Upload.BookletLayout.js @@ -183,11 +183,16 @@ 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' ) ) ); @@ -199,6 +204,11 @@ } } ); + // If there is an error in uploading, come back to the upload page + deferred.fail( function () { + layout.setPage( 'upload' ); + } ); + return deferred; };