@@ -48,6 +48,15 @@ export class ObjectExplorerDragAndDropController
4848 ) : void {
4949 const item = source [ 0 ] ; // Handle only the first item for simplicity
5050
51+ // Prevent dragging User Connections and Workspace Connections groups
52+ if (
53+ item instanceof ConnectionGroupNode &&
54+ ( item . label === "User Connections" || item . label === "Workspace Connections" )
55+ ) {
56+ // Do not set drag data, effectively disabling drag
57+ return ;
58+ }
59+
5160 if ( item instanceof ConnectionNode || item instanceof ConnectionGroupNode ) {
5261 const dragData : ObjectExplorerDragMetadata = {
5362 name : item . label . toString ( ) ,
@@ -83,23 +92,39 @@ export class ObjectExplorerDragAndDropController
8392 return ;
8493 }
8594
95+ // Prevent dropping User Connections or Workspace Connections groups anywhere
96+ const userGroupId = this . connectionStore . connectionConfig . getUserConnectionsGroupId ( ) ;
97+ const workspaceGroupId =
98+ this . connectionStore . connectionConfig . getWorkspaceConnectionsGroupId ( ) ;
99+ if (
100+ dragData . type === "connectionGroup" &&
101+ ( dragData . id === userGroupId || dragData . id === workspaceGroupId )
102+ ) {
103+ // Do nothing, prevent drop
104+ return ;
105+ }
106+
107+ // Prevent dropping onto User Connections or Workspace Connections groups
108+ if (
109+ target instanceof ConnectionGroupNode &&
110+ ( target . label === "User Connections" || target . label === "Workspace Connections" )
111+ ) {
112+ // Do nothing, prevent drop
113+ return ;
114+ }
115+
116+ // Prevent drag-and-drop if target is root
117+ if ( target === undefined ) {
118+ return ;
119+ }
120+
86121 try {
87122 if ( dragData . isConnectionOrGroup && dragData . type && dragData . id ) {
88- if ( target instanceof ConnectionGroupNode || target === undefined ) {
89- let targetInfo : { label : string ; id : string } ;
90-
91- // If the target is undefined, we're dropping onto the root of the Object Explorer
92- if ( target === undefined ) {
93- targetInfo = {
94- label : "ROOT" ,
95- id : this . connectionStore . rootGroupId ,
96- } ;
97- } else {
98- targetInfo = {
99- label : target . label . toString ( ) ,
100- id : target . id ,
101- } ;
102- }
123+ if ( target instanceof ConnectionGroupNode ) {
124+ let targetInfo : { label : string ; id : string } = {
125+ label : target . label . toString ( ) ,
126+ id : target . id ,
127+ } ;
103128
104129 this . _logger . verbose (
105130 `Dragged ${ dragData . type } '${ dragData . name } ' (ID: ${ dragData . id } ) onto group '${ targetInfo . label } ' (ID: ${ targetInfo . id } )` ,
@@ -150,7 +175,7 @@ export class ObjectExplorerDragAndDropController
150175
151176 sendActionEvent ( TelemetryViews . ObjectExplorer , TelemetryActions . DragAndDrop , {
152177 dragType : dragData . type ,
153- dropTarget : target ? "connectionGroup" : "ROOT ",
178+ dropTarget : "connectionGroup" ,
154179 } ) ;
155180 }
156181 }
0 commit comments