revert async changes (#22649)

This commit is contained in:
Aasim Khan
2023-04-06 13:33:29 -07:00
committed by GitHub
parent 094562ea9c
commit 4f341a0989
8 changed files with 107 additions and 632 deletions

View File

@@ -8,7 +8,7 @@ import * as WorkbenchUtils from 'sql/workbench/common/sqlWorkbenchUtils';
import {
IConnectionManagementService, INewConnectionParams,
ConnectionType, IConnectableInput, IConnectionCompletionOptions, IConnectionCallbacks,
IConnectionParams, IConnectionResult, RunQueryOnConnectionMode, ConnectionElementMovedParams, ConnectionProfileEditedParams
IConnectionParams, IConnectionResult, RunQueryOnConnectionMode
} from 'sql/platform/connection/common/connectionManagement';
import { ConnectionStore } from 'sql/platform/connection/common/connectionStore';
import { ConnectionManagementInfo } from 'sql/platform/connection/common/connectionManagementInfo';
@@ -76,17 +76,6 @@ export class ConnectionManagementService extends Disposable implements IConnecti
private _connectionGlobalStatus = new ConnectionGlobalStatus(this._notificationService);
private _uriToReconnectPromiseMap: { [uri: string]: Promise<IConnectionResult> } = {};
private _onConnectionProfileCreated = new Emitter<ConnectionProfile>();
private _onConnectionProfileDeleted = new Emitter<ConnectionProfile>();
private _onConnectionProfileEdited = new Emitter<ConnectionProfileEditedParams>();
private _onConnectionProfileMoved = new Emitter<ConnectionElementMovedParams>();
private _onConnectionProfileConnected = new Emitter<ConnectionProfile>();
private _onConnectionProfileDisconnected = new Emitter<ConnectionProfile>();
private _onConnectionProfileGroupCreated = new Emitter<ConnectionProfileGroup>();
private _onConnectionProfileGroupDeleted = new Emitter<ConnectionProfileGroup>();
private _onConnectionProfileGroupEdited = new Emitter<ConnectionProfileGroup>();
private _onConnectionProfileGroupMoved = new Emitter<ConnectionElementMovedParams>();
private _mementoContext: Memento;
private _mementoObj: MementoObject;
private _connectionStore: ConnectionStore;
@@ -202,49 +191,6 @@ export class ConnectionManagementService extends Disposable implements IConnecti
return this._onLanguageFlavorChanged.event;
}
/**
* Async tree event emitters
*/
public get onConnectionProfileCreated(): Event<ConnectionProfile> {
return this._onConnectionProfileCreated.event;
}
public get onConnectionProfileEdited(): Event<ConnectionProfileEditedParams> {
return this._onConnectionProfileEdited.event;
}
public get onConnectionProfileDeleted(): Event<ConnectionProfile> {
return this._onConnectionProfileDeleted.event;
}
public get onConnectionProfileMoved(): Event<ConnectionElementMovedParams> {
return this._onConnectionProfileMoved.event;
}
public get onConnectionProfileConnected(): Event<ConnectionProfile> {
return this._onConnectionProfileConnected.event;
}
public get onConnectionProfileDisconnected(): Event<ConnectionProfile> {
return this._onConnectionProfileDisconnected.event;
}
public get onConnectionProfileGroupCreated(): Event<ConnectionProfileGroup> {
return this._onConnectionProfileGroupCreated.event;
}
public get onConnectionProfileGroupDeleted(): Event<ConnectionProfileGroup> {
return this._onConnectionProfileGroupDeleted.event;
}
public get onConnectionProfileGroupEdited(): Event<ConnectionProfileGroup> {
return this._onConnectionProfileGroupEdited.event;
}
public get onConnectionProfileGroupMoved(): Event<ConnectionElementMovedParams> {
return this._onConnectionProfileGroupMoved.event;
}
public get providerNameToDisplayNameMap(): { readonly [providerDisplayName: string]: string } {
return this._providerNameToDisplayNameMap;
}
@@ -593,18 +539,6 @@ export class ConnectionManagementService extends Disposable implements IConnecti
await this.saveToSettings(uri, connection, matcher).then(value => {
this._onAddConnectionProfile.fire(connection);
if (isEdit) {
this._onConnectionProfileEdited.fire({
oldProfileId: options.params.oldProfileId,
profile: <ConnectionProfile>connection
});
} else {
if (options.params === undefined) {
this._onConnectionProfileConnected.fire(<ConnectionProfile>connection);
} else {
this._onConnectionProfileCreated.fire(<ConnectionProfile>connection);
}
}
this.doActionsAfterConnectionComplete(value, options);
});
} else {
@@ -782,22 +716,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti
}
public getConnectionGroups(providers?: string[]): ConnectionProfileGroup[] {
const groups = this._connectionStore.getConnectionProfileGroups(false, providers);
return groups;
}
public getConnectionGroupById(id: string): ConnectionProfileGroup | undefined {
const groups = this.getConnectionGroups();
for (let group of groups) {
if (group.id === id) {
return group;
}
const subgroup = ConnectionProfileGroup.getSubgroups(group).find(g => g.id === id);
if (subgroup) {
return subgroup;
}
}
return undefined;
return this._connectionStore.getConnectionProfileGroups(false, providers);
}
public getRecentConnections(providers?: string[]): ConnectionProfile[] {
@@ -826,15 +745,10 @@ export class ConnectionManagementService extends Disposable implements IConnecti
}
}
public saveProfileGroup(group: IConnectionProfileGroup): Promise<string> {
public saveProfileGroup(profile: IConnectionProfileGroup): Promise<string> {
this._telemetryService.sendActionEvent(TelemetryKeys.TelemetryView.Shell, TelemetryKeys.TelemetryAction.AddServerGroup);
return this._connectionStore.saveProfileGroup(group).then(groupId => {
return this._connectionStore.saveProfileGroup(profile).then(groupId => {
this._onAddConnectionProfile.fire(undefined);
//Getting id for the new profile group
group.id = groupId;
const parentGroup = this.getConnectionGroupById(group.parentId);
this._onConnectionProfileGroupCreated.fire(ConnectionProfileGroup.createConnectionProfileGroup(group, parentGroup));
return groupId;
});
}
@@ -1310,30 +1224,21 @@ export class ConnectionManagementService extends Disposable implements IConnecti
public onIntelliSenseCacheComplete(handle: number, connectionUri: string): void {
}
public async changeGroupIdForConnectionGroup(source: ConnectionProfileGroup, target: ConnectionProfileGroup): Promise<void> {
public changeGroupIdForConnectionGroup(source: ConnectionProfileGroup, target: ConnectionProfileGroup): Promise<void> {
this._telemetryService.sendActionEvent(TelemetryKeys.TelemetryView.Shell, TelemetryKeys.TelemetryAction.MoveServerConnection);
await this._connectionStore.changeGroupIdForConnectionGroup(source, target);
this._onConnectionProfileGroupMoved.fire({
source: source,
oldGroupId: source.parentId,
newGroupId: target.id
});
return this._connectionStore.changeGroupIdForConnectionGroup(source, target);
}
public async changeGroupIdForConnection(source: ConnectionProfile, targetGroupId: string): Promise<void> {
const oldProfileId = source.groupId;
public changeGroupIdForConnection(source: ConnectionProfile, targetGroupId: string): Promise<void> {
let id = Utils.generateUri(source);
this._telemetryService.sendActionEvent(TelemetryKeys.TelemetryView.Shell, TelemetryKeys.TelemetryAction.MoveServerGroup);
await this._connectionStore.changeGroupIdForConnection(source, targetGroupId)
this._onAddConnectionProfile.fire(source);
if (id && targetGroupId) {
source.groupId = targetGroupId;
}
this.changeConnectionUri(Utils.generateUri(source), id);
this._onConnectionProfileMoved.fire({
source: source,
oldGroupId: oldProfileId,
newGroupId: targetGroupId,
return this._connectionStore.changeGroupIdForConnection(source, targetGroupId).then(result => {
this._onAddConnectionProfile.fire(source);
if (id && targetGroupId) {
source.groupId = targetGroupId;
}
// change the connection uri with the new group so that connection does not appear as disconnected in OE.
this.changeConnectionUri(Utils.generateUri(source), id);
});
}
@@ -1603,7 +1508,6 @@ export class ConnectionManagementService extends Disposable implements IConnecti
public editGroup(group: ConnectionProfileGroup): Promise<void> {
return this._connectionStore.editGroup(group).then(groupId => {
this._onAddConnectionProfile.fire(undefined);
this._onConnectionProfileGroupEdited.fire(group);
});
}
@@ -1611,7 +1515,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti
* Deletes a connection from registered servers.
* Disconnects a connection before removing from settings.
*/
public async deleteConnection(connection: ConnectionProfile): Promise<boolean> {
public deleteConnection(connection: ConnectionProfile): Promise<boolean> {
this._telemetryService.createActionEvent(TelemetryKeys.TelemetryView.Shell, TelemetryKeys.TelemetryAction.DeleteConnection)
.withAdditionalProperties({
provider: connection.providerName
@@ -1624,7 +1528,6 @@ export class ConnectionManagementService extends Disposable implements IConnecti
// Remove profile from configuration
return this._connectionStore.deleteConnectionFromConfiguration(connection).then(() => {
this._onDeleteConnectionProfile.fire();
this._onConnectionProfileDeleted.fire(connection);
return true;
});
@@ -1636,7 +1539,6 @@ export class ConnectionManagementService extends Disposable implements IConnecti
// Remove disconnected profile from settings
return this._connectionStore.deleteConnectionFromConfiguration(connection).then(() => {
this._onDeleteConnectionProfile.fire();
this._onConnectionProfileDeleted.fire(connection);
return true;
});
}
@@ -1665,7 +1567,6 @@ export class ConnectionManagementService extends Disposable implements IConnecti
// Remove profiles and groups from config
return this._connectionStore.deleteGroupFromConfiguration(group).then(() => {
this._onDeleteConnectionProfile.fire();
this._onConnectionProfileGroupDeleted.fire(group);
return true;
});
}).catch(() => false);