@@ -25,10 +25,12 @@ import { FILE_TYPE_OPTIONS, SUB_VARIABLES, TRANSFER_METHOD } from '../../default
25
25
import ConditionWrap from '../condition-wrap'
26
26
import ConditionOperator from './condition-operator'
27
27
import ConditionInput from './condition-input'
28
- import VariableTag from '@/app/components/workflow/nodes/_base/components/variable-tag'
28
+
29
+ import ConditionVarSelector from './condition-var-selector'
29
30
import type {
30
31
Node ,
31
32
NodeOutPutVar ,
33
+ ValueSelector ,
32
34
Var ,
33
35
} from '@/app/components/workflow/types'
34
36
import { VarType } from '@/app/components/workflow/types'
@@ -82,6 +84,7 @@ const ConditionItem = ({
82
84
const { t } = useTranslation ( )
83
85
84
86
const [ isHovered , setIsHovered ] = useState ( false )
87
+ const [ open , setOpen ] = useState ( false )
85
88
86
89
const doUpdateCondition = useCallback ( ( newCondition : Condition ) => {
87
90
if ( isSubVariableKey )
@@ -190,6 +193,17 @@ const ConditionItem = ({
190
193
onRemoveCondition ?.( caseId , condition . id )
191
194
} , [ caseId , condition , conditionId , isSubVariableKey , onRemoveCondition , onRemoveSubVariableCondition ] )
192
195
196
+ const handleVarChange = useCallback ( ( valueSelector : ValueSelector , varItem : Var ) => {
197
+ const newCondition = produce ( condition , ( draft ) => {
198
+ draft . variable_selector = valueSelector
199
+ draft . varType = varItem . type
200
+ draft . value = ''
201
+ draft . comparison_operator = getOperators ( varItem . type ) [ 0 ]
202
+ } )
203
+ doUpdateCondition ( newCondition )
204
+ setOpen ( false )
205
+ } , [ condition , doUpdateCondition ] )
206
+
193
207
return (
194
208
< div className = { cn ( 'flex mb-1 last-of-type:mb-0' , className ) } >
195
209
< div className = { cn (
@@ -221,11 +235,14 @@ const ConditionItem = ({
221
235
/>
222
236
)
223
237
: (
224
- < VariableTag
238
+ < ConditionVarSelector
239
+ open = { open }
240
+ onOpenChange = { setOpen }
225
241
valueSelector = { condition . variable_selector || [ ] }
226
242
varType = { condition . varType }
227
243
availableNodes = { availableNodes }
228
- isShort
244
+ nodesOutputVars = { nodesOutputVars }
245
+ onChange = { handleVarChange }
229
246
/>
230
247
) }
231
248
0 commit comments