Also, localise the error messages.
Bug: T119314
Change-Id: I0b2f53b91454f22e2001462397087da9e055b701
"upload-too-many-redirects": "The URL contained too many redirects",
"upload-http-error": "An HTTP error occurred: $1",
"upload-copy-upload-invalid-domain": "Copy uploads are not available from this domain.",
+ "upload-foreign-cant-upload": "This wiki is not configured to upload files to the requested foreign file repository.",
"upload-dialog-title": "Upload file",
"upload-dialog-button-cancel": "Cancel",
"upload-dialog-button-done": "Done",
"upload-too-many-redirects": "Error message shown when uploading a file via URL, if the upload failed because the URL returned too many redirects.",
"upload-http-error": "Parameters:\n* $1 - error message",
"upload-copy-upload-invalid-domain": "Error message shown if a user is trying to upload (i.e. copy) a file from a website that is not in $wgCopyUploadsDomains (if set).\n\nSee also:\n* {{msg-mw|http-invalid-url}}\n* {{msg-mw|tmp-create-error}}\n* {{msg-mw|tmp-write-error}}",
+ "upload-foreign-cant-upload": "Error message shown when a user is trying to upload a file to foreign repository that is not configured to receive file uploads from current wiki.",
"upload-dialog-title": "Title of the upload dialog box\n{{Identical|Upload file}}",
"upload-dialog-button-cancel": "Button to cancel the dialog\n{{Identical|Cancel}}",
"upload-dialog-button-done": "Button to close the dialog once upload is complete\n{{Identical|Done}}",
'mediawiki.Upload',
'oojs',
),
+ 'messages' => array(
+ 'uploaddisabledtext',
+ 'upload-foreign-cant-upload',
+ )
),
'mediawiki.ForeignStructuredUpload' => array(
'scripts' => 'resources/src/mediawiki/mediawiki.ForeignStructuredUpload.js',
// Can't reuse the same object, CategorySelector calls #abort on its mw.Api instance
this.categoriesWidget.api = new mw.ForeignApi( api.apiUrl );
}
+ }.bind( this ) ).always( function () {
deferred.resolve();
- }.bind( this ) );
+ } );
}.bind( this ) );
return deferred.promise();
};
if ( this.target === 'local' ) {
// If local uploads were requested, but they are disabled, fail.
if ( !mw.config.get( 'wgEnableUploads' ) ) {
- throw new Error( 'Local uploads are disabled' );
+ this.apiPromise = $.Deferred().reject( 'uploaddisabledtext' );
+ } else {
+ // We'll ignore the CORS and centralauth stuff if the target is
+ // the local wiki.
+ this.apiPromise = $.Deferred().resolve( new mw.Api( apiconfig ) );
}
- // We'll ignore the CORS and centralauth stuff if the target is
- // the local wiki.
- this.apiPromise = $.Deferred().resolve( new mw.Api( apiconfig ) );
} else {
api = new mw.Api();
this.apiPromise = api.get( {
}
}
- throw new Error( 'Can not upload to requested foreign repo' );
+ return $.Deferred().reject( 'upload-foreign-cant-upload' );
} );
}
} ).always( function () {
deferred.resolve();
} );
+ } ).fail( function ( errorMsg ) {
+ booklet.getPage( 'upload' ).$element.msg( errorMsg );
+ deferred.resolve();
} );
return deferred.promise();