diff --git a/src/sql/workbench/contrib/objectExplorer/browser/serverTreeView.ts b/src/sql/workbench/contrib/objectExplorer/browser/serverTreeView.ts index 2b9145a1be..fd2ebfc703 100644 --- a/src/sql/workbench/contrib/objectExplorer/browser/serverTreeView.ts +++ b/src/sql/workbench/contrib/objectExplorer/browser/serverTreeView.ts @@ -472,11 +472,6 @@ 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 26ee04e5d2..289cacdb06 100644 --- a/src/sql/workbench/services/connection/browser/connectionDialogService.ts +++ b/src/sql/workbench/services/connection/browser/connectionDialogService.ts @@ -270,9 +270,6 @@ 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 2181302f6f..8f10fac736 100644 --- a/src/sql/workbench/services/connection/browser/connectionManagementService.ts +++ b/src/sql/workbench/services/connection/browser/connectionManagementService.ts @@ -416,9 +416,7 @@ 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, - isEditConnection: true, - oldProfileId: connection.id + showDashboard: options.showDashboard }; return this.showConnectionDialog(params, options, connection, connectionResult).then(() => { return connectionResult; diff --git a/src/sql/workbench/services/objectExplorer/browser/asyncServerTree.ts b/src/sql/workbench/services/objectExplorer/browser/asyncServerTree.ts index 0a77592a97..bdca7cc7f4 100644 --- a/src/sql/workbench/services/objectExplorer/browser/asyncServerTree.ts +++ b/src/sql/workbench/services/objectExplorer/browser/asyncServerTree.ts @@ -70,7 +70,7 @@ export class AsyncServerTree extends WorkbenchAsyncDataTree | undefined { + public override getDataNode(element: ConnectionProfileGroup | ServerTreeElement): IAsyncDataTreeNode { try { const node = super.getDataNode(element); return node; @@ -79,10 +79,7 @@ export class AsyncServerTree extends WorkbenchAsyncDataTree { for (let element of elements) { - const node = this.getDataNode(element, false); + const id = element.id; + const node = this.getDataNodeById(id); if (node) { await this.expand(node.element); + } else { + // If the node is not found in the nodes map, we search for the node by comparing the relative paths of the elements + if (element) { + const elementPath = this.getRelativePath(element); + for (let n of this.nodes.values()) { + if (this.getRelativePath(n.element) === elementPath) { + await this.expand(n.element); + break; + } + } + } } } } + /** + * Get the relative path of the element in the tree. For connection and group, the path is the id of the element. + * For other elements, the path is the node path of the element and the id of the connection they belong to. + */ + private getRelativePath(element: ServerTreeElement): string { + let path = ''; + if (element instanceof TreeNode) { + path = element.nodePath; + let parent = element.parent; + while (parent.parent) { + parent = parent.parent; + } + if (parent.connection) { + path = parent.connection.id + '/' + path; + } + } else if (element instanceof ConnectionProfile || element instanceof ConnectionProfileGroup) { + path = element.id; + } + return path; + } + /** * Mark the element as dirty so that it will be refreshed when it is expanded next time * @param element The element to mark as dirty diff --git a/src/sql/workbench/services/objectExplorer/browser/objectExplorerService.ts b/src/sql/workbench/services/objectExplorer/browser/objectExplorerService.ts index c761662697..31c4fc873d 100644 --- a/src/sql/workbench/services/objectExplorer/browser/objectExplorerService.ts +++ b/src/sql/workbench/services/objectExplorer/browser/objectExplorerService.ts @@ -179,9 +179,6 @@ export class ObjectExplorerService implements IObjectExplorerService { private _connectionsWaitingForSession: Map = new Map(); - // Cache of tree nodes for each connection by session ids - private _treeNodeCache: Map> = new Map>(); - constructor( @IConnectionManagementService private _connectionManagementService: IConnectionManagementService, @IAdsTelemetryService private _telemetryService: IAdsTelemetryService, @@ -236,7 +233,6 @@ export class ObjectExplorerService implements IObjectExplorerService { if (!session) { return; } - this._treeNodeCache.delete(session.sessionId); await this.closeSession(connection.providerName, session); delete this._activeObjectExplorerNodes[connectionUri]; delete this._sessions[session.sessionId!]; @@ -344,8 +340,6 @@ export class ObjectExplorerService implements IObjectExplorerService { try { if (session.success && session.rootNode) { let server = this.toTreeNode(session.rootNode, undefined); - this._treeNodeCache.set(sessionId, new Map()); - this._treeNodeCache.get(sessionId)!.set(this.getTreeNodeCacheKey(server.toNodeInfo()), server); server.connection = connection; server.session = session; this._activeObjectExplorerNodes[connection!.id] = server; @@ -736,31 +730,9 @@ export class ObjectExplorerService implements IObjectExplorerService { throw new Error('Failed to expand node - no provider name'); } const expandResult = await this.callExpandOrRefreshFromService(providerName, session, parentTree, refresh); - const sessionTreeNodeCache = this._treeNodeCache.get(session.sessionId!); if (expandResult && expandResult.nodes) { - // In case of refresh, we want to clear the cache of the descendants of the node being refreshed - if (refresh && parentTree?.children) { - const stack = [...parentTree.children]; - while (stack.length > 0) { - const currentTreeNode = stack.pop(); - if (currentTreeNode) { - sessionTreeNodeCache.delete(this.getTreeNodeCacheKey(currentTreeNode.toNodeInfo())); - if (currentTreeNode.children) { - stack.push(...currentTreeNode.children); - } - } - } - } const children = expandResult.nodes.map(node => { - const cacheKey = this.getTreeNodeCacheKey(node); - // In case of refresh, we want to update the existing node in the cache - if (!refresh && sessionTreeNodeCache.has(cacheKey)) { - return sessionTreeNodeCache.get(cacheKey); - } else { - const treeNode = this.toTreeNode(node, parentTree); - sessionTreeNodeCache.set(cacheKey, treeNode); - return treeNode; - } + return this.toTreeNode(node, parentTree); }); parentTree.children = children.filter(c => c !== undefined); return children; @@ -1032,8 +1004,4 @@ export class ObjectExplorerService implements IObjectExplorerService { public getObjectExplorerTimeout(): number { return this._configurationService.getValue(NODE_EXPANSION_CONFIG); } - - private getTreeNodeCacheKey(node: azdata.NodeInfo): string { - return node.nodePath; - } } diff --git a/src/sql/workbench/services/objectExplorer/browser/treeUpdateUtils.ts b/src/sql/workbench/services/objectExplorer/browser/treeUpdateUtils.ts index aeb219f523..6a684b409a 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 = () => { - cleanup(); reject(new Error(nls.localize('objectExplorerTimeout', "Object Explorer expansion timed out for '{0}'", connection.databaseName))); + cleanup(); } const nodeUpdateTimer = setTimeout(nodeUpdateTimeout, expansionTimeoutValueSec * 1000);