@@ -327,11 +327,13 @@ export default class ConnectionController {
327
327
this . _connectingConnectionId = connectionId ;
328
328
this . eventEmitter . emit ( DataServiceEventTypes . CONNECTIONS_DID_CHANGE ) ;
329
329
330
+ const nextConnectionName = this . getSavedConnectionName ( connectionId ) ;
331
+
330
332
if ( this . _activeDataService ) {
331
333
log . info ( 'Disconnecting from the previous connection...' , {
332
334
connectionId : this . _currentConnectionId ,
333
335
} ) ;
334
- await this . disconnect ( ) ;
336
+ await this . disconnect ( { quiet : true } ) ;
335
337
}
336
338
337
339
if ( connectionAttempt . isClosed ( ) ) {
@@ -350,7 +352,7 @@ export default class ConnectionController {
350
352
throw new Error ( 'Connect failed: connectionOptions are missing.' ) ;
351
353
}
352
354
353
- this . _statusView . showMessage ( ' Connecting to MongoDB ...' ) ;
355
+ this . _statusView . showMessage ( ` Connecting to ${ nextConnectionName } ...` ) ;
354
356
log . info ( 'Connecting to MongoDB...' , {
355
357
connectionInfo : JSON . stringify (
356
358
extractSecrets ( this . _connections [ connectionId ] ) . connectionInfo
@@ -418,7 +420,9 @@ export default class ConnectionController {
418
420
}
419
421
420
422
log . info ( 'Successfully connected' , { connectionId } ) ;
421
- void vscode . window . showInformationMessage ( 'MongoDB connection successful.' ) ;
423
+ void vscode . window . showInformationMessage (
424
+ `Set the active connection to ${ nextConnectionName } .`
425
+ ) ;
422
426
423
427
dataService . addReauthenticationHandler (
424
428
this . _reauthenticationHandler . bind ( this )
@@ -566,12 +570,13 @@ export default class ConnectionController {
566
570
}
567
571
}
568
572
569
- async disconnect ( ) : Promise < boolean > {
573
+ async disconnect ( { quiet = false } = { } ) : Promise < boolean > {
570
574
log . info (
571
575
'Disconnect called, currently connected to' ,
572
576
this . _currentConnectionId
573
577
) ;
574
578
579
+ const disconnectingConnectionId = this . _currentConnectionId ;
575
580
this . _currentConnectionId = null ;
576
581
this . _disconnecting = true ;
577
582
@@ -586,12 +591,24 @@ export default class ConnectionController {
586
591
return false ;
587
592
}
588
593
589
- this . _statusView . showMessage ( 'Disconnecting from current connection...' ) ;
594
+ const disconnectingConnectionName = disconnectingConnectionId
595
+ ? this . getSavedConnectionName ( disconnectingConnectionId )
596
+ : 'MongoDB server' ;
597
+
598
+ this . _statusView . showMessage (
599
+ `Disconnecting from ${ disconnectingConnectionName } ...`
600
+ ) ;
590
601
591
602
try {
592
603
// Disconnect from the active connection.
593
604
await this . _activeDataService . disconnect ( ) ;
594
- void vscode . window . showInformationMessage ( 'MongoDB disconnected.' ) ;
605
+
606
+ if ( ! quiet ) {
607
+ void vscode . window . showInformationMessage (
608
+ `Disconnected from ${ disconnectingConnectionName } .`
609
+ ) ;
610
+ }
611
+
595
612
this . _activeDataService = null ;
596
613
597
614
void vscode . commands . executeCommand (
@@ -607,7 +624,7 @@ export default class ConnectionController {
607
624
} catch ( error ) {
608
625
// Show an error, however we still reset the active connection to free up the extension.
609
626
void vscode . window . showErrorMessage (
610
- ' An error occurred while disconnecting from the current connection.'
627
+ ` An error occurred while disconnecting from ${ disconnectingConnectionName } .`
611
628
) ;
612
629
}
613
630
0 commit comments