@@ -4,7 +4,9 @@ import { Button, Copy, Tooltip, Trash2 } from '@/components/emcn'
44import { cn } from '@/lib/core/utils/cn'
55import { isInputDefinitionTrigger } from '@/lib/workflows/triggers/input-definition-triggers'
66import { useUserPermissionsContext } from '@/app/workspace/[workspaceId]/providers/workspace-permissions-provider'
7+ import { validateTriggerPaste } from '@/app/workspace/[workspaceId]/w/[workflowId]/utils'
78import { useCollaborativeWorkflow } from '@/hooks/use-collaborative-workflow'
9+ import { useNotificationStore } from '@/stores/notifications'
810import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
911import { useWorkflowStore } from '@/stores/workflows/workflow/store'
1012
@@ -48,14 +50,27 @@ export const ActionBar = memo(
4850 } = useCollaborativeWorkflow ( )
4951 const { setPendingSelection } = useWorkflowRegistry ( )
5052
53+ const addNotification = useNotificationStore ( ( s ) => s . addNotification )
54+
5155 const handleDuplicateBlock = useCallback ( ( ) => {
52- const { copyBlocks, preparePasteData } = useWorkflowRegistry . getState ( )
56+ const { copyBlocks, preparePasteData, activeWorkflowId } = useWorkflowRegistry . getState ( )
57+ const existingBlocks = useWorkflowStore . getState ( ) . blocks
5358 copyBlocks ( [ blockId ] )
5459
5560 const pasteData = preparePasteData ( DEFAULT_DUPLICATE_OFFSET )
5661 if ( ! pasteData ) return
5762
5863 const blocks = Object . values ( pasteData . blocks )
64+ const validation = validateTriggerPaste ( blocks , existingBlocks , 'duplicate' )
65+ if ( ! validation . isValid ) {
66+ addNotification ( {
67+ level : 'error' ,
68+ message : validation . message ! ,
69+ workflowId : activeWorkflowId || undefined ,
70+ } )
71+ return
72+ }
73+
5974 setPendingSelection ( blocks . map ( ( b ) => b . id ) )
6075 collaborativeBatchAddBlocks (
6176 blocks ,
@@ -64,7 +79,7 @@ export const ActionBar = memo(
6479 pasteData . parallels ,
6580 pasteData . subBlockValues
6681 )
67- } , [ blockId , collaborativeBatchAddBlocks , setPendingSelection ] )
82+ } , [ blockId , addNotification , collaborativeBatchAddBlocks , setPendingSelection ] )
6883
6984 const { isEnabled, horizontalHandles, parentId, parentType } = useWorkflowStore (
7085 useCallback (
0 commit comments