mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-19 09:35:36 -05:00
Fixing async server tree (#22511)
* Changing look of new OE * Fixing styling * Fixing moving of connected profile * Fixing drag and drop where treenodes delete connection nodes * Fixing Deleting and disconnecting in AsyncServerTree * Adding constant for OE timeout * Updated interfaces * Removing test compilation errors * Fixing most events in async server tree * Fixing connection pane styling * Fixing find node function * Fixing some more operations * Fixing some ops * All operations done * Fixed active connections * Fixed data source * Adding support for setting parents * code cleanup * Fixing icon styling issues * Fix errors * Fixing comment * Fixing spacing * Adding explanation to OE service. * Reverting server delegate changes * Reverting styling * reverting more styling change * reverting more styling * Fixing has children * Fixing drag and drop to tree nodes * fixing drag and drop * reverting timing * fixing drag and drop * cleaning some code * Fixed server and group moving * spell check * consolidating some logic * Fixed whitespace * fixing moving to root group
This commit is contained in:
@@ -8,7 +8,7 @@ import * as WorkbenchUtils from 'sql/workbench/common/sqlWorkbenchUtils';
|
||||
import {
|
||||
IConnectionManagementService, INewConnectionParams,
|
||||
ConnectionType, IConnectableInput, IConnectionCompletionOptions, IConnectionCallbacks,
|
||||
IConnectionParams, IConnectionResult, RunQueryOnConnectionMode
|
||||
IConnectionParams, IConnectionResult, RunQueryOnConnectionMode, ConnectionElementMovedParams, ConnectionProfileEditedParams
|
||||
} from 'sql/platform/connection/common/connectionManagement';
|
||||
import { ConnectionStore } from 'sql/platform/connection/common/connectionStore';
|
||||
import { ConnectionManagementInfo } from 'sql/platform/connection/common/connectionManagementInfo';
|
||||
@@ -76,6 +76,17 @@ 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;
|
||||
@@ -191,6 +202,49 @@ 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;
|
||||
}
|
||||
@@ -539,6 +593,18 @@ 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 {
|
||||
@@ -716,7 +782,22 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
}
|
||||
|
||||
public getConnectionGroups(providers?: string[]): ConnectionProfileGroup[] {
|
||||
return this._connectionStore.getConnectionProfileGroups(false, providers);
|
||||
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;
|
||||
}
|
||||
|
||||
public getRecentConnections(providers?: string[]): ConnectionProfile[] {
|
||||
@@ -745,10 +826,15 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
}
|
||||
}
|
||||
|
||||
public saveProfileGroup(profile: IConnectionProfileGroup): Promise<string> {
|
||||
public saveProfileGroup(group: IConnectionProfileGroup): Promise<string> {
|
||||
this._telemetryService.sendActionEvent(TelemetryKeys.TelemetryView.Shell, TelemetryKeys.TelemetryAction.AddServerGroup);
|
||||
return this._connectionStore.saveProfileGroup(profile).then(groupId => {
|
||||
return this._connectionStore.saveProfileGroup(group).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;
|
||||
});
|
||||
}
|
||||
@@ -1224,21 +1310,30 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
public onIntelliSenseCacheComplete(handle: number, connectionUri: string): void {
|
||||
}
|
||||
|
||||
public changeGroupIdForConnectionGroup(source: ConnectionProfileGroup, target: ConnectionProfileGroup): Promise<void> {
|
||||
public async changeGroupIdForConnectionGroup(source: ConnectionProfileGroup, target: ConnectionProfileGroup): Promise<void> {
|
||||
this._telemetryService.sendActionEvent(TelemetryKeys.TelemetryView.Shell, TelemetryKeys.TelemetryAction.MoveServerConnection);
|
||||
return this._connectionStore.changeGroupIdForConnectionGroup(source, target);
|
||||
await this._connectionStore.changeGroupIdForConnectionGroup(source, target);
|
||||
this._onConnectionProfileGroupMoved.fire({
|
||||
source: source,
|
||||
oldGroupId: source.parentId,
|
||||
newGroupId: target.id
|
||||
});
|
||||
}
|
||||
|
||||
public changeGroupIdForConnection(source: ConnectionProfile, targetGroupId: string): Promise<void> {
|
||||
public async changeGroupIdForConnection(source: ConnectionProfile, targetGroupId: string): Promise<void> {
|
||||
const oldProfileId = source.groupId;
|
||||
let id = Utils.generateUri(source);
|
||||
this._telemetryService.sendActionEvent(TelemetryKeys.TelemetryView.Shell, TelemetryKeys.TelemetryAction.MoveServerGroup);
|
||||
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);
|
||||
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,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1508,6 +1603,7 @@ 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);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1515,7 +1611,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
* Deletes a connection from registered servers.
|
||||
* Disconnects a connection before removing from settings.
|
||||
*/
|
||||
public deleteConnection(connection: ConnectionProfile): Promise<boolean> {
|
||||
public async deleteConnection(connection: ConnectionProfile): Promise<boolean> {
|
||||
this._telemetryService.createActionEvent(TelemetryKeys.TelemetryView.Shell, TelemetryKeys.TelemetryAction.DeleteConnection)
|
||||
.withAdditionalProperties({
|
||||
provider: connection.providerName
|
||||
@@ -1528,6 +1624,7 @@ 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;
|
||||
});
|
||||
|
||||
@@ -1539,6 +1636,7 @@ 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;
|
||||
});
|
||||
}
|
||||
@@ -1567,6 +1665,7 @@ 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);
|
||||
|
||||
Reference in New Issue
Block a user