remove circular dependency between server group and connection management (#6916)

This commit is contained in:
Anthony Dresser
2019-08-23 14:53:54 -07:00
committed by GitHub
parent d6950fa4b7
commit 5b9a08359d
10 changed files with 30 additions and 71 deletions

View File

@@ -9,6 +9,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { ConnectionProviderProperties } from 'sql/workbench/parts/connection/common/connectionProviderExtension';
import { ConnectionController } from 'sql/workbench/services/connection/browser/connectionController';
import { CmsConnectionWidget } from 'sql/workbench/services/connection/browser/cmsConnectionWidget';
import { IServerGroupController } from 'sql/platform/serverGroup/common/serverGroupController';
/**
* Connection Controller for CMS Connections
@@ -16,12 +17,14 @@ import { CmsConnectionWidget } from 'sql/workbench/services/connection/browser/c
export class CmsConnectionController extends ConnectionController {
constructor(
connectionManagementService: IConnectionManagementService,
connectionProperties: ConnectionProviderProperties,
callback: IConnectionComponentCallbacks,
providerName: string,
@IInstantiationService _instantiationService: IInstantiationService) {
super(connectionManagementService, connectionProperties, callback, providerName, _instantiationService);
@IConnectionManagementService _connectionManagementService: IConnectionManagementService,
@IInstantiationService _instantiationService: IInstantiationService,
@IServerGroupController _serverGroupController: IServerGroupController
) {
super(connectionProperties, callback, providerName, _connectionManagementService, _instantiationService, _serverGroupController);
let specialOptions = this._providerOptions.filter(
(property) => (property.specialValueType !== null && property.specialValueType !== undefined));
this._connectionWidget = this._instantiationService.createInstance(CmsConnectionWidget, specialOptions, {
@@ -40,4 +43,4 @@ export class CmsConnectionController extends ConnectionController {
this._databaseCache = new Map<string, string[]>();
this._connectionWidget.createConnectionWidget(container, authTypeChanged);
}
}
}

View File

@@ -15,9 +15,9 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { ConnectionOptionSpecialType } from 'sql/workbench/api/common/sqlExtHostTypes';
import { ConnectionProviderProperties } from 'sql/workbench/parts/connection/common/connectionProviderExtension';
import { ConnectionWidget } from 'sql/workbench/services/connection/browser/connectionWidget';
import { IServerGroupController } from 'sql/platform/serverGroup/common/serverGroupController';
export class ConnectionController implements IConnectionComponentController {
private _connectionManagementService: IConnectionManagementService;
private _advancedController: AdvancedPropertiesController;
private _model: IConnectionProfile;
private _providerName: string;
@@ -28,12 +28,13 @@ export class ConnectionController implements IConnectionComponentController {
protected _databaseCache = new Map<string, string[]>();
constructor(
connectionManagementService: IConnectionManagementService,
connectionProperties: ConnectionProviderProperties,
callback: IConnectionComponentCallbacks,
providerName: string,
@IInstantiationService protected _instantiationService: IInstantiationService) {
this._connectionManagementService = connectionManagementService;
@IConnectionManagementService protected readonly _connectionManagementService: IConnectionManagementService,
@IInstantiationService protected readonly _instantiationService: IInstantiationService,
@IServerGroupController protected readonly _serverGroupController: IServerGroupController
) {
this._callback = callback;
this._providerOptions = connectionProperties.connectionOptions;
let specialOptions = this._providerOptions.filter(
@@ -89,7 +90,7 @@ export class ConnectionController implements IConnectionComponentController {
}
protected onCreateNewServerGroup(): void {
this._connectionManagementService.showCreateServerGroupDialog({
this._serverGroupController.showCreateGroupDialog({
onAddGroup: (groupName) => this._connectionWidget.updateServerGroup(this.getAllServerGroups(), groupName),
onClose: () => this._connectionWidget.focusOnServerGroup()
});

View File

@@ -276,14 +276,12 @@ export class ConnectionDialogService implements IConnectionDialogService {
if (providerName === Constants.cmsProviderName) {
this._connectionControllerMap[providerName] =
this._instantiationService.createInstance(CmsConnectionController,
this._connectionManagementService,
this._capabilitiesService.getCapabilities(providerName).connection, {
onSetConnectButton: (enable: boolean) => this.handleSetConnectButtonEnable(enable)
}, providerName);
} else {
this._connectionControllerMap[providerName] =
this._instantiationService.createInstance(ConnectionController,
this._connectionManagementService,
this._capabilitiesService.getCapabilities(providerName).connection, {
onSetConnectButton: (enable: boolean) => this.handleSetConnectButtonEnable(enable)
}, providerName);