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

@@ -21,6 +21,7 @@ import { ObjectExplorerActionsContext } from 'sql/workbench/parts/objectExplorer
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMessageService';
import { UNSAVED_GROUP_ID } from 'sql/platform/connection/common/constants';
import { IServerGroupController } from 'sql/platform/serverGroup/common/serverGroupController';
export class RefreshAction extends Action {
@@ -173,14 +174,14 @@ export class AddServerGroupAction extends Action {
constructor(
id: string,
label: string,
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService
@IServerGroupController private readonly serverGroupController: IServerGroupController
) {
super(id, label);
this.class = 'add-server-group-action';
}
public run(): Promise<boolean> {
this._connectionManagementService.showCreateServerGroupDialog();
this.serverGroupController.showCreateGroupDialog();
return Promise.resolve(true);
}
}
@@ -196,14 +197,14 @@ export class EditServerGroupAction extends Action {
id: string,
label: string,
private _group: ConnectionProfileGroup,
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService
@IServerGroupController private readonly serverGroupController: IServerGroupController
) {
super(id, label);
this.class = 'edit-server-group-action';
}
public run(): Promise<boolean> {
this._connectionManagementService.showEditServerGroupDialog(this._group);
this.serverGroupController.showEditGroupDialog(this._group);
return Promise.resolve(true);
}
}
@@ -231,8 +232,7 @@ export class ActiveConnectionsFilterAction extends Action {
constructor(
id: string,
label: string,
private view: ServerTreeView,
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService
private view: ServerTreeView
) {
super(id, label);
this.class = ActiveConnectionsFilterAction.enabledClass;

View File

@@ -220,7 +220,7 @@ suite('SQL Connection Tree Action tests', () => {
let serverTreeView = TypeMoq.Mock.ofType(ServerTreeView, TypeMoq.MockBehavior.Strict, undefined, instantiationService.object, undefined, undefined, undefined, undefined, capabilitiesService);
serverTreeView.setup(x => x.showFilteredTree(TypeMoq.It.isAnyString()));
serverTreeView.setup(x => x.refreshTree());
let connectionTreeAction: ActiveConnectionsFilterAction = new ActiveConnectionsFilterAction(ActiveConnectionsFilterAction.ID, ActiveConnectionsFilterAction.LABEL, serverTreeView.object, connectionManagementService.object);
let connectionTreeAction: ActiveConnectionsFilterAction = new ActiveConnectionsFilterAction(ActiveConnectionsFilterAction.ID, ActiveConnectionsFilterAction.LABEL, serverTreeView.object);
connectionTreeAction.run().then((value) => {
serverTreeView.verify(x => x.showFilteredTree('active'), TypeMoq.Times.once());
}).then(() => done(), (err) => done(err));
@@ -237,7 +237,7 @@ suite('SQL Connection Tree Action tests', () => {
let serverTreeView = TypeMoq.Mock.ofType(ServerTreeView, TypeMoq.MockBehavior.Strict, undefined, instantiationService.object, undefined, undefined, undefined, undefined, capabilitiesService);
serverTreeView.setup(x => x.showFilteredTree(TypeMoq.It.isAnyString()));
serverTreeView.setup(x => x.refreshTree());
let connectionTreeAction: ActiveConnectionsFilterAction = new ActiveConnectionsFilterAction(ActiveConnectionsFilterAction.ID, ActiveConnectionsFilterAction.LABEL, serverTreeView.object, connectionManagementService.object);
let connectionTreeAction: ActiveConnectionsFilterAction = new ActiveConnectionsFilterAction(ActiveConnectionsFilterAction.ID, ActiveConnectionsFilterAction.LABEL, serverTreeView.object);
connectionTreeAction.isSet = true;
connectionTreeAction.run().then((value) => {
serverTreeView.verify(x => x.refreshTree(), TypeMoq.Times.once());