diff --git a/web/app/components/workflow/nodes/_base/components/variable-tag.tsx b/web/app/components/workflow/nodes/_base/components/variable-tag.tsx index 6e1b1ed143..fc8c1ce9c9 100644 --- a/web/app/components/workflow/nodes/_base/components/variable-tag.tsx +++ b/web/app/components/workflow/nodes/_base/components/variable-tag.tsx @@ -72,7 +72,7 @@ const VariableTag = ({ {isEnv && } {isChatVar && }
{variableName} diff --git a/web/app/components/workflow/nodes/_base/components/variable/var-reference-vars.tsx b/web/app/components/workflow/nodes/_base/components/variable/var-reference-vars.tsx index 9c2cba6e41..eb28279c0c 100644 --- a/web/app/components/workflow/nodes/_base/components/variable/var-reference-vars.tsx +++ b/web/app/components/workflow/nodes/_base/components/variable/var-reference-vars.tsx @@ -274,7 +274,7 @@ const VarReferenceVars: FC = ({ { !hideSearch && ( <> -
e.stopPropagation()}> +
e.stopPropagation()}> { if (isSubVariableKey) @@ -190,6 +193,17 @@ const ConditionItem = ({ onRemoveCondition?.(caseId, condition.id) }, [caseId, condition, conditionId, isSubVariableKey, onRemoveCondition, onRemoveSubVariableCondition]) + const handleVarChange = useCallback((valueSelector: ValueSelector, varItem: Var) => { + const newCondition = produce(condition, (draft) => { + draft.variable_selector = valueSelector + draft.varType = varItem.type + draft.value = '' + draft.comparison_operator = getOperators(varItem.type)[0] + }) + doUpdateCondition(newCondition) + setOpen(false) + }, [condition, doUpdateCondition]) + return (
) : ( - )} diff --git a/web/app/components/workflow/nodes/if-else/components/condition-list/condition-var-selector.tsx b/web/app/components/workflow/nodes/if-else/components/condition-list/condition-var-selector.tsx new file mode 100644 index 0000000000..68a012d1a0 --- /dev/null +++ b/web/app/components/workflow/nodes/if-else/components/condition-list/condition-var-selector.tsx @@ -0,0 +1,58 @@ +import { PortalToFollowElem, PortalToFollowElemContent, PortalToFollowElemTrigger } from '@/app/components/base/portal-to-follow-elem' +import VariableTag from '@/app/components/workflow/nodes/_base/components/variable-tag' +import VarReferenceVars from '@/app/components/workflow/nodes/_base/components/variable/var-reference-vars' +import type { Node, NodeOutPutVar, ValueSelector, Var, VarType } from '@/app/components/workflow/types' + +type ConditionVarSelectorProps = { + open: boolean + onOpenChange: (open: boolean) => void + valueSelector: ValueSelector + varType: VarType + availableNodes: Node[] + nodesOutputVars: NodeOutPutVar[] + onChange: (valueSelector: ValueSelector, varItem: Var) => void +} + +const ConditionVarSelector = ({ + open, + onOpenChange, + valueSelector, + varType, + availableNodes, + nodesOutputVars, + onChange, +}: ConditionVarSelectorProps) => { + return ( + + onOpenChange(!open)}> +
+ +
+
+ +
+ +
+
+
+ ) +} + +export default ConditionVarSelector 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 182e38f71e..792064e6ed 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 @@ -73,7 +73,7 @@ const ConditionValue = ({