@@ -46,19 +46,15 @@ export function WorkflowItem({ workflow, active, level, onWorkflowClick }: Workf
4646 const userPermissions = useUserPermissionsContext ( )
4747 const isSelected = selectedWorkflows . has ( workflow . id )
4848
49- // Can delete check hook
5049 const { canDeleteWorkflows } = useCanDelete ( { workspaceId } )
5150
52- // Delete modal state
5351 const [ isDeleteModalOpen , setIsDeleteModalOpen ] = useState ( false )
5452 const [ workflowIdsToDelete , setWorkflowIdsToDelete ] = useState < string [ ] > ( [ ] )
5553 const [ deleteModalNames , setDeleteModalNames ] = useState < string | string [ ] > ( '' )
5654 const [ canDeleteCaptured , setCanDeleteCaptured ] = useState ( true )
5755
58- // Presence avatars state
5956 const [ hasAvatars , setHasAvatars ] = useState ( false )
6057
61- // Capture selection at right-click time (using ref to persist across renders)
6258 const capturedSelectionRef = useRef < {
6359 workflowIds : string [ ]
6460 workflowNames : string | string [ ]
@@ -68,44 +64,39 @@ export function WorkflowItem({ workflow, active, level, onWorkflowClick }: Workf
6864 * Handle opening the delete modal - uses pre-captured selection state
6965 */
7066 const handleOpenDeleteModal = useCallback ( ( ) => {
71- // Use the selection captured at right-click time
7267 if ( capturedSelectionRef . current ) {
7368 setWorkflowIdsToDelete ( capturedSelectionRef . current . workflowIds )
7469 setDeleteModalNames ( capturedSelectionRef . current . workflowNames )
7570 setIsDeleteModalOpen ( true )
7671 }
7772 } , [ ] )
7873
79- // Delete workflow hook
8074 const { isDeleting, handleDeleteWorkflow } = useDeleteWorkflow ( {
8175 workspaceId,
8276 workflowIds : workflowIdsToDelete ,
8377 isActive : ( workflowIds ) => workflowIds . includes ( params . workflowId as string ) ,
8478 onSuccess : ( ) => setIsDeleteModalOpen ( false ) ,
8579 } )
8680
87- // Duplicate workflow hook (uses captured selection from right-click)
88- const { handleDuplicateWorkflow } = useDuplicateWorkflow ( {
89- workspaceId,
90- workflowIds : capturedSelectionRef . current ?. workflowIds || [ ] ,
91- } )
81+ const { handleDuplicateWorkflow : duplicateWorkflow } = useDuplicateWorkflow ( { workspaceId } )
9282
93- // Export workflow hook (uses captured selection from right-click)
94- const { handleExportWorkflow } = useExportWorkflow ( {
95- workspaceId,
96- workflowIds : capturedSelectionRef . current ?. workflowIds || [ ] ,
97- } )
83+ const { handleExportWorkflow : exportWorkflow } = useExportWorkflow ( { workspaceId } )
84+ const handleDuplicateWorkflow = useCallback ( ( ) => {
85+ const workflowIds = capturedSelectionRef . current ?. workflowIds || [ ]
86+ if ( workflowIds . length === 0 ) return
87+ duplicateWorkflow ( workflowIds )
88+ } , [ duplicateWorkflow ] )
89+
90+ const handleExportWorkflow = useCallback ( ( ) => {
91+ const workflowIds = capturedSelectionRef . current ?. workflowIds || [ ]
92+ if ( workflowIds . length === 0 ) return
93+ exportWorkflow ( workflowIds )
94+ } , [ exportWorkflow ] )
9895
99- /**
100- * Opens the workflow in a new browser tab
101- */
10296 const handleOpenInNewTab = useCallback ( ( ) => {
10397 window . open ( `/workspace/${ workspaceId } /w/${ workflow . id } ` , '_blank' )
10498 } , [ workspaceId , workflow . id ] )
10599
106- /**
107- * Changes the workflow color
108- */
109100 const handleColorChange = useCallback (
110101 ( color : string ) => {
111102 updateWorkflow ( workflow . id , { color } )
@@ -120,7 +111,6 @@ export function WorkflowItem({ workflow, active, level, onWorkflowClick }: Workf
120111 */
121112 const onDragStart = useCallback (
122113 ( e : React . DragEvent ) => {
123- // Don't start drag if editing
124114 if ( isEditing ) {
125115 e . preventDefault ( )
126116 return
@@ -135,12 +125,10 @@ export function WorkflowItem({ workflow, active, level, onWorkflowClick }: Workf
135125 [ isSelected , selectedWorkflows , workflow . id ]
136126 )
137127
138- // Item drag hook
139128 const { isDragging, shouldPreventClickRef, handleDragStart, handleDragEnd } = useItemDrag ( {
140129 onDragStart,
141130 } )
142131
143- // Context menu hook
144132 const {
145133 isOpen : isContextMenuOpen ,
146134 position,
@@ -209,14 +197,12 @@ export function WorkflowItem({ workflow, active, level, onWorkflowClick }: Workf
209197 e . preventDefault ( )
210198 e . stopPropagation ( )
211199
212- // Toggle: close if open, open if closed
213200 if ( isContextMenuOpen ) {
214201 closeMenu ( )
215202 return
216203 }
217204
218205 captureSelectionState ( )
219- // Open context menu aligned with the button
220206 const rect = e . currentTarget . getBoundingClientRect ( )
221207 handleContextMenuBase ( {
222208 preventDefault : ( ) => { } ,
@@ -228,7 +214,6 @@ export function WorkflowItem({ workflow, active, level, onWorkflowClick }: Workf
228214 [ isContextMenuOpen , closeMenu , captureSelectionState , handleContextMenuBase ]
229215 )
230216
231- // Rename hook
232217 const {
233218 isEditing,
234219 editValue,
@@ -275,12 +260,10 @@ export function WorkflowItem({ workflow, active, level, onWorkflowClick }: Workf
275260
276261 const isModifierClick = e . shiftKey || e . metaKey || e . ctrlKey
277262
278- // Prevent default link behavior when using modifier keys
279263 if ( isModifierClick ) {
280264 e . preventDefault ( )
281265 }
282266
283- // Use metaKey (Cmd on Mac) or ctrlKey (Ctrl on Windows/Linux)
284267 onWorkflowClick ( workflow . id , e . shiftKey , e . metaKey || e . ctrlKey )
285268 } ,
286269 [ shouldPreventClickRef , workflow . id , onWorkflowClick , isEditing ]
0 commit comments