From d49ff85afcdb99c4dea09f70712cc743dcd5ec56 Mon Sep 17 00:00:00 2001 From: Aasim Khan Date: Fri, 31 Mar 2023 09:19:01 -0700 Subject: [PATCH] Fixing connection without saved password not connecting in Async Server Tree (#22535) --- .../contrib/objectExplorer/browser/serverTreeView.ts | 5 +++++ .../services/connection/browser/connectionDialogService.ts | 3 +++ .../connection/browser/connectionManagementService.ts | 4 +++- .../services/objectExplorer/browser/treeUpdateUtils.ts | 2 +- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/sql/workbench/contrib/objectExplorer/browser/serverTreeView.ts b/src/sql/workbench/contrib/objectExplorer/browser/serverTreeView.ts index fd2ebfc703..2b9145a1be 100644 --- a/src/sql/workbench/contrib/objectExplorer/browser/serverTreeView.ts +++ b/src/sql/workbench/contrib/objectExplorer/browser/serverTreeView.ts @@ -472,6 +472,11 @@ export class ServerTreeView extends Disposable implements IServerTreeView { await this._connectionManagementService.deleteConnection(profile); } const connectionProfile = this.getConnectionInTreeInput(profile.id); + + // For the connection profile, we need to clear the password from the last session if the user doesn't want to save it + if (!connectionProfile.savePassword) { + connectionProfile.password = ''; + } // Delete the node from the tree await this._objectExplorerService.deleteObjectExplorerNode(connectionProfile); // Collapse the node diff --git a/src/sql/workbench/services/connection/browser/connectionDialogService.ts b/src/sql/workbench/services/connection/browser/connectionDialogService.ts index 289cacdb06..26ee04e5d2 100644 --- a/src/sql/workbench/services/connection/browser/connectionDialogService.ts +++ b/src/sql/workbench/services/connection/browser/connectionDialogService.ts @@ -270,6 +270,9 @@ export class ConnectionDialogService implements IConnectionDialogService { showFirewallRuleOnError: true }; + if (params && options.params === undefined) { + options.params = params; + } try { const connectionResult = await this._connectionManagementService.connectAndSaveProfile(connection, uri, options, params && params.input); this._connecting = false; diff --git a/src/sql/workbench/services/connection/browser/connectionManagementService.ts b/src/sql/workbench/services/connection/browser/connectionManagementService.ts index 8f10fac736..2181302f6f 100644 --- a/src/sql/workbench/services/connection/browser/connectionManagementService.ts +++ b/src/sql/workbench/services/connection/browser/connectionManagementService.ts @@ -416,7 +416,9 @@ export class ConnectionManagementService extends Disposable implements IConnecti connectionType: this._connectionStatusManager.isEditorTypeUri(owner.uri) ? ConnectionType.editor : ConnectionType.default, input: owner, runQueryOnCompletion: RunQueryOnConnectionMode.none, - showDashboard: options.showDashboard + showDashboard: options.showDashboard, + isEditConnection: true, + oldProfileId: connection.id }; return this.showConnectionDialog(params, options, connection, connectionResult).then(() => { return connectionResult; diff --git a/src/sql/workbench/services/objectExplorer/browser/treeUpdateUtils.ts b/src/sql/workbench/services/objectExplorer/browser/treeUpdateUtils.ts index 6a684b409a..aeb219f523 100644 --- a/src/sql/workbench/services/objectExplorer/browser/treeUpdateUtils.ts +++ b/src/sql/workbench/services/objectExplorer/browser/treeUpdateUtils.ts @@ -305,8 +305,8 @@ export class TreeUpdateUtils { // If the node update takes too long, reject the promise const nodeUpdateTimeout = () => { - reject(new Error(nls.localize('objectExplorerTimeout', "Object Explorer expansion timed out for '{0}'", connection.databaseName))); cleanup(); + reject(new Error(nls.localize('objectExplorerTimeout', "Object Explorer expansion timed out for '{0}'", connection.databaseName))); } const nodeUpdateTimer = setTimeout(nodeUpdateTimeout, expansionTimeoutValueSec * 1000);