dify/web/app/components/workflow/workflow-preview/components/node-handle.tsx
Yeuoly b76e17b25d
feat: introduce trigger functionality (#27644)
Signed-off-by: lyzno1 <yuanyouhuilyz@gmail.com>
Co-authored-by: Stream <Stream_2@qq.com>
Co-authored-by: lyzno1 <92089059+lyzno1@users.noreply.github.com>
Co-authored-by: zhsama <torvalds@linux.do>
Co-authored-by: Harry <xh001x@hotmail.com>
Co-authored-by: lyzno1 <yuanyouhuilyz@gmail.com>
Co-authored-by: yessenia <yessenia.contact@gmail.com>
Co-authored-by: hjlarry <hjlarry@163.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: WTW0313 <twwu@dify.ai>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-11-12 17:59:37 +08:00

74 lines
1.9 KiB
TypeScript

import {
memo,
} from 'react'
import {
Handle,
Position,
} from 'reactflow'
import {
BlockEnum,
} from '@/app/components/workflow/types'
import type { Node } from '@/app/components/workflow/types'
import cn from '@/utils/classnames'
type NodeHandleProps = {
handleId: string
handleClassName?: string
} & Pick<Node, 'id' | 'data'>
export const NodeTargetHandle = memo(({
data,
handleId,
handleClassName,
}: NodeHandleProps) => {
const connected = data._connectedTargetHandleIds?.includes(handleId)
return (
<>
<Handle
id={handleId}
type='target'
position={Position.Left}
className={cn(
'z-[1] !h-4 !w-4 !rounded-none !border-none !bg-transparent !outline-none',
'after:absolute after:left-1.5 after:top-1 after:h-2 after:w-0.5 after:bg-workflow-link-line-handle',
'transition-all hover:scale-125',
!connected && 'after:opacity-0',
(data.type === BlockEnum.Start
|| data.type === BlockEnum.TriggerWebhook
|| data.type === BlockEnum.TriggerSchedule
|| data.type === BlockEnum.TriggerPlugin) && 'opacity-0',
handleClassName,
)}
>
</Handle>
</>
)
})
NodeTargetHandle.displayName = 'NodeTargetHandle'
export const NodeSourceHandle = memo(({
data,
handleId,
handleClassName,
}: NodeHandleProps) => {
const connected = data._connectedSourceHandleIds?.includes(handleId)
return (
<Handle
id={handleId}
type='source'
position={Position.Right}
className={cn(
'group/handle z-[1] !h-4 !w-4 !rounded-none !border-none !bg-transparent !outline-none',
'after:absolute after:right-1.5 after:top-1 after:h-2 after:w-0.5 after:bg-workflow-link-line-handle',
'transition-all hover:scale-125',
!connected && 'after:opacity-0',
handleClassName,
)}
>
</Handle>
)
})
NodeSourceHandle.displayName = 'NodeSourceHandle'