From c6039e35361081ebacc32b2f0075f0b20cc33eaf Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Thu, 26 Jan 2023 10:39:39 +0800 Subject: [PATCH] feat(nc-gui): allow all mime types logic --- packages/nc-gui/components/cell/attachment/utils.ts | 3 ++- packages/nc-gui/composables/useMultiSelect/convertCellData.ts | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui/components/cell/attachment/utils.ts b/packages/nc-gui/components/cell/attachment/utils.ts index 9fdc6af4ac..6b202c519c 100644 --- a/packages/nc-gui/components/cell/attachment/utils.ts +++ b/packages/nc-gui/components/cell/attachment/utils.ts @@ -66,7 +66,7 @@ export const [useProvideAttachmentCell, useAttachmentCell] = useInjectionState( maxNumberOfAttachments: Math.max(1, +appInfo.value.ncMaxAttachmentsAllowed || 50) || 50, // Maximum File Size per file maxAttachmentSize: Math.max(1, +appInfo.value.ncMaxAttachmentsAllowed || 20) || 20, - supportedAttachmentMimeTypes: ['application', 'audio', 'image', 'video', 'misc'], + supportedAttachmentMimeTypes: ['*'], }), } @@ -125,6 +125,7 @@ export const [useProvideAttachmentCell, useAttachmentCell] = useInjectionState( // verify mime type if ( + !attachmentMeta.supportedAttachmentMimeTypes.includes('*') && !attachmentMeta.supportedAttachmentMimeTypes.includes(file.type) && !attachmentMeta.supportedAttachmentMimeTypes.includes(file.type.split('/')[0]) ) { diff --git a/packages/nc-gui/composables/useMultiSelect/convertCellData.ts b/packages/nc-gui/composables/useMultiSelect/convertCellData.ts index 23d3f4eea8..5cbc47e694 100644 --- a/packages/nc-gui/composables/useMultiSelect/convertCellData.ts +++ b/packages/nc-gui/composables/useMultiSelect/convertCellData.ts @@ -81,13 +81,14 @@ export default function convertCellData( if (parsedVal.some((v: any) => v && !(v.url || v.data))) { throw new Error('Invalid attachment data') } + // TODO(refactor): duplicate logic in attachment/utils.ts const defaultAttachmentMeta = { ...(args.appInfo.ee && { // Maximum Number of Attachments per cell maxNumberOfAttachments: Math.max(1, +args.appInfo.ncMaxAttachmentsAllowed || 50) || 50, // Maximum File Size per file maxAttachmentSize: Math.max(1, +args.appInfo.ncMaxAttachmentsAllowed || 20) || 20, - supportedAttachmentMimeTypes: ['application', 'audio', 'image', 'video', 'misc'], + supportedAttachmentMimeTypes: ['*'], }), } @@ -118,6 +119,7 @@ export default function convertCellData( // verify mime type if ( + !attachmentMeta.supportedAttachmentMimeTypes.includes('*') && !attachmentMeta.supportedAttachmentMimeTypes.includes(attachment.type) && !attachmentMeta.supportedAttachmentMimeTypes.includes(attachment.type.split('/')[0]) ) {