feat: allow configuring attachment upload limit (#12835)
## Summary - add a configurable MAXIMUM_FILE_UPLOAD_SIZE installation setting and surface it through super admin and global config payloads - apply the configurable limit to attachment validations and shared upload helpers on dashboard and widget - introduce a reusable helper with unit tests for parsing the limit and extend attachment specs for configurability ------ [Codex Task](https://chatgpt.com/codex/tasks/task_e_6912644786b08326bc8dee9401af6d0a) --------- Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Co-authored-by: iamsivin <iamsivin@gmail.com>
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
<script>
|
||||
import FileUpload from 'vue-upload-component';
|
||||
import Spinner from 'shared/components/Spinner.vue';
|
||||
import { checkFileSizeLimit } from 'shared/helpers/FileHelper';
|
||||
import {
|
||||
MAXIMUM_FILE_UPLOAD_SIZE,
|
||||
ALLOWED_FILE_TYPES,
|
||||
} from 'shared/constants/messages';
|
||||
checkFileSizeLimit,
|
||||
resolveMaximumFileUploadSize,
|
||||
} from 'shared/helpers/FileHelper';
|
||||
import { ALLOWED_FILE_TYPES } from 'shared/constants/messages';
|
||||
import { BUS_EVENTS } from 'shared/constants/busEvents';
|
||||
import FluentIcon from 'shared/components/FluentIcon/Index.vue';
|
||||
import { DirectUpload } from 'activestorage';
|
||||
@@ -29,7 +29,9 @@ export default {
|
||||
shouldShowFilePicker: 'appConfig/getShouldShowFilePicker',
|
||||
}),
|
||||
fileUploadSizeLimit() {
|
||||
return MAXIMUM_FILE_UPLOAD_SIZE;
|
||||
return resolveMaximumFileUploadSize(
|
||||
this.globalConfig.maximumFileUploadSize
|
||||
);
|
||||
},
|
||||
allowedFileTypes() {
|
||||
return ALLOWED_FILE_TYPES;
|
||||
@@ -73,7 +75,7 @@ export default {
|
||||
}
|
||||
this.isUploading = true;
|
||||
try {
|
||||
if (checkFileSizeLimit(file, MAXIMUM_FILE_UPLOAD_SIZE)) {
|
||||
if (checkFileSizeLimit(file, this.fileUploadSizeLimit)) {
|
||||
const { websiteToken } = window.chatwootWebChannel;
|
||||
const upload = new DirectUpload(
|
||||
file.file,
|
||||
@@ -115,7 +117,7 @@ export default {
|
||||
}
|
||||
this.isUploading = true;
|
||||
try {
|
||||
if (checkFileSizeLimit(file, MAXIMUM_FILE_UPLOAD_SIZE)) {
|
||||
if (checkFileSizeLimit(file, this.fileUploadSizeLimit)) {
|
||||
await this.onAttach({
|
||||
file: file.file,
|
||||
...this.getLocalFileAttributes(file),
|
||||
|
||||
Reference in New Issue
Block a user