uploads: Remove unusable UI elements if file uploading is disabled.

If MAX_FILE_UPLOAD_SIZE is set to 0, then UI elements like the upload
icon in the compose and message edit UI and "Attachments" menu in
"/#settings" are not displayed.
A different error message is also displayed if a user tries to drag and
drop or paste a file into the compose message box.

Fixes #12152.
This commit is contained in:
vinitS101
2019-05-04 23:54:36 +05:30
committed by Tim Abbott
parent ececf0a209
commit 18a424be79
8 changed files with 37 additions and 8 deletions

View File

@@ -101,12 +101,18 @@ exports.options = function (config) {
msg = i18n.t("Unable to upload that many files at once.");
break;
case 'FileTooLarge':
// sanitization not needed as the file name is not potentially parsed as HTML, etc.
var context = {
file_name: file.name,
file_size: page_params.max_file_upload_size,
};
msg = i18n.t('"__file_name__" was too large; the maximum file size is __file_size__MB.', context);
if (page_params.max_file_upload_size > 0) {
// sanitization not needed as the file name is not potentially parsed as HTML, etc.
var context = {
file_name: file.name,
file_size: page_params.max_file_upload_size,
};
msg = i18n.t('"__file_name__" was too large; the maximum file size is __file_size__MB.',
context);
} else {
// If uploading files has been disabled.
msg = i18n.t('File and image uploads have been disabled for this organization.');
}
break;
case 413: // HTTP status "Request Entity Too Large"
msg = i18n.t("Sorry, the file was too large.");