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 c6cb580118..bcbaf2be69 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 @@ -26,6 +26,7 @@ type ConditionItemProps = { disabled?: boolean caseId: string condition: Condition + file?: { key: string } onRemoveCondition: HandleRemoveCondition onUpdateCondition: HandleUpdateCondition nodesOutputVars: NodeOutPutVar[] @@ -36,6 +37,7 @@ const ConditionItem = ({ disabled, caseId, condition, + file, onRemoveCondition, onUpdateCondition, nodesOutputVars, @@ -88,6 +90,7 @@ const ConditionItem = ({ varType={condition.varType} value={condition.comparison_operator} onSelect={handleUpdateConditionOperator} + file={file} /> { diff --git a/web/app/components/workflow/nodes/if-else/components/condition-list/condition-operator.tsx b/web/app/components/workflow/nodes/if-else/components/condition-list/condition-operator.tsx index 3ae1a93b0a..93a4c3cc08 100644 --- a/web/app/components/workflow/nodes/if-else/components/condition-list/condition-operator.tsx +++ b/web/app/components/workflow/nodes/if-else/components/condition-list/condition-operator.tsx @@ -19,12 +19,14 @@ const i18nPrefix = 'workflow.nodes.ifElse' type ConditionOperatorProps = { disabled?: boolean varType: VarType + file?: { key: string } value?: string onSelect: (value: ComparisonOperator) => void } const ConditionOperator = ({ disabled, varType, + file, value, onSelect, }: ConditionOperatorProps) => { @@ -32,13 +34,13 @@ const ConditionOperator = ({ const [open, setOpen] = useState(false) const options = useMemo(() => { - return getOperators(varType).map((o) => { + return getOperators(varType, file).map((o) => { return { label: isComparisonOperatorNeedTranslate(o) ? t(`${i18nPrefix}.comparisonOperator.${o}`) : o, value: o, } }) - }, [t, varType]) + }, [t, varType, file]) const selectedOption = options.find(o => o.value === value) return ( diff --git a/web/app/components/workflow/nodes/if-else/components/condition-list/index.tsx b/web/app/components/workflow/nodes/if-else/components/condition-list/index.tsx index b97b0a05ac..721f19de56 100644 --- a/web/app/components/workflow/nodes/if-else/components/condition-list/index.tsx +++ b/web/app/components/workflow/nodes/if-else/components/condition-list/index.tsx @@ -21,6 +21,7 @@ type ConditionListProps = { nodesOutputVars: NodeOutPutVar[] availableNodes: Node[] numberVariables: NodeOutPutVar[] + varsIsVarFileAttribute: Record } const ConditionList = ({ disabled, @@ -31,6 +32,7 @@ const ConditionList = ({ nodesOutputVars, availableNodes, numberVariables, + varsIsVarFileAttribute, }: ConditionListProps) => { const { conditions, logical_operator } = caseItem @@ -65,6 +67,7 @@ const ConditionList = ({ nodesOutputVars={nodesOutputVars} availableNodes={availableNodes} numberVariables={numberVariables} + file={varsIsVarFileAttribute[condition.id] ? { key: condition.variable_selector.slice(-1)[0] } : undefined} /> )) } diff --git a/web/app/components/workflow/nodes/if-else/panel.tsx b/web/app/components/workflow/nodes/if-else/panel.tsx index b3e7f7dfc5..111219118d 100644 --- a/web/app/components/workflow/nodes/if-else/panel.tsx +++ b/web/app/components/workflow/nodes/if-else/panel.tsx @@ -41,6 +41,7 @@ const Panel: FC> = ({ handleUpdateConditionLogicalOperator, nodesOutputVars, availableNodes, + varsIsVarFileAttribute, } = useConfig(id, data) const [willDeleteCaseId, setWillDeleteCaseId] = useState('') const cases = inputs.cases || [] @@ -93,6 +94,7 @@ const Panel: FC> = ({ nodesOutputVars={nodesOutputVars} availableNodes={availableNodes} numberVariables={getAvailableVars(id, '', filterNumberVar)} + varsIsVarFileAttribute={varsIsVarFileAttribute} /> ) diff --git a/web/app/components/workflow/nodes/if-else/use-config.ts b/web/app/components/workflow/nodes/if-else/use-config.ts index 55362bab3b..1ce1a73bb2 100644 --- a/web/app/components/workflow/nodes/if-else/use-config.ts +++ b/web/app/components/workflow/nodes/if-else/use-config.ts @@ -190,6 +190,7 @@ const useConfig = (id: string, payload: IfElseNodeType) => { availableNodes: availableNodesWithParent, nodesOutputNumberVars: availableNumberVars, availableNumberNodes: availableNumberNodesWithParent, + varsIsVarFileAttribute, } } diff --git a/web/app/components/workflow/nodes/if-else/utils.ts b/web/app/components/workflow/nodes/if-else/utils.ts index f034761ca0..114368290f 100644 --- a/web/app/components/workflow/nodes/if-else/utils.ts +++ b/web/app/components/workflow/nodes/if-else/utils.ts @@ -40,6 +40,47 @@ export const getOperators = (type?: VarType, file?: { key: string }) => { ComparisonOperator.in, ComparisonOperator.notIn, ] + case 'size': + return [ + ComparisonOperator.largerThan, + ComparisonOperator.largerThanOrEqual, + ComparisonOperator.lessThan, + ComparisonOperator.lessThanOrEqual, + ] + case 'extension': + return [ + ComparisonOperator.is, + ComparisonOperator.isNot, + ComparisonOperator.contains, + ComparisonOperator.notContains, + ] + case 'mimetype': + return [ + ComparisonOperator.contains, + ComparisonOperator.notContains, + ComparisonOperator.startWith, + ComparisonOperator.endWith, + ComparisonOperator.is, + ComparisonOperator.isNot, + ComparisonOperator.empty, + ComparisonOperator.notEmpty, + ] + case 'transfer_method': + return [ + ComparisonOperator.in, + ComparisonOperator.notIn, + ] + case 'url': + return [ + ComparisonOperator.contains, + ComparisonOperator.notContains, + ComparisonOperator.startWith, + ComparisonOperator.endWith, + ComparisonOperator.is, + ComparisonOperator.isNot, + ComparisonOperator.empty, + ComparisonOperator.notEmpty, + ] } } switch (type) { diff --git a/web/i18n/en-US/workflow.ts b/web/i18n/en-US/workflow.ts index b510b5f889..e455b4d37d 100644 --- a/web/i18n/en-US/workflow.ts +++ b/web/i18n/en-US/workflow.ts @@ -387,6 +387,8 @@ const translation = { 'not empty': 'is not empty', 'null': 'is null', 'not null': 'is not null', + 'in': 'in', + 'not in': 'not in', }, enterValue: 'Enter value', addCondition: 'Add Condition', diff --git a/web/i18n/zh-Hans/workflow.ts b/web/i18n/zh-Hans/workflow.ts index db496a03ea..9d88332efc 100644 --- a/web/i18n/zh-Hans/workflow.ts +++ b/web/i18n/zh-Hans/workflow.ts @@ -387,6 +387,8 @@ const translation = { 'not empty': '不为空', 'null': '空', 'not null': '不为空', + 'in': '在', + 'not in': '不在', }, enterValue: '输入值', addCondition: '添加条件',