Removing oe service changes from release 1.43 (#22593)

* Revert "Fixing connection without saved password not connecting in Async Server Tree (#22535)"

This reverts commit d49ff85afc.

* Revert "Adding caching in OE service (#22539)"

This reverts commit a1acaf2096.
This commit is contained in:
Aasim Khan
2023-04-03 16:04:28 -07:00
committed by GitHub
parent 15ecdc8653
commit a8d851b1ed
6 changed files with 39 additions and 51 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -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;

View File

@@ -70,7 +70,7 @@ export class AsyncServerTree extends WorkbenchAsyncDataTree<ConnectionProfileGro
* This method overrides the original implementation to find the node by comparing the ids of the elements.
* If the node is not found in the original implementation, we search for the node in the nodes map by ids.
*/
public override getDataNode(element: ServerTreeElement, throwError: boolean = true): IAsyncDataTreeNode<ConnectionProfileGroup, ServerTreeElement> | undefined {
public override getDataNode(element: ConnectionProfileGroup | ServerTreeElement): IAsyncDataTreeNode<ConnectionProfileGroup, ServerTreeElement> {
try {
const node = super.getDataNode(element);
return node;
@@ -79,10 +79,7 @@ export class AsyncServerTree extends WorkbenchAsyncDataTree<ConnectionProfileGro
if (node) {
return node;
}
if (throwError) {
throw e;
}
return undefined;
throw e;
}
}
@@ -135,13 +132,46 @@ export class AsyncServerTree extends WorkbenchAsyncDataTree<ConnectionProfileGro
public async expandElements(elements: ServerTreeElement[]): Promise<void> {
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

View File

@@ -179,9 +179,6 @@ export class ObjectExplorerService implements IObjectExplorerService {
private _connectionsWaitingForSession: Map<string, boolean> = new Map<string, boolean>();
// Cache of tree nodes for each connection by session ids
private _treeNodeCache: Map<string, Map<string, TreeNode>> = new Map<string, Map<string, TreeNode>>();
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<string, TreeNode>());
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<number>(NODE_EXPANSION_CONFIG);
}
private getTreeNodeCacheKey(node: azdata.NodeInfo): string {
return node.nodePath;
}
}

View File

@@ -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);