From 0480bb03c39ae2d17902d5612e002caf28d79ef2 Mon Sep 17 00:00:00 2001 From: Joel Date: Fri, 2 Aug 2024 11:42:48 +0800 Subject: [PATCH] feat: new input types --- .../config-var/config-modal/index.tsx | 16 +++++++--------- .../config-var/select-type-item/index.tsx | 2 +- .../config-var/select-type-item/style.module.css | 2 +- .../_base/components/input-var-type-icon.tsx | 15 ++++++++------- .../workflow/nodes/start/components/var-item.tsx | 1 + .../components/workflow/nodes/start/panel.tsx | 1 + web/app/components/workflow/types.ts | 2 ++ web/i18n/en-US/app-debug.ts | 2 ++ web/i18n/zh-Hans/app-debug.ts | 2 ++ 9 files changed, 25 insertions(+), 18 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 20fcf49de1..6a910ee4db 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 @@ -25,6 +25,7 @@ export type IConfigModalProps = { varKeys?: string[] onClose: () => void onConfirm: (newValue: InputVar, moreInfo?: MoreInfo) => void + supportFile?: boolean } const inputClassName = 'w-full px-3 text-sm leading-9 text-gray-900 border-0 rounded-lg grow h-9 bg-gray-100 focus:outline-none focus:ring-1 focus:ring-inset focus:ring-gray-200' @@ -35,6 +36,7 @@ const ConfigModal: FC = ({ isShow, onClose, onConfirm, + supportFile, }) => { const { modelConfig } = useContext(ConfigContext) const { t } = useTranslation() @@ -88,14 +90,6 @@ const ConfigModal: FC = ({ Toast.notify({ type: 'error', message: t('appDebug.variableConig.errorMsg.varNameRequired') }) return } - // TODO: check if key already exists. should the consider the edit case - // if (varKeys.map(key => key?.trim()).includes(tempPayload.variable.trim())) { - // Toast.notify({ - // type: 'error', - // message: t('appDebug.varKeyError.keyAlreadyExists', { key: tempPayload.variable }), - // }) - // return - // } if (!tempPayload.label) { Toast.notify({ type: 'error', message: t('appDebug.variableConig.errorMsg.labelNameRequired') }) @@ -136,11 +130,15 @@ const ConfigModal: FC = ({
-
+
handlePayloadChange('type')(InputVarType.textInput)} /> handlePayloadChange('type')(InputVarType.paragraph)} /> handlePayloadChange('type')(InputVarType.select)} /> handlePayloadChange('type')(InputVarType.number)} /> + {supportFile && <> + handlePayloadChange('type')(InputVarType.singleFile)} /> + handlePayloadChange('type')(InputVarType.multiFiles)} /> + }
diff --git a/web/app/components/app/configuration/config-var/select-type-item/index.tsx b/web/app/components/app/configuration/config-var/select-type-item/index.tsx index bb5e700d11..21567a5123 100644 --- a/web/app/components/app/configuration/config-var/select-type-item/index.tsx +++ b/web/app/components/app/configuration/config-var/select-type-item/index.tsx @@ -22,7 +22,7 @@ const SelectTypeItem: FC = ({ return (
diff --git a/web/app/components/app/configuration/config-var/select-type-item/style.module.css b/web/app/components/app/configuration/config-var/select-type-item/style.module.css index 8ff716d58b..5007ed7fed 100644 --- a/web/app/components/app/configuration/config-var/select-type-item/style.module.css +++ b/web/app/components/app/configuration/config-var/select-type-item/style.module.css @@ -4,7 +4,7 @@ justify-content: center; align-items: center; height: 58px; - width: 98px; + /* width: 98px; */ border-radius: 8px; border: 1px solid #EAECF0; box-shadow: 0px 1px 2px rgba(16, 24, 40, 0.05); diff --git a/web/app/components/workflow/nodes/_base/components/input-var-type-icon.tsx b/web/app/components/workflow/nodes/_base/components/input-var-type-icon.tsx index 22c406866f..d3cc1dbc78 100644 --- a/web/app/components/workflow/nodes/_base/components/input-var-type-icon.tsx +++ b/web/app/components/workflow/nodes/_base/components/input-var-type-icon.tsx @@ -1,9 +1,8 @@ 'use client' import type { FC } from 'react' import React from 'react' +import { RiAlignLeft, RiCheckboxMultipleLine, RiFileCopy2Line, RiFileList2Line, RiHashtag, RiTextSnippet } from '@remixicon/react' import { InputVarType } from '../../../types' -import { AlignLeft, LetterSpacing01 } from '@/app/components/base/icons/src/vender/line/editor' -import { CheckDone01, Hash02 } from '@/app/components/base/icons/src/vender/line/general' type Props = { className?: string @@ -12,11 +11,13 @@ type Props = { const getIcon = (type: InputVarType) => { return ({ - [InputVarType.textInput]: LetterSpacing01, - [InputVarType.paragraph]: AlignLeft, - [InputVarType.select]: CheckDone01, - [InputVarType.number]: Hash02, - } as any)[type] || LetterSpacing01 + [InputVarType.textInput]: RiTextSnippet, + [InputVarType.paragraph]: RiAlignLeft, + [InputVarType.select]: RiCheckboxMultipleLine, + [InputVarType.number]: RiHashtag, + [InputVarType.singleFile]: RiFileList2Line, + [InputVarType.multiFiles]: RiFileCopy2Line, + } as any)[type] || RiTextSnippet } const InputVarTypeIcon: FC = ({ diff --git a/web/app/components/workflow/nodes/start/components/var-item.tsx b/web/app/components/workflow/nodes/start/components/var-item.tsx index efbf0c44fd..e2b5ad28c1 100644 --- a/web/app/components/workflow/nodes/start/components/var-item.tsx +++ b/web/app/components/workflow/nodes/start/components/var-item.tsx @@ -79,6 +79,7 @@ const VarItem: FC = ({ isShowEditVarModal && ( > = ({ {isShowAddVarModal && (