diff --git a/src/sql/workbench/contrib/objectExplorer/browser/serverTreeView.ts b/src/sql/workbench/contrib/objectExplorer/browser/serverTreeView.ts index ecbf79c69c..26b6226915 100644 --- a/src/sql/workbench/contrib/objectExplorer/browser/serverTreeView.ts +++ b/src/sql/workbench/contrib/objectExplorer/browser/serverTreeView.ts @@ -44,6 +44,9 @@ import { CONNECTIONS_SORT_BY_CONFIG_KEY } from 'sql/platform/connection/common/c import { IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey'; import { debounce } from 'vs/base/common/decorators'; import { ActionRunner } from 'vs/base/common/actions'; +import { IHostService } from 'vs/workbench/services/host/browser/host'; +import { USE_ASYNC_SERVER_TREE_CONFIG } from 'sql/workbench/contrib/objectExplorer/common/serverGroup.contribution'; +import { INotificationService } from 'vs/platform/notification/common/notification'; export const CONTEXT_SERVER_TREE_VIEW = new RawContextKey('serverTreeView.view', ServerTreeViewView.all); export const CONTEXT_SERVER_TREE_HAS_CONNECTIONS = new RawContextKey('serverTreeView.hasConnections', false); @@ -73,7 +76,9 @@ export class ServerTreeView extends Disposable implements IServerTreeView { @ICapabilitiesService private _capabilitiesService: ICapabilitiesService, @IContextMenuService private _contextMenuService: IContextMenuService, @IKeybindingService private _keybindingService: IKeybindingService, - @IContextKeyService contextKeyService: IContextKeyService + @IContextKeyService contextKeyService: IContextKeyService, + @IHostService private _hostService: IHostService, + @INotificationService private _notificationService: INotificationService ) { super(); this._hasConnectionsKey = CONTEXT_SERVER_TREE_HAS_CONNECTIONS.bindTo(contextKeyService); @@ -87,6 +92,26 @@ export class ServerTreeView extends Disposable implements IServerTreeView { await this.handleOnCapabilitiesRegistered(); }); this.registerCommands(); + this._register(this._configurationService.onDidChangeConfiguration(e => { + if (e.affectsConfiguration(USE_ASYNC_SERVER_TREE_CONFIG)) { + this._notificationService.prompt( + Severity.Info, + localize('serverTreeViewChangeNotification', "Server tree has changed. Please reload the window to see the changes."), + [{ + label: localize('serverTreeViewChangeNotification.reload', "Reload"), + run: () => { + this._hostService.reload(); + } + }, { + label: localize('serverTreeViewChangeNotification.doNotReload', "Don't Reload"), + run: () => { } + }], + { + sticky: true + } + ); + } + })); } @debounce(50) diff --git a/src/sql/workbench/contrib/objectExplorer/common/serverGroup.contribution.ts b/src/sql/workbench/contrib/objectExplorer/common/serverGroup.contribution.ts index 1515cacdc8..3a20b8ea82 100644 --- a/src/sql/workbench/contrib/objectExplorer/common/serverGroup.contribution.ts +++ b/src/sql/workbench/contrib/objectExplorer/common/serverGroup.contribution.ts @@ -42,6 +42,7 @@ const serverGroupConfig: IConfigurationNode = { }; export const NODE_EXPANSION_CONFIG = 'serverTree.nodeExpansionTimeout'; +export const USE_ASYNC_SERVER_TREE_CONFIG = 'serverTree.useAsyncServerTree'; const serverTreeConfig: IConfigurationNode = { 'id': 'serverTree', 'title': localize('serverTree.configuration.title', "Server Tree"), @@ -50,7 +51,7 @@ const serverTreeConfig: IConfigurationNode = { 'serverTree.useAsyncServerTree': { 'type': 'boolean', 'default': true, - 'description': localize('serverTree.useAsyncServerTree', "Use the new async server tree for the Servers view and Connection Dialog with support for new features such as dynamic node filtering.") + 'description': localize('serverTree.useAsyncServerTree', "Use the new async server tree for the Servers view and Connection Dialog with support for new features such as dynamic node filtering. Requires a restart to take effect.") }, 'serverTree.nodeExpansionTimeout': { 'type': 'number', diff --git a/src/sql/workbench/contrib/objectExplorer/test/browser/connectionTreeActions.test.ts b/src/sql/workbench/contrib/objectExplorer/test/browser/connectionTreeActions.test.ts index 56917ff6a2..eca0a98c41 100644 --- a/src/sql/workbench/contrib/objectExplorer/test/browser/connectionTreeActions.test.ts +++ b/src/sql/workbench/contrib/objectExplorer/test/browser/connectionTreeActions.test.ts @@ -298,7 +298,7 @@ suite('SQL Connection Tree Action tests', () => { return new Promise((resolve) => resolve({})); }); - let serverTreeView = TypeMoq.Mock.ofType(ServerTreeView, TypeMoq.MockBehavior.Strict, undefined, instantiationService.object, undefined, undefined, undefined, undefined, capabilitiesService, undefined, undefined, new MockContextKeyService()); + let serverTreeView = TypeMoq.Mock.ofType(ServerTreeView, TypeMoq.MockBehavior.Strict, undefined, instantiationService.object, undefined, undefined, undefined, new TestConfigurationService(), capabilitiesService, undefined, undefined, new MockContextKeyService()); serverTreeView.setup(x => x.showFilteredTree(TypeMoq.It.isAny())); serverTreeView.setup(x => x.refreshTree()); serverTreeView.setup(x => x.view).returns(() => ServerTreeViewView.all); @@ -316,7 +316,7 @@ suite('SQL Connection Tree Action tests', () => { return new Promise((resolve) => resolve({})); }); - let serverTreeView = TypeMoq.Mock.ofType(ServerTreeView, TypeMoq.MockBehavior.Strict, undefined, instantiationService.object, undefined, undefined, undefined, undefined, capabilitiesService, undefined, undefined, new MockContextKeyService()); + let serverTreeView = TypeMoq.Mock.ofType(ServerTreeView, TypeMoq.MockBehavior.Strict, undefined, instantiationService.object, undefined, undefined, undefined, new TestConfigurationService(), capabilitiesService, undefined, undefined, new MockContextKeyService()); serverTreeView.setup(x => x.showFilteredTree(TypeMoq.It.isAny())); serverTreeView.setup(x => x.refreshTree()); serverTreeView.setup(x => x.view).returns(() => ServerTreeViewView.active); diff --git a/src/sql/workbench/contrib/objectExplorer/test/browser/serverTreeView.test.ts b/src/sql/workbench/contrib/objectExplorer/test/browser/serverTreeView.test.ts index 25f9b571d1..aeeff43768 100644 --- a/src/sql/workbench/contrib/objectExplorer/test/browser/serverTreeView.test.ts +++ b/src/sql/workbench/contrib/objectExplorer/test/browser/serverTreeView.test.ts @@ -17,6 +17,7 @@ import { TreeItemCollapsibleState } from 'sql/workbench/services/objectExplorer/ import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService'; import * as assert from 'assert'; import { MockContextKeyService } from 'vs/platform/keybinding/test/common/mockKeybindingService'; +import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService'; suite('ServerTreeView onAddConnectionProfile handler tests', () => { @@ -38,7 +39,7 @@ suite('ServerTreeView onAddConnectionProfile handler tests', () => { ); mockConnectionManagementService.setup(x => x.getConnectionGroups()).returns(x => []); mockConnectionManagementService.setup(x => x.hasRegisteredServers()).returns(() => true); - serverTreeView = new ServerTreeView(mockConnectionManagementService.object, instantiationService, undefined, new TestThemeService(), undefined, undefined, capabilitiesService, undefined, undefined, new MockContextKeyService()); + serverTreeView = new ServerTreeView(mockConnectionManagementService.object, instantiationService, undefined, new TestThemeService(), undefined, new TestConfigurationService(), capabilitiesService, undefined, undefined, new MockContextKeyService(), undefined, undefined); mockTree = TypeMoq.Mock.ofType(TestTree); (serverTreeView as any)._tree = mockTree.object; mockRefreshTreeMethod = TypeMoq.Mock.ofType(Function); diff --git a/src/sql/workbench/contrib/scripting/test/browser/scriptingActions.test.ts b/src/sql/workbench/contrib/scripting/test/browser/scriptingActions.test.ts index e6bc9f6ac1..9928767c82 100644 --- a/src/sql/workbench/contrib/scripting/test/browser/scriptingActions.test.ts +++ b/src/sql/workbench/contrib/scripting/test/browser/scriptingActions.test.ts @@ -23,6 +23,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti import { TestTree } from 'sql/workbench/test/treeMock'; import { TestConnectionManagementService } from 'sql/platform/connection/test/common/testConnectionManagementService'; import { MockContextKeyService } from 'vs/platform/keybinding/test/common/mockKeybindingService'; +import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService'; const connection: azdata.IConnectionProfile = { options: [], @@ -67,7 +68,7 @@ suite('Scripting Actions', () => { instantiationService = new InstantiationService(collection); const capabilitiesService = new TestCapabilitiesService(); const connectionManagementServiceMock = TypeMoq.Mock.ofType(TestConnectionManagementService, TypeMoq.MockBehavior.Loose); - const serverTreeViewMock = TypeMoq.Mock.ofType(ServerTreeView, TypeMoq.MockBehavior.Loose, connectionManagementServiceMock.object, instantiationService, undefined, undefined, undefined, undefined, capabilitiesService, undefined, undefined, new MockContextKeyService()); + const serverTreeViewMock = TypeMoq.Mock.ofType(ServerTreeView, TypeMoq.MockBehavior.Loose, connectionManagementServiceMock.object, instantiationService, undefined, undefined, undefined, new TestConfigurationService(), capabilitiesService, undefined, undefined, new MockContextKeyService()); treeMock = TypeMoq.Mock.ofType(TestTree); serverTreeViewMock.setup(x => x.tree).returns(() => treeMock.object); collection.set(IObjectExplorerService, createObjectExplorerServiceMock({ serverTreeView: serverTreeViewMock.object, treeNode: treeNode }));