From 8cffbc6b2a63f6801e190333b9df86fdbf3f3fde Mon Sep 17 00:00:00 2001 From: Joel Date: Thu, 21 Mar 2024 16:23:47 +0800 Subject: [PATCH] chore: more info to workflows --- .../config-var/config-modal/index.tsx | 14 ++------------ .../workflow/nodes/start/components/var-item.tsx | 3 +-- .../workflow/nodes/start/components/var-list.tsx | 3 +-- web/app/components/workflow/nodes/start/panel.tsx | 2 +- .../components/workflow/nodes/start/use-config.ts | 5 ++--- web/app/components/workflow/types.ts | 12 ++++++++++++ 6 files changed, 19 insertions(+), 20 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 649e598b21..e147a3f26c 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 @@ -11,22 +11,12 @@ import Field from './field' import Toast from '@/app/components/base/toast' import { getNewVarInWorkflow } from '@/utils/var' import ConfigContext from '@/context/debug-configuration' -import { type InputVar, InputVarType } from '@/app/components/workflow/types' +import type { InputVar, MoreInfo } from '@/app/components/workflow/types' import Modal from '@/app/components/base/modal' import Switch from '@/app/components/base/switch' +import { ChangeType, InputVarType } from '@/app/components/workflow/types' -export enum ChangeType { - changeVarName = 'changeVarName', -} - -export type MoreInfo = { - type: ChangeType - payload?: { - beforeKey: string - afterKey: string - } -} export type IConfigModalProps = { isCreate?: boolean payload?: InputVar 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 af2e74bba6..da30bc4b30 100644 --- a/web/app/components/workflow/nodes/start/components/var-item.tsx +++ b/web/app/components/workflow/nodes/start/components/var-item.tsx @@ -4,11 +4,10 @@ import React, { useCallback, useRef } from 'react' import { useBoolean, useHover } from 'ahooks' import { useTranslation } from 'react-i18next' import InputVarTypeIcon from '../../_base/components/input-var-type-icon' -import type { InputVar } from '@/app/components/workflow/types' +import type { InputVar, MoreInfo } from '@/app/components/workflow/types' import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development' import { Edit03 } from '@/app/components/base/icons/src/vender/solid/general' import { Trash03 } from '@/app/components/base/icons/src/vender/line/general' -import type { MoreInfo } from '@/app/components/app/configuration/config-var/config-modal' import ConfigVarModal from '@/app/components/app/configuration/config-var/config-modal' type Props = { diff --git a/web/app/components/workflow/nodes/start/components/var-list.tsx b/web/app/components/workflow/nodes/start/components/var-list.tsx index be33b0bbae..a0a47caa66 100644 --- a/web/app/components/workflow/nodes/start/components/var-list.tsx +++ b/web/app/components/workflow/nodes/start/components/var-list.tsx @@ -4,8 +4,7 @@ import React, { useCallback } from 'react' import produce from 'immer' import { useTranslation } from 'react-i18next' import VarItem from './var-item' -import type { InputVar } from '@/app/components/workflow/types' -import type { MoreInfo } from '@/app/components/app/configuration/config-var/config-modal' +import type { InputVar, MoreInfo } from '@/app/components/workflow/types' type Props = { readonly: boolean list: InputVar[] diff --git a/web/app/components/workflow/nodes/start/panel.tsx b/web/app/components/workflow/nodes/start/panel.tsx index 4d890b52d1..e55c621b24 100644 --- a/web/app/components/workflow/nodes/start/panel.tsx +++ b/web/app/components/workflow/nodes/start/panel.tsx @@ -8,7 +8,7 @@ import Split from '@/app/components/workflow/nodes/_base/components/split' import Field from '@/app/components/workflow/nodes/_base/components/field' import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/components/output-vars' import AddButton from '@/app/components/base/button/add-button' -import ConfigVarModal from '@/app/components/app/configuration/config-var/config-modal' +import ConfigVarModal from '@/app/components/workflow/types' import type { InputVar, NodePanelProps } from '@/app/components/workflow/types' const i18nPrefix = 'workflow.nodes.start' diff --git a/web/app/components/workflow/nodes/start/use-config.ts b/web/app/components/workflow/nodes/start/use-config.ts index b118906127..289e89c268 100644 --- a/web/app/components/workflow/nodes/start/use-config.ts +++ b/web/app/components/workflow/nodes/start/use-config.ts @@ -2,14 +2,13 @@ import { useCallback } from 'react' import produce from 'immer' import { useBoolean } from 'ahooks' import type { StartNodeType } from './types' -import type { InputVar } from '@/app/components/workflow/types' +import type { InputVar, MoreInfo } from '@/app/components/workflow/types' import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud' import { useIsChatMode, useNodesReadOnly, useWorkflow, } from '@/app/components/workflow/hooks' -import type { MoreInfo } from '@/app/components/app/configuration/config-var/config-modal' const useConfig = (id: string, payload: StartNodeType) => { const { nodesReadOnly: readOnly } = useNodesReadOnly() @@ -32,7 +31,7 @@ const useConfig = (id: string, payload: StartNodeType) => { const changedVar = newList[moreInfo.index] handleOutVarRenameChange(id, [id, inputs.variables[moreInfo.index].variable], [id, changedVar.variable]) } - }, [inputs, setInputs]) + }, [handleOutVarRenameChange, id, inputs, setInputs]) const handleAddVariable = useCallback((payload: InputVar) => { const newInputs = produce(inputs, (draft: StartNodeType) => { diff --git a/web/app/components/workflow/types.ts b/web/app/components/workflow/types.ts index 36c7f99361..b5e2ba5531 100644 --- a/web/app/components/workflow/types.ts +++ b/web/app/components/workflow/types.ts @@ -251,3 +251,15 @@ export type HistoryWorkflowData = { status: string conversation_id?: string } + +export enum ChangeType { + changeVarName = 'changeVarName', +} + +export type MoreInfo = { + type: ChangeType + payload?: { + beforeKey: string + afterKey: string + } +}