diff --git a/web/app/components/workflow/nodes/_base/components/variable/utils.ts b/web/app/components/workflow/nodes/_base/components/variable/utils.ts index cb1a170011..2e4ea8a355 100644 --- a/web/app/components/workflow/nodes/_base/components/variable/utils.ts +++ b/web/app/components/workflow/nodes/_base/components/variable/utils.ts @@ -14,7 +14,7 @@ import type { ToolNodeType } from '../../../tool/types' import type { ParameterExtractorNodeType } from '../../../parameter-extractor/types' import type { IterationNodeType } from '../../../iteration/types' import type { ListFilterNodeType } from '../../../list-operator/types' -import { OUTPUT_FILE_SUB_VARIABLES } from '../../../if-else/default' +import { OUTPUT_FILE_SUB_VARIABLES } from '../../../constants' import type { DocExtractorNodeType } from '../../../document-extractor/types' import { BlockEnum, InputVarType, VarType } from '@/app/components/workflow/types' import type { StartNodeType } from '@/app/components/workflow/nodes/start/types' diff --git a/web/app/components/workflow/nodes/constants.ts b/web/app/components/workflow/nodes/constants.ts index dc202acc28..d765b89f86 100644 --- a/web/app/components/workflow/nodes/constants.ts +++ b/web/app/components/workflow/nodes/constants.ts @@ -36,6 +36,7 @@ import ListFilterNode from './list-operator/node' import ListFilterPanel from './list-operator/panel' import AgentNode from './agent/node' import AgentPanel from './agent/panel' +import { TransferMethod } from '@/types/app' export const NodeComponentMap: Record> = { [BlockEnum.Start]: StartNode, @@ -82,3 +83,18 @@ export const PanelComponentMap: Record> = { } export const CUSTOM_NODE_TYPE = 'custom' + +export const FILE_TYPE_OPTIONS = [ + { value: 'image', i18nKey: 'image' }, + { value: 'document', i18nKey: 'doc' }, + { value: 'audio', i18nKey: 'audio' }, + { value: 'video', i18nKey: 'video' }, +] + +export const TRANSFER_METHOD = [ + { value: TransferMethod.local_file, i18nKey: 'localUpload' }, + { value: TransferMethod.remote_url, i18nKey: 'url' }, +] + +export const SUB_VARIABLES = ['type', 'size', 'name', 'url', 'extension', 'mime_type', 'transfer_method'] +export const OUTPUT_FILE_SUB_VARIABLES = SUB_VARIABLES.filter(key => key !== 'transfer_method') diff --git a/web/app/components/workflow/nodes/if-else/components/condition-files-list-value.tsx b/web/app/components/workflow/nodes/if-else/components/condition-files-list-value.tsx index f21a3fac10..b0cfdeaf28 100644 --- a/web/app/components/workflow/nodes/if-else/components/condition-files-list-value.tsx +++ b/web/app/components/workflow/nodes/if-else/components/condition-files-list-value.tsx @@ -9,7 +9,7 @@ import { isComparisonOperatorNeedTranslate, isEmptyRelatedOperator, } from '../utils' -import { FILE_TYPE_OPTIONS, TRANSFER_METHOD } from '../default' +import { FILE_TYPE_OPTIONS, TRANSFER_METHOD } from '../../constants' import type { ValueSelector } from '../../../types' import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development' import { BubbleX, Env } from '@/app/components/base/icons/src/vender/line/others' diff --git a/web/app/components/workflow/nodes/if-else/components/condition-list/condition-item.tsx b/web/app/components/workflow/nodes/if-else/components/condition-list/condition-item.tsx index 2e89c73074..670f766bea 100644 --- a/web/app/components/workflow/nodes/if-else/components/condition-list/condition-item.tsx +++ b/web/app/components/workflow/nodes/if-else/components/condition-list/condition-item.tsx @@ -21,7 +21,7 @@ import { } from '../../types' import { comparisonOperatorNotRequireValue, getOperators } from '../../utils' import ConditionNumberInput from '../condition-number-input' -import { FILE_TYPE_OPTIONS, SUB_VARIABLES, TRANSFER_METHOD } from '../../default' +import { FILE_TYPE_OPTIONS, SUB_VARIABLES, TRANSFER_METHOD } from '../../../constants' import ConditionWrap from '../condition-wrap' import ConditionOperator from './condition-operator' import ConditionInput from './condition-input' @@ -39,7 +39,7 @@ import { SimpleSelect as Select } from '@/app/components/base/select' import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development' const optionNameI18NPrefix = 'workflow.nodes.ifElse.optionName' -interface ConditionItemProps { +type ConditionItemProps = { className?: string disabled?: boolean caseId: string diff --git a/web/app/components/workflow/nodes/if-else/components/condition-value.tsx b/web/app/components/workflow/nodes/if-else/components/condition-value.tsx index 3a71b85a0e..8bfa77acc1 100644 --- a/web/app/components/workflow/nodes/if-else/components/condition-value.tsx +++ b/web/app/components/workflow/nodes/if-else/components/condition-value.tsx @@ -9,7 +9,7 @@ import { comparisonOperatorNotRequireValue, isComparisonOperatorNeedTranslate, } from '../utils' -import { FILE_TYPE_OPTIONS, TRANSFER_METHOD } from '../default' +import { FILE_TYPE_OPTIONS, TRANSFER_METHOD } from '../../constants' import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development' import { BubbleX, Env } from '@/app/components/base/icons/src/vender/line/others' import cn from '@/utils/classnames' @@ -20,7 +20,7 @@ import type { Node, } from '@/app/components/workflow/types' -interface ConditionValueProps { +type ConditionValueProps = { variableSelector: string[] labelName?: string operator: ComparisonOperator diff --git a/web/app/components/workflow/nodes/if-else/components/condition-wrap.tsx b/web/app/components/workflow/nodes/if-else/components/condition-wrap.tsx index 39c03c9b38..a09cb5fa29 100644 --- a/web/app/components/workflow/nodes/if-else/components/condition-wrap.tsx +++ b/web/app/components/workflow/nodes/if-else/components/condition-wrap.tsx @@ -12,7 +12,7 @@ import type { CaseItem, HandleAddCondition, HandleAddSubVariableCondition, Handl import type { Node, NodeOutPutVar, Var } from '../../../types' import { VarType } from '../../../types' import { useGetAvailableVars } from '../../variable-assigner/hooks' -import { SUB_VARIABLES } from '../default' +import { SUB_VARIABLES } from '../../constants' import ConditionList from './condition-list' import ConditionAdd from './condition-add' import cn from '@/utils/classnames' diff --git a/web/app/components/workflow/nodes/if-else/default.ts b/web/app/components/workflow/nodes/if-else/default.ts index 8d98f694bd..1be80592e5 100644 --- a/web/app/components/workflow/nodes/if-else/default.ts +++ b/web/app/components/workflow/nodes/if-else/default.ts @@ -1,7 +1,6 @@ import { BlockEnum, type NodeDefault } from '../../types' import { type IfElseNodeType, LogicalOperator } from './types' import { isEmptyRelatedOperator } from './utils' -import { TransferMethod } from '@/types/app' import { ALL_CHAT_AVAILABLE_BLOCKS, ALL_COMPLETION_AVAILABLE_BLOCKS } from '@/app/components/workflow/blocks' const i18nPrefix = 'workflow.errorMsg' @@ -79,18 +78,3 @@ const nodeDefault: NodeDefault = { } export default nodeDefault - -export const FILE_TYPE_OPTIONS = [ - { value: 'image', i18nKey: 'image' }, - { value: 'document', i18nKey: 'doc' }, - { value: 'audio', i18nKey: 'audio' }, - { value: 'video', i18nKey: 'video' }, -] - -export const TRANSFER_METHOD = [ - { value: TransferMethod.local_file, i18nKey: 'localUpload' }, - { value: TransferMethod.remote_url, i18nKey: 'url' }, -] - -export const SUB_VARIABLES = ['type', 'size', 'name', 'url', 'extension', 'mime_type', 'transfer_method'] -export const OUTPUT_FILE_SUB_VARIABLES = SUB_VARIABLES.filter(key => key !== 'transfer_method') diff --git a/web/app/components/workflow/nodes/list-operator/components/filter-condition.tsx b/web/app/components/workflow/nodes/list-operator/components/filter-condition.tsx index b64f753514..0c261a70d6 100644 --- a/web/app/components/workflow/nodes/list-operator/components/filter-condition.tsx +++ b/web/app/components/workflow/nodes/list-operator/components/filter-condition.tsx @@ -9,7 +9,7 @@ import { ComparisonOperator } from '../../if-else/types' import { comparisonOperatorNotRequireValue, getOperators } from '../../if-else/utils' import SubVariablePicker from './sub-variable-picker' import Input from '@/app/components/base/input' -import { FILE_TYPE_OPTIONS, TRANSFER_METHOD } from '@/app/components/workflow/nodes/if-else/default' +import { FILE_TYPE_OPTIONS, TRANSFER_METHOD } from '@/app/components/workflow/nodes/constants' import { SimpleSelect as Select } from '@/app/components/base/select' const optionNameI18NPrefix = 'workflow.nodes.ifElse.optionName' diff --git a/web/app/components/workflow/nodes/list-operator/components/sub-variable-picker.tsx b/web/app/components/workflow/nodes/list-operator/components/sub-variable-picker.tsx index 0a210504cf..c3a8708603 100644 --- a/web/app/components/workflow/nodes/list-operator/components/sub-variable-picker.tsx +++ b/web/app/components/workflow/nodes/list-operator/components/sub-variable-picker.tsx @@ -2,7 +2,7 @@ import type { FC } from 'react' import React, { useCallback } from 'react' import { useTranslation } from 'react-i18next' -import { SUB_VARIABLES } from '../../if-else/default' +import { SUB_VARIABLES } from '../../constants' import type { Item } from '@/app/components/base/select' import { SimpleSelect as Select } from '@/app/components/base/select' import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development'