mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Fix a memory leak on listener (#10294)
* Fix leak * We don't need the full connection profiles for drag drop control * Remove unused code * Change test definition * Change test definition * Change equality check
This commit is contained in:
@@ -183,12 +183,7 @@ export class ConnectionConfig {
|
|||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public getIConnectionProfileStores(getWorkspaceConnections: boolean): IConnectionProfileStore[] {
|
||||||
* Get a list of all connections in the connection config. Connections returned
|
|
||||||
* are sorted first by whether they were found in the user/workspace settings,
|
|
||||||
* and next alphabetically by profile/server name.
|
|
||||||
*/
|
|
||||||
public getConnections(getWorkspaceConnections: boolean): ConnectionProfile[] {
|
|
||||||
let profiles: IConnectionProfileStore[] = [];
|
let profiles: IConnectionProfileStore[] = [];
|
||||||
//TODO: have to figure out how to sort connections for all provider
|
//TODO: have to figure out how to sort connections for all provider
|
||||||
// Read from user settings
|
// Read from user settings
|
||||||
@@ -207,7 +202,16 @@ export class ConnectionConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let connectionProfiles = profiles.map(p => {
|
return profiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of all connections in the connection config. Connections returned
|
||||||
|
* are sorted first by whether they were found in the user/workspace settings,
|
||||||
|
* and next alphabetically by profile/server name.
|
||||||
|
*/
|
||||||
|
public getConnections(getWorkspaceConnections: boolean): ConnectionProfile[] {
|
||||||
|
let connectionProfiles = this.getIConnectionProfileStores(getWorkspaceConnections).map(p => {
|
||||||
return ConnectionProfile.createFromStoredProfile(p, this._capabilitiesService);
|
return ConnectionProfile.createFromStoredProfile(p, this._capabilitiesService);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -277,9 +281,14 @@ export class ConnectionConfig {
|
|||||||
* Returns true if connection can be moved to another group
|
* Returns true if connection can be moved to another group
|
||||||
*/
|
*/
|
||||||
public canChangeConnectionConfig(profile: ConnectionProfile, newGroupID: string): boolean {
|
public canChangeConnectionConfig(profile: ConnectionProfile, newGroupID: string): boolean {
|
||||||
let profiles = this.getConnections(true);
|
let profiles = this.getIConnectionProfileStores(true);
|
||||||
let existingProfile = find(profiles, p => p.getConnectionInfoId() === profile.getConnectionInfoId()
|
let existingProfile = find(profiles, p =>
|
||||||
&& p.groupId === newGroupID);
|
p.providerName === profile.providerName &&
|
||||||
|
p.options.authenticationType === profile.options.authenticationType &&
|
||||||
|
p.options.database === profile.options.database &&
|
||||||
|
p.options.server === profile.options.server &&
|
||||||
|
p.options.user === profile.options.user &&
|
||||||
|
p.groupId === newGroupID);
|
||||||
return existingProfile === undefined;
|
return existingProfile === undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,8 +304,7 @@ export class ConnectionConfig {
|
|||||||
profiles.push(ConnectionProfile.convertToProfileStore(this._capabilitiesService, profile));
|
profiles.push(ConnectionProfile.convertToProfileStore(this._capabilitiesService, profile));
|
||||||
} else {
|
} else {
|
||||||
profiles.forEach((value) => {
|
profiles.forEach((value) => {
|
||||||
let configProf = ConnectionProfile.createFromStoredProfile(value, this._capabilitiesService);
|
if (value.id === profile.id) {
|
||||||
if (configProf.getOptionsKey() === profile.getOptionsKey()) {
|
|
||||||
value.groupId = newGroupID;
|
value.groupId = newGroupID;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -81,14 +81,31 @@ export class ServerTreeDragAndDrop implements IDragAndDrop {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public canDragToConnectionProfileGroup(source: any, targetConnectionProfileGroup: ConnectionProfileGroup) {
|
||||||
|
let canDragOver: boolean = true;
|
||||||
|
|
||||||
|
if (source instanceof ConnectionProfile) {
|
||||||
|
if (!this._connectionManagementService.canChangeConnectionConfig(source, targetConnectionProfileGroup.id)) {
|
||||||
|
canDragOver = false;
|
||||||
|
}
|
||||||
|
} else if (source instanceof ConnectionProfileGroup) {
|
||||||
|
// Dropping a group to itself or its descendants nodes is not allowed
|
||||||
|
// to avoid creating a circular structure.
|
||||||
|
canDragOver = source.id !== targetConnectionProfileGroup.id && !source.isAncestorOf(targetConnectionProfileGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
return canDragOver;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a DragOverReaction indicating whether sources can be
|
* Returns a DragOverReaction indicating whether sources can be
|
||||||
* dropped into target or some parent of the target.
|
* dropped into target or some parent of the target.
|
||||||
* Returns DRAG_OVER_ACCEPT_BUBBLE_DOWN when element is a connection group or connection
|
* Returns DRAG_OVER_ACCEPT_BUBBLE_DOWN when element is a connection group or connection
|
||||||
*/
|
*/
|
||||||
public onDragOver(tree: ITree, data: IDragAndDropData, targetElement: any, originalEvent: DragMouseEvent): IDragOverReaction {
|
public onDragOver(tree: ITree, data: IDragAndDropData, targetElement: any, originalEvent: DragMouseEvent): IDragOverReaction {
|
||||||
|
|
||||||
let canDragOver: boolean = true;
|
let canDragOver: boolean = true;
|
||||||
|
|
||||||
if (targetElement instanceof ConnectionProfile || targetElement instanceof ConnectionProfileGroup) {
|
if (targetElement instanceof ConnectionProfile || targetElement instanceof ConnectionProfileGroup) {
|
||||||
let targetConnectionProfileGroup = this.getTargetGroup(targetElement);
|
let targetConnectionProfileGroup = this.getTargetGroup(targetElement);
|
||||||
// Verify if the connection can be moved to the target group
|
// Verify if the connection can be moved to the target group
|
||||||
|
|||||||
Reference in New Issue
Block a user