mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Put back code to refresh tree when capabilities provider gets new capabilities (#4475)
This commit is contained in:
@@ -32,6 +32,7 @@ import { TreeNode, TreeItemCollapsibleState } from 'sql/parts/objectExplorer/com
|
|||||||
import { SERVER_GROUP_CONFIG, SERVER_GROUP_AUTOEXPAND_CONFIG } from 'sql/parts/objectExplorer/serverGroupDialog/serverGroup.contribution';
|
import { SERVER_GROUP_CONFIG, SERVER_GROUP_AUTOEXPAND_CONFIG } from 'sql/parts/objectExplorer/serverGroupDialog/serverGroup.contribution';
|
||||||
import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMessageService';
|
import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMessageService';
|
||||||
import { ServerTreeActionProvider } from 'sql/parts/objectExplorer/viewlet/serverTreeActionProvider';
|
import { ServerTreeActionProvider } from 'sql/parts/objectExplorer/viewlet/serverTreeActionProvider';
|
||||||
|
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||||
|
|
||||||
const $ = builder.$;
|
const $ = builder.$;
|
||||||
|
|
||||||
@@ -54,7 +55,8 @@ export class ServerTreeView {
|
|||||||
@IObjectExplorerService private _objectExplorerService: IObjectExplorerService,
|
@IObjectExplorerService private _objectExplorerService: IObjectExplorerService,
|
||||||
@IThemeService private _themeService: IThemeService,
|
@IThemeService private _themeService: IThemeService,
|
||||||
@IErrorMessageService private _errorMessageService: IErrorMessageService,
|
@IErrorMessageService private _errorMessageService: IErrorMessageService,
|
||||||
@IConfigurationService private _configurationService: IConfigurationService
|
@IConfigurationService private _configurationService: IConfigurationService,
|
||||||
|
@ICapabilitiesService capabilitiesService: ICapabilitiesService
|
||||||
) {
|
) {
|
||||||
this._activeConnectionsFilterAction = this._instantiationService.createInstance(
|
this._activeConnectionsFilterAction = this._instantiationService.createInstance(
|
||||||
ActiveConnectionsFilterAction,
|
ActiveConnectionsFilterAction,
|
||||||
@@ -64,6 +66,12 @@ export class ServerTreeView {
|
|||||||
this._treeSelectionHandler = this._instantiationService.createInstance(TreeSelectionHandler);
|
this._treeSelectionHandler = this._instantiationService.createInstance(TreeSelectionHandler);
|
||||||
this._onSelectionOrFocusChange = new Emitter();
|
this._onSelectionOrFocusChange = new Emitter();
|
||||||
this._actionProvider = this._instantiationService.createInstance(ServerTreeActionProvider);
|
this._actionProvider = this._instantiationService.createInstance(ServerTreeActionProvider);
|
||||||
|
capabilitiesService.onCapabilitiesRegistered(() => {
|
||||||
|
if (this._connectionManagementService.hasRegisteredServers()) {
|
||||||
|
this.refreshTree();
|
||||||
|
this._treeSelectionHandler.onTreeActionStateChange(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ suite('SQL Connection Tree Action tests', () => {
|
|||||||
return new TPromise((resolve) => resolve({}));
|
return new TPromise((resolve) => resolve({}));
|
||||||
});
|
});
|
||||||
|
|
||||||
let serverTreeView = TypeMoq.Mock.ofType(ServerTreeView, TypeMoq.MockBehavior.Strict, undefined, instantiationService.object, undefined, undefined, undefined);
|
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.showFilteredTree(TypeMoq.It.isAnyString()));
|
||||||
serverTreeView.setup(x => x.refreshTree());
|
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, connectionManagementService.object);
|
||||||
@@ -222,7 +222,7 @@ suite('SQL Connection Tree Action tests', () => {
|
|||||||
return new TPromise((resolve) => resolve({}));
|
return new TPromise((resolve) => resolve({}));
|
||||||
});
|
});
|
||||||
|
|
||||||
let serverTreeView = TypeMoq.Mock.ofType(ServerTreeView, TypeMoq.MockBehavior.Strict, undefined, instantiationService.object, undefined, undefined, undefined);
|
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.showFilteredTree(TypeMoq.It.isAnyString()));
|
||||||
serverTreeView.setup(x => x.refreshTree());
|
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, connectionManagementService.object);
|
||||||
@@ -240,7 +240,7 @@ suite('SQL Connection Tree Action tests', () => {
|
|||||||
return new TPromise((resolve) => resolve({}));
|
return new TPromise((resolve) => resolve({}));
|
||||||
});
|
});
|
||||||
|
|
||||||
let serverTreeView = TypeMoq.Mock.ofType(ServerTreeView, TypeMoq.MockBehavior.Strict, undefined, instantiationService.object, undefined, undefined, undefined);
|
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.showFilteredTree(TypeMoq.It.isAnyString()));
|
||||||
serverTreeView.setup(x => x.refreshTree());
|
serverTreeView.setup(x => x.refreshTree());
|
||||||
let connectionTreeAction: RecentConnectionsFilterAction = new RecentConnectionsFilterAction(RecentConnectionsFilterAction.ID, RecentConnectionsFilterAction.LABEL, serverTreeView.object, connectionManagementService.object);
|
let connectionTreeAction: RecentConnectionsFilterAction = new RecentConnectionsFilterAction(RecentConnectionsFilterAction.ID, RecentConnectionsFilterAction.LABEL, serverTreeView.object, connectionManagementService.object);
|
||||||
@@ -257,7 +257,7 @@ suite('SQL Connection Tree Action tests', () => {
|
|||||||
return new TPromise((resolve) => resolve({}));
|
return new TPromise((resolve) => resolve({}));
|
||||||
});
|
});
|
||||||
|
|
||||||
let serverTreeView = TypeMoq.Mock.ofType(ServerTreeView, TypeMoq.MockBehavior.Strict, undefined, instantiationService.object, undefined, undefined, undefined);
|
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.showFilteredTree(TypeMoq.It.isAnyString()));
|
||||||
serverTreeView.setup(x => x.refreshTree());
|
serverTreeView.setup(x => x.refreshTree());
|
||||||
let connectionTreeAction: RecentConnectionsFilterAction = new RecentConnectionsFilterAction(RecentConnectionsFilterAction.ID, RecentConnectionsFilterAction.LABEL, serverTreeView.object, connectionManagementService.object);
|
let connectionTreeAction: RecentConnectionsFilterAction = new RecentConnectionsFilterAction(RecentConnectionsFilterAction.ID, RecentConnectionsFilterAction.LABEL, serverTreeView.object, connectionManagementService.object);
|
||||||
|
|||||||
@@ -14,18 +14,21 @@ import { TestInstantiationService } from 'vs/platform/instantiation/test/common/
|
|||||||
import { TestStorageService } from 'vs/workbench/test/workbenchTestServices';
|
import { TestStorageService } from 'vs/workbench/test/workbenchTestServices';
|
||||||
|
|
||||||
import * as TypeMoq from 'typemoq';
|
import * as TypeMoq from 'typemoq';
|
||||||
|
import { CapabilitiesTestService } from 'sqltest/stubs/capabilitiesTestService';
|
||||||
|
|
||||||
suite('ServerTreeView onAddConnectionProfile handler tests', () => {
|
suite('ServerTreeView onAddConnectionProfile handler tests', () => {
|
||||||
|
|
||||||
let serverTreeView: ServerTreeView;
|
let serverTreeView: ServerTreeView;
|
||||||
let mockTree: TypeMoq.Mock<Tree>;
|
let mockTree: TypeMoq.Mock<Tree>;
|
||||||
let mockRefreshTreeMethod: TypeMoq.Mock<Function>;
|
let mockRefreshTreeMethod: TypeMoq.Mock<Function>;
|
||||||
|
let capabilitiesService = new CapabilitiesTestService();
|
||||||
|
|
||||||
setup(() => {
|
setup(() => {
|
||||||
let instantiationService = new TestInstantiationService();
|
let instantiationService = new TestInstantiationService();
|
||||||
let mockConnectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Strict, {}, {}, new TestStorageService());
|
let mockConnectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Strict, {}, {}, new TestStorageService());
|
||||||
mockConnectionManagementService.setup(x => x.getConnectionGroups()).returns(x => []);
|
mockConnectionManagementService.setup(x => x.getConnectionGroups()).returns(x => []);
|
||||||
serverTreeView = new ServerTreeView(mockConnectionManagementService.object, instantiationService, undefined, undefined, undefined, undefined);
|
mockConnectionManagementService.setup(x => x.hasRegisteredServers()).returns(() => true);
|
||||||
|
serverTreeView = new ServerTreeView(mockConnectionManagementService.object, instantiationService, undefined, undefined, undefined, undefined, capabilitiesService);
|
||||||
let tree = <Tree>{
|
let tree = <Tree>{
|
||||||
clearSelection() { },
|
clearSelection() { },
|
||||||
getSelection() { },
|
getSelection() { },
|
||||||
@@ -91,4 +94,9 @@ suite('ServerTreeView onAddConnectionProfile handler tests', () => {
|
|||||||
mockTree.verify(x => x.clearSelection(), TypeMoq.Times.never());
|
mockTree.verify(x => x.clearSelection(), TypeMoq.Times.never());
|
||||||
mockTree.verify(x => x.select(TypeMoq.It.isAny()), TypeMoq.Times.never());
|
mockTree.verify(x => x.select(TypeMoq.It.isAny()), TypeMoq.Times.never());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('The tree refreshes when new capabilities are registered', () => {
|
||||||
|
capabilitiesService.fireCapabilitiesRegistered(undefined);
|
||||||
|
mockRefreshTreeMethod.verify(x => x(), TypeMoq.Times.once());
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -138,6 +138,10 @@ export class CapabilitiesTestService implements ICapabilitiesService {
|
|||||||
return Promise.resolve(null);
|
return Promise.resolve(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public fireCapabilitiesRegistered(providerFeatures: ProviderFeatures): void {
|
||||||
|
this._onCapabilitiesRegistered.fire(providerFeatures);
|
||||||
|
}
|
||||||
|
|
||||||
private _onCapabilitiesRegistered = new Emitter<ProviderFeatures>();
|
private _onCapabilitiesRegistered = new Emitter<ProviderFeatures>();
|
||||||
public readonly onCapabilitiesRegistered = this._onCapabilitiesRegistered.event;
|
public readonly onCapabilitiesRegistered = this._onCapabilitiesRegistered.event;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user