@@ -327,11 +327,13 @@ export default class ConnectionController {
327327 this . _connectingConnectionId = connectionId ;
328328 this . eventEmitter . emit ( DataServiceEventTypes . CONNECTIONS_DID_CHANGE ) ;
329329
330+ const nextConnectionName = this . getSavedConnectionName ( connectionId ) ;
331+
330332 if ( this . _activeDataService ) {
331333 log . info ( 'Disconnecting from the previous connection...' , {
332334 connectionId : this . _currentConnectionId ,
333335 } ) ;
334- await this . disconnect ( ) ;
336+ await this . disconnect ( { quiet : true } ) ;
335337 }
336338
337339 if ( connectionAttempt . isClosed ( ) ) {
@@ -350,7 +352,7 @@ export default class ConnectionController {
350352 throw new Error ( 'Connect failed: connectionOptions are missing.' ) ;
351353 }
352354
353- this . _statusView . showMessage ( ' Connecting to MongoDB ...' ) ;
355+ this . _statusView . showMessage ( ` Connecting to ${ nextConnectionName } ...` ) ;
354356 log . info ( 'Connecting to MongoDB...' , {
355357 connectionInfo : JSON . stringify (
356358 extractSecrets ( this . _connections [ connectionId ] ) . connectionInfo
@@ -418,7 +420,9 @@ export default class ConnectionController {
418420 }
419421
420422 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+ ) ;
422426
423427 dataService . addReauthenticationHandler (
424428 this . _reauthenticationHandler . bind ( this )
@@ -566,12 +570,13 @@ export default class ConnectionController {
566570 }
567571 }
568572
569- async disconnect ( ) : Promise < boolean > {
573+ async disconnect ( { quiet = false } = { } ) : Promise < boolean > {
570574 log . info (
571575 'Disconnect called, currently connected to' ,
572576 this . _currentConnectionId
573577 ) ;
574578
579+ const disconnectingConnectionId = this . _currentConnectionId ;
575580 this . _currentConnectionId = null ;
576581 this . _disconnecting = true ;
577582
@@ -586,12 +591,24 @@ export default class ConnectionController {
586591 return false ;
587592 }
588593
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+ ) ;
590601
591602 try {
592603 // Disconnect from the active connection.
593604 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+
595612 this . _activeDataService = null ;
596613
597614 void vscode . commands . executeCommand (
@@ -607,7 +624,7 @@ export default class ConnectionController {
607624 } catch ( error ) {
608625 // Show an error, however we still reset the active connection to free up the extension.
609626 void vscode . window . showErrorMessage (
610- ' An error occurred while disconnecting from the current connection.'
627+ ` An error occurred while disconnecting from ${ disconnectingConnectionName } .`
611628 ) ;
612629 }
613630
0 commit comments