11import { useState , useEffect } from 'react' ;
2- import { X , Link2 , Search , CheckCircle , ArrowRight , Target , ExternalLink , Filter , ChevronDown , CheckCircle2 , Trash2 } from 'lucide-react' ;
2+ import { X , Link2 , Search , CheckCircle , ArrowRight , Target , ExternalLink , Filter , CheckCircle2 } from 'lucide-react' ;
33import { useQuery , useMutation } from '@apollo/client' ;
4- import { GET_WORK_ITEMS , CREATE_EDGE , GET_EDGES , DELETE_EDGE } from '../lib/queries' ;
4+ import { GET_WORK_ITEMS , CREATE_EDGE , GET_EDGES } from '../lib/queries' ;
55import { useAuth } from '../contexts/AuthContext' ;
66import { useGraph } from '../contexts/GraphContext' ;
77import { useNotifications } from '../contexts/NotificationContext' ;
@@ -11,7 +11,6 @@ import {
1111 Edge ,
1212 getExistingRelationships ,
1313 relationshipExists ,
14- getNodesWithExistingRelationship ,
1514 hasExistingRelationshipWithSelected ,
1615 filterValidSelectedNodes ,
1716 getRelationshipIcon
@@ -123,34 +122,6 @@ export function ConnectNodeModal({ isOpen, onClose, sourceNode }: ConnectNodeMod
123122 awaitRefetchQueries : true
124123 } ) ;
125124
126- const [ deleteEdgeMutation , { loading : deletingConnection } ] = useMutation ( DELETE_EDGE , {
127- refetchQueries : [
128- // Refetch edges for the source node
129- {
130- query : GET_EDGES ,
131- variables : {
132- where : {
133- OR : [
134- { source : { id : sourceNode . id } } ,
135- { target : { id : sourceNode . id } }
136- ]
137- }
138- }
139- } ,
140- // Refetch all edges for graph visualization
141- {
142- query : GET_EDGES ,
143- variables : { }
144- } ,
145- // Refetch work items
146- {
147- query : GET_WORK_ITEMS ,
148- variables : { options : { limit : 100 } }
149- }
150- ] ,
151- awaitRefetchQueries : true
152- } ) ;
153-
154125 // Initialize data arrays
155126 const workItems : WorkItem [ ] = workItemsData ?. workItems || [ ] ;
156127 const existingEdges : Edge [ ] = edgesData ?. edges || [ ] ;
@@ -312,37 +283,6 @@ export function ConnectNodeModal({ isOpen, onClose, sourceNode }: ConnectNodeMod
312283 }
313284 } ;
314285
315- const handleDisconnectEdge = async ( connectionId : string , connectedNodeTitle : string , relationshipType : string ) => {
316- try {
317- console . log ( 'Disconnecting edge:' , { connectionId, connectedNodeTitle, relationshipType } ) ;
318-
319- await deleteEdgeMutation ( {
320- variables : {
321- where : { id : connectionId }
322- }
323- } ) ;
324-
325- showSuccess (
326- 'Connection Removed Successfully!' ,
327- `Disconnected "${ sourceNode . title } " from "${ connectedNodeTitle } "`
328- ) ;
329-
330- } catch ( error : any ) {
331- console . error ( 'Failed to disconnect:' , error ) ;
332-
333- let errorMessage = 'Please try again or contact support.' ;
334- if ( error . graphQLErrors && error . graphQLErrors . length > 0 ) {
335- errorMessage = error . graphQLErrors [ 0 ] . message ;
336- } else if ( error . networkError ) {
337- errorMessage = 'Network error. Please check your connection.' ;
338- } else if ( error . message ) {
339- errorMessage = error . message ;
340- }
341-
342- showError ( 'Failed to Remove Connection' , errorMessage ) ;
343- }
344- } ;
345-
346286 const selectedRelation = RELATIONSHIP_TYPES . find ( r => r . type === selectedRelationType ) ;
347287
348288 return (
@@ -734,22 +674,6 @@ export function ConnectNodeModal({ isOpen, onClose, sourceNode }: ConnectNodeMod
734674 < span className = "text-gray-200 font-medium text-xs max-w-16 truncate" > { connection . connectedNode . title } </ span >
735675 </ div >
736676 </ div >
737-
738- { /* Disconnect Button - Only show for Edge entities (not WorkItem dependencies) */ }
739- { connection . id . startsWith ( 'edge-' ) || ( ! connection . id . startsWith ( 'workitem-' ) ) ? (
740- < button
741- onClick = { ( ) => handleDisconnectEdge ( connection . id , connection . connectedNode . title , connection . type ) }
742- disabled = { deletingConnection }
743- className = "opacity-0 group-hover:opacity-100 transition-opacity duration-200 p-2 rounded-lg bg-red-500/20 hover:bg-red-500/30 border border-red-400/30 hover:border-red-400/50 disabled:opacity-50 disabled:cursor-not-allowed"
744- title = { `Disconnect ${ relationshipType ?. label || connection . type } relationship` }
745- >
746- < Trash2 className = "h-3 w-3 text-red-400" />
747- </ button >
748- ) : (
749- < div className = "text-xs text-gray-500 px-2 py-1 rounded bg-gray-600/20 border border-gray-600/30" >
750- Legacy
751- </ div >
752- ) }
753677 </ div >
754678 ) ;
755679 } ) }
@@ -917,14 +841,13 @@ export function ConnectNodeModal({ isOpen, onClose, sourceNode }: ConnectNodeMod
917841 </ button >
918842 < button
919843 onClick = { handleCreateConnections }
920- disabled = { selectedNodes . size === 0 || creatingConnection || deletingConnection || isRelationshipDisabled ( selectedRelationType ) }
844+ disabled = { selectedNodes . size === 0 || creatingConnection || isRelationshipDisabled ( selectedRelationType ) }
921845 className = "px-8 py-3 bg-gradient-to-r from-emerald-600 to-green-700 hover:from-emerald-500 hover:to-green-600 text-white rounded-xl transition-all duration-200 disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-3 font-semibold shadow-lg shadow-emerald-500/20 disabled:shadow-none"
922846 title = { isRelationshipDisabled ( selectedRelationType ) ? 'This relationship already exists between the selected nodes' : '' }
923847 >
924848 < Link2 className = "w-5 h-5" />
925849 < span >
926850 { creatingConnection ? 'Connecting...' :
927- deletingConnection ? 'Removing connection...' :
928851 isRelationshipDisabled ( selectedRelationType ) ? 'Already Connected' :
929852 `Connect ${ selectedNodes . size } Node${ selectedNodes . size !== 1 ? 's' : '' } ` }
930853 </ span >
0 commit comments