From 788731beca726a2a6a89625c1da7cb1ada59b229 Mon Sep 17 00:00:00 2001 From: Ahmad Altaher Alfayad Date: Fri, 26 Apr 2024 14:27:35 -0400 Subject: [PATCH] Add file size too large error for file uploads --- assets/js/Components/FilesModal.js | 7 +++++++ translations/en.json | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/assets/js/Components/FilesModal.js b/assets/js/Components/FilesModal.js index 5043f6db..f34e5888 100644 --- a/assets/js/Components/FilesModal.js +++ b/assets/js/Components/FilesModal.js @@ -249,6 +249,13 @@ class FilesModal extends React.Component { return } + if(file.size > 1024 * 1024 * 10) { + this.addMessage({severity: 'error', message: this.props.t('msg.file.replace.file_size'), timeout: 5000}) + this.setState({ replaceFileObj: null }) + this.forceUpdate() + return + } + this.setState({ replaceFileObj: file }) } diff --git a/translations/en.json b/translations/en.json index 816e1b07..a3c5b4fe 100644 --- a/translations/en.json +++ b/translations/en.json @@ -133,6 +133,7 @@ "msg.sync.started": "Course scan started.", "msg.sync.failed": "Course scan failed. Course is missing.", "msg.file.replace.file_type": "File type not accepted. Please input a file with the correct filetype.", + "msg.file.replace.file_size": "File size too large. Please input a file with a size less than 10MB", "msg.sync.completed": "Course scan completed.", "msg.sync.course_inactive": "Course scan failed. Course is inactive.", @@ -384,4 +385,4 @@ "rule.label.SearchKeyWord": "Keyword found", "rule.desc.SearchKeyWord": "The keyword has been found" -} \ No newline at end of file +}