From cfbabb838331aa4a52de2798f47c16a39f8c8f71 Mon Sep 17 00:00:00 2001 From: Joel Date: Tue, 27 Aug 2024 17:09:34 +0800 Subject: [PATCH] feat: file valid --- .../config-var/config-modal/index.tsx | 15 ++++++++++++++- .../nodes/_base/components/file-type-item.tsx | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/web/app/components/app/configuration/config-var/config-modal/index.tsx b/web/app/components/app/configuration/config-var/config-modal/index.tsx index 36b7fabc56..d4b0cc36f3 100644 --- a/web/app/components/app/configuration/config-var/config-modal/index.tsx +++ b/web/app/components/app/configuration/config-var/config-modal/index.tsx @@ -15,7 +15,7 @@ import { checkKeys, getNewVarInWorkflow } from '@/utils/var' import ConfigContext from '@/context/debug-configuration' import type { InputVar, MoreInfo, UploadFileSetting } from '@/app/components/workflow/types' import Modal from '@/app/components/base/modal' -import { ChangeType, InputVarType } from '@/app/components/workflow/types' +import { ChangeType, InputVarType, SupportUploadFileTypes } from '@/app/components/workflow/types' import FileUploadSetting from '@/app/components/workflow/nodes/_base/components/file-upload-setting' import Checkbox from '@/app/components/base/checkbox' import { DEFAULT_FILE_UPLOAD_SETTING } from '@/app/components/workflow/constants' @@ -151,6 +151,19 @@ const ConfigModal: FC = ({ } onConfirm(tempPayload, moreInfo) } + else if ([InputVarType.singleFile, InputVarType.multiFiles].includes(type)) { + if (tempPayload.allowed_file_types?.length === 0) { + const errorMessages = t('workflow.errorMsg.fieldRequired', { field: t('appDebug.variableConig.file.supportFileTypes') }) + Toast.notify({ type: 'error', message: errorMessages }) + return + } + if (tempPayload.allowed_file_types?.includes(SupportUploadFileTypes.custom) && !tempPayload.allowed_file_extensions?.length) { + const errorMessages = t('workflow.errorMsg.fieldRequired', { field: t('appDebug.variableConig.file.custom.name') }) + Toast.notify({ type: 'error', message: errorMessages }) + return + } + onConfirm(tempPayload, moreInfo) + } else { onConfirm(tempPayload, moreInfo) } diff --git a/web/app/components/workflow/nodes/_base/components/file-type-item.tsx b/web/app/components/workflow/nodes/_base/components/file-type-item.tsx index 2099474e42..e0696435e8 100644 --- a/web/app/components/workflow/nodes/_base/components/file-type-item.tsx +++ b/web/app/components/workflow/nodes/_base/components/file-type-item.tsx @@ -47,7 +47,7 @@ const FileTypeItem: FC = ({
{t(`appDebug.variableConig.file.${type}.name`)}
-
+
e.stopPropagation()}>