'dom-level2-shim',
'mediawiki.api.upload',
),
+ 'messages' => array(
+ 'api-error-badaccess-groups',
+ 'api-error-badtoken',
+ 'api-error-copyuploaddisabled',
+ 'api-error-duplicate',
+ 'api-error-duplicate-archive',
+ 'api-error-empty-file',
+ 'api-error-emptypage',
+ 'api-error-fetchfileerror',
+ 'api-error-fileexists-forbidden',
+ 'api-error-fileexists-shared-forbidden',
+ 'api-error-file-too-large',
+ 'api-error-filename-tooshort',
+ 'api-error-filetype-banned',
+ 'api-error-filetype-banned-type',
+ 'api-error-filetype-missing',
+ 'api-error-hookaborted',
+ 'api-error-http',
+ 'api-error-illegal-filename',
+ 'api-error-internal-error',
+ 'api-error-invalid-file-key',
+ 'api-error-missingparam',
+ 'api-error-missingresult',
+ 'api-error-mustbeloggedin',
+ 'api-error-mustbeposted',
+ 'api-error-noimageinfo',
+ 'api-error-nomodule',
+ 'api-error-ok-but-empty',
+ 'api-error-overwrite',
+ 'api-error-stashfailed',
+ 'api-error-publishfailed',
+ 'api-error-stasherror',
+ 'api-error-stashedfilenotfound',
+ 'api-error-stashpathinvalid',
+ 'api-error-stashfilestorage',
+ 'api-error-stashzerolength',
+ 'api-error-stashnotloggedin',
+ 'api-error-stashwrongowner',
+ 'api-error-stashnosuchfilekey',
+ 'api-error-timeout',
+ 'api-error-unclassified',
+ 'api-error-unknown-code',
+ 'api-error-unknown-error',
+ 'api-error-unknown-warning',
+ 'api-error-unknownerror',
+ 'api-error-uploaddisabled',
+ 'api-error-verification-error',
+ ),
),
'mediawiki.ForeignUpload' => array(
'scripts' => 'resources/src/mediawiki/mediawiki.ForeignUpload.js',
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 () {
+ }, function () {
+ // These errors will be thrown while the user is on the info page
if ( layout.upload.getState() === mw.Upload.State.ERROR ) {
- deferred.reject( new OO.ui.Error( mw.msg( 'upload-process-error' ), {
+ deferred.reject( new OO.ui.Error( layout.upload.getStateDetails(), {
recoverable: false
} ) );
return false;
}
if ( layout.upload.getState() === mw.Upload.State.WARNING ) {
- deferred.reject( new OO.ui.Error( mw.msg( 'upload-process-error' ), {
+ deferred.reject( new OO.ui.Error( layout.upload.getStateDetails(), {
recoverable: false
} ) );
return false;
this.comment = '';
this.filename = null;
this.file = null;
- this.state = Upload.State.NEW;
+ this.setState( Upload.State.NEW );
this.imageinfo = undefined;
}
);
};
+ /**
+ * Sets the state and state details (if any) of the upload.
+ */
+ UP.setState = function ( state, stateDetails ) {
+ this.state = state;
+ this.stateDetails = stateDetails;
+ };
+
/**
* Gets the state of the upload.
*
return this.state;
};
+ /**
+ * Gets details of the current state.
+ *
+ * @return {string}
+ */
+ UP.getStateDetails = function () {
+ return this.stateDetails;
+ };
+
/**
* Get the imageinfo object for the finished upload.
* Only available once the upload is finished! Don't try to get it
return $.Deferred().reject( 'No filename set. Call setFilename to add one.' );
}
- this.state = Upload.State.UPLOADING;
+ this.setState( Upload.State.UPLOADING );
return this.api.upload( this.getFile(), {
watchlist: ( this.getWatchlist() ) ? 1 : undefined,
filename: this.getFilename(),
text: this.getText()
} ).then( function ( result ) {
- upload.state = Upload.State.UPLOADED;
+ upload.setState( Upload.State.UPLOADED );
upload.imageinfo = result.upload.imageinfo;
return result;
}, function () {
- upload.state = Upload.State.ERROR;
+ upload.setState( Upload.State.ERROR );
} );
};
this.setFilenameFromFile();
}
- this.state = Upload.State.UPLOADING;
+ this.setState( Upload.State.UPLOADING );
this.stashPromise = this.api.uploadToStash( this.getFile(), {
filename: this.getFilename()
} ).then( function ( finishStash ) {
- upload.state = Upload.State.STASHED;
+ upload.setState( Upload.State.STASHED );
return finishStash;
- }, function () {
- upload.state = Upload.State.ERROR;
+ }, function ( result ) {
+ upload.setState( Upload.State.ERROR, mw.message( 'api-error-' + result ) );
} );
return this.stashPromise;
}
return this.stashPromise.then( function ( finishStash ) {
- upload.state = Upload.State.UPLOADING;
+ upload.setState( Upload.State.UPLOADING );
return finishStash( {
watchlist: ( upload.getWatchlist() ) ? 1 : undefined,
filename: upload.getFilename(),
text: upload.getText()
} ).then( function ( result ) {
- upload.state = Upload.State.UPLOADED;
+ upload.setState( Upload.State.UPLOADED );
upload.imageinfo = result.upload.imageinfo;
return result;
}, function () {
- upload.state = Upload.State.ERROR;
+ upload.setState( Upload.State.ERROR );
} );
} );
};