mirror of
https://github.com/langgenius/dify.git
synced 2026-04-21 23:38:53 +08:00
feat: support context and other var reset
This commit is contained in:
parent
8d4f40bc7c
commit
7320ac41af
@ -24,6 +24,7 @@ import {
|
|||||||
import { VarType as VarKindType } from '@/app/components/workflow/nodes/tool/types'
|
import { VarType as VarKindType } from '@/app/components/workflow/nodes/tool/types'
|
||||||
import TypeSelector from '@/app/components/workflow/nodes/_base/components/selector'
|
import TypeSelector from '@/app/components/workflow/nodes/_base/components/selector'
|
||||||
import { ChevronDown } from '@/app/components/base/icons/src/vender/line/arrows'
|
import { ChevronDown } from '@/app/components/base/icons/src/vender/line/arrows'
|
||||||
|
import { XClose } from '@/app/components/base/icons/src/vender/line/general'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
className?: string
|
className?: string
|
||||||
@ -162,6 +163,13 @@ const VarReferencePicker: FC<Props> = ({
|
|||||||
onChange(e.target.value as string, varKindType)
|
onChange(e.target.value as string, varKindType)
|
||||||
}, [onChange, varKindType])
|
}, [onChange, varKindType])
|
||||||
|
|
||||||
|
const handleClearVar = useCallback(() => {
|
||||||
|
if (varKindType === VarKindType.static)
|
||||||
|
onChange('', varKindType)
|
||||||
|
else
|
||||||
|
onChange([], varKindType)
|
||||||
|
}, [onChange, varKindType])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={cn(className, !readonly && 'cursor-pointer')}>
|
<div className={cn(className, !readonly && 'cursor-pointer')}>
|
||||||
<PortalToFollowElem
|
<PortalToFollowElem
|
||||||
@ -170,7 +178,7 @@ const VarReferencePicker: FC<Props> = ({
|
|||||||
placement='bottom-start'
|
placement='bottom-start'
|
||||||
>
|
>
|
||||||
<PortalToFollowElemTrigger onClick={() => !isConstant ? setOpen(!open) : setControlFocus(Date.now())} className='!flex'>
|
<PortalToFollowElemTrigger onClick={() => !isConstant ? setOpen(!open) : setControlFocus(Date.now())} className='!flex'>
|
||||||
<div className={cn((open || isFocus) && 'border border-gray-300', 'flex items-center w-full h-8 p-1 rounded-lg bg-gray-100')}>
|
<div className={cn((open || isFocus) && 'border border-gray-300', 'relative group/wrap flex items-center w-full h-8 p-1 rounded-lg bg-gray-100')}>
|
||||||
{isSupportConstantValue
|
{isSupportConstantValue
|
||||||
? <div onClick={(e) => {
|
? <div onClick={(e) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
@ -228,6 +236,12 @@ const VarReferencePicker: FC<Props> = ({
|
|||||||
: <div className='text-[13px] font-normal text-gray-400'>{t('workflow.common.setVarValuePlaceholder')}</div>}
|
: <div className='text-[13px] font-normal text-gray-400'>{t('workflow.common.setVarValuePlaceholder')}</div>}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
{hasValue && (<div
|
||||||
|
className='invisible group-hover/wrap:visible absolute h-5 right-1 top-[50%] translate-y-[-50%] group p-1 rounded-md hover:bg-black/5 cursor-pointer'
|
||||||
|
onClick={handleClearVar}
|
||||||
|
>
|
||||||
|
<XClose className='w-3.5 h-3.5 text-gray-500 group-hover:text-gray-800' />
|
||||||
|
</div>)}
|
||||||
</div>
|
</div>
|
||||||
</PortalToFollowElemTrigger>
|
</PortalToFollowElemTrigger>
|
||||||
<PortalToFollowElemContent style={{
|
<PortalToFollowElemContent style={{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user