@@ -743,7 +743,15 @@ export default class ConnectionController {
743
743
async onRemoveMongoDBConnection ( ) : Promise < boolean > {
744
744
log . info ( 'mdb.removeConnection command called' ) ;
745
745
746
- const connectionIds = Object . keys ( this . _connections ) ;
746
+ const connectionIds = Object . entries ( this . _connections )
747
+ . map ( ( [ id , connection ] ) => {
748
+ return { id, connection } ;
749
+ } )
750
+ . filter (
751
+ ( { connection } ) =>
752
+ connection . source !== 'globalSettings' &&
753
+ connection . source !== 'workspaceSettings'
754
+ ) ;
747
755
748
756
if ( connectionIds . length === 0 ) {
749
757
// No active connection(s) to remove.
@@ -753,15 +761,15 @@ export default class ConnectionController {
753
761
}
754
762
755
763
if ( connectionIds . length === 1 ) {
756
- return this . removeMongoDBConnection ( connectionIds [ 0 ] ) ;
764
+ return this . removeMongoDBConnection ( connectionIds [ 0 ] . id ) ;
757
765
}
758
766
759
767
// There is more than 1 possible connection to remove.
760
768
// We attach the index of the connection so that we can infer their pick.
761
769
const connectionNameToRemove : string | undefined =
762
770
await vscode . window . showQuickPick (
763
771
connectionIds . map (
764
- ( id , index ) => `${ index + 1 } : ${ this . _connections [ id ] . name } `
772
+ ( { connection } , index ) => `${ index + 1 } : ${ connection . name } `
765
773
) ,
766
774
{
767
775
placeHolder : 'Choose a connection to remove...' ,
@@ -775,7 +783,7 @@ export default class ConnectionController {
775
783
// We attach the index of the connection so that we can infer their pick.
776
784
const connectionIndexToRemove =
777
785
Number ( connectionNameToRemove . split ( ':' , 1 ) [ 0 ] ) - 1 ;
778
- const connectionIdToRemove = connectionIds [ connectionIndexToRemove ] ;
786
+ const connectionIdToRemove = connectionIds [ connectionIndexToRemove ] . id ;
779
787
780
788
return this . removeMongoDBConnection ( connectionIdToRemove ) ;
781
789
}
0 commit comments