mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Adding restart ads notification when async server tree is toggled (#22726)
This commit is contained in:
@@ -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 { IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||||
import { debounce } from 'vs/base/common/decorators';
|
import { debounce } from 'vs/base/common/decorators';
|
||||||
import { ActionRunner } from 'vs/base/common/actions';
|
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<ServerTreeViewView>('serverTreeView.view', ServerTreeViewView.all);
|
export const CONTEXT_SERVER_TREE_VIEW = new RawContextKey<ServerTreeViewView>('serverTreeView.view', ServerTreeViewView.all);
|
||||||
export const CONTEXT_SERVER_TREE_HAS_CONNECTIONS = new RawContextKey<boolean>('serverTreeView.hasConnections', false);
|
export const CONTEXT_SERVER_TREE_HAS_CONNECTIONS = new RawContextKey<boolean>('serverTreeView.hasConnections', false);
|
||||||
@@ -73,7 +76,9 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
|||||||
@ICapabilitiesService private _capabilitiesService: ICapabilitiesService,
|
@ICapabilitiesService private _capabilitiesService: ICapabilitiesService,
|
||||||
@IContextMenuService private _contextMenuService: IContextMenuService,
|
@IContextMenuService private _contextMenuService: IContextMenuService,
|
||||||
@IKeybindingService private _keybindingService: IKeybindingService,
|
@IKeybindingService private _keybindingService: IKeybindingService,
|
||||||
@IContextKeyService contextKeyService: IContextKeyService
|
@IContextKeyService contextKeyService: IContextKeyService,
|
||||||
|
@IHostService private _hostService: IHostService,
|
||||||
|
@INotificationService private _notificationService: INotificationService
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
this._hasConnectionsKey = CONTEXT_SERVER_TREE_HAS_CONNECTIONS.bindTo(contextKeyService);
|
this._hasConnectionsKey = CONTEXT_SERVER_TREE_HAS_CONNECTIONS.bindTo(contextKeyService);
|
||||||
@@ -87,6 +92,26 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
|||||||
await this.handleOnCapabilitiesRegistered();
|
await this.handleOnCapabilitiesRegistered();
|
||||||
});
|
});
|
||||||
this.registerCommands();
|
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)
|
@debounce(50)
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ const serverGroupConfig: IConfigurationNode = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const NODE_EXPANSION_CONFIG = 'serverTree.nodeExpansionTimeout';
|
export const NODE_EXPANSION_CONFIG = 'serverTree.nodeExpansionTimeout';
|
||||||
|
export const USE_ASYNC_SERVER_TREE_CONFIG = 'serverTree.useAsyncServerTree';
|
||||||
const serverTreeConfig: IConfigurationNode = {
|
const serverTreeConfig: IConfigurationNode = {
|
||||||
'id': 'serverTree',
|
'id': 'serverTree',
|
||||||
'title': localize('serverTree.configuration.title', "Server Tree"),
|
'title': localize('serverTree.configuration.title', "Server Tree"),
|
||||||
@@ -50,7 +51,7 @@ const serverTreeConfig: IConfigurationNode = {
|
|||||||
'serverTree.useAsyncServerTree': {
|
'serverTree.useAsyncServerTree': {
|
||||||
'type': 'boolean',
|
'type': 'boolean',
|
||||||
'default': true,
|
'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': {
|
'serverTree.nodeExpansionTimeout': {
|
||||||
'type': 'number',
|
'type': 'number',
|
||||||
|
|||||||
@@ -298,7 +298,7 @@ suite('SQL Connection Tree Action tests', () => {
|
|||||||
return new Promise((resolve) => resolve({}));
|
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.showFilteredTree(TypeMoq.It.isAny()));
|
||||||
serverTreeView.setup(x => x.refreshTree());
|
serverTreeView.setup(x => x.refreshTree());
|
||||||
serverTreeView.setup(x => x.view).returns(() => ServerTreeViewView.all);
|
serverTreeView.setup(x => x.view).returns(() => ServerTreeViewView.all);
|
||||||
@@ -316,7 +316,7 @@ suite('SQL Connection Tree Action tests', () => {
|
|||||||
return new Promise((resolve) => resolve({}));
|
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.showFilteredTree(TypeMoq.It.isAny()));
|
||||||
serverTreeView.setup(x => x.refreshTree());
|
serverTreeView.setup(x => x.refreshTree());
|
||||||
serverTreeView.setup(x => x.view).returns(() => ServerTreeViewView.active);
|
serverTreeView.setup(x => x.view).returns(() => ServerTreeViewView.active);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import { TreeItemCollapsibleState } from 'sql/workbench/services/objectExplorer/
|
|||||||
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
|
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
|
||||||
import * as assert from 'assert';
|
import * as assert from 'assert';
|
||||||
import { MockContextKeyService } from 'vs/platform/keybinding/test/common/mockKeybindingService';
|
import { MockContextKeyService } from 'vs/platform/keybinding/test/common/mockKeybindingService';
|
||||||
|
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||||
|
|
||||||
suite('ServerTreeView onAddConnectionProfile handler tests', () => {
|
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.getConnectionGroups()).returns(x => []);
|
||||||
mockConnectionManagementService.setup(x => x.hasRegisteredServers()).returns(() => true);
|
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<ITree>(TestTree);
|
mockTree = TypeMoq.Mock.ofType<ITree>(TestTree);
|
||||||
(serverTreeView as any)._tree = mockTree.object;
|
(serverTreeView as any)._tree = mockTree.object;
|
||||||
mockRefreshTreeMethod = TypeMoq.Mock.ofType(Function);
|
mockRefreshTreeMethod = TypeMoq.Mock.ofType(Function);
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
|||||||
import { TestTree } from 'sql/workbench/test/treeMock';
|
import { TestTree } from 'sql/workbench/test/treeMock';
|
||||||
import { TestConnectionManagementService } from 'sql/platform/connection/test/common/testConnectionManagementService';
|
import { TestConnectionManagementService } from 'sql/platform/connection/test/common/testConnectionManagementService';
|
||||||
import { MockContextKeyService } from 'vs/platform/keybinding/test/common/mockKeybindingService';
|
import { MockContextKeyService } from 'vs/platform/keybinding/test/common/mockKeybindingService';
|
||||||
|
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||||
|
|
||||||
const connection: azdata.IConnectionProfile = {
|
const connection: azdata.IConnectionProfile = {
|
||||||
options: [],
|
options: [],
|
||||||
@@ -67,7 +68,7 @@ suite('Scripting Actions', () => {
|
|||||||
instantiationService = new InstantiationService(collection);
|
instantiationService = new InstantiationService(collection);
|
||||||
const capabilitiesService = new TestCapabilitiesService();
|
const capabilitiesService = new TestCapabilitiesService();
|
||||||
const connectionManagementServiceMock = TypeMoq.Mock.ofType(TestConnectionManagementService, TypeMoq.MockBehavior.Loose);
|
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);
|
treeMock = TypeMoq.Mock.ofType(TestTree);
|
||||||
serverTreeViewMock.setup(x => x.tree).returns(() => treeMock.object);
|
serverTreeViewMock.setup(x => x.tree).returns(() => treeMock.object);
|
||||||
collection.set(IObjectExplorerService, createObjectExplorerServiceMock({ serverTreeView: serverTreeViewMock.object, treeNode: treeNode }));
|
collection.set(IObjectExplorerService, createObjectExplorerServiceMock({ serverTreeView: serverTreeViewMock.object, treeNode: treeNode }));
|
||||||
|
|||||||
Reference in New Issue
Block a user