mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-14 01:25:37 -05:00
More data explorer actions (#4307)
* adding context * apply extension changes * shimming disconnect * add data explorer context menu and add disconnect to it * clean up shim code; better handle errors * remove tpromise * simplify code * add node context on data explorer * formatting * add new Query action * fix various errors with how the context menus work * add manage and new query * add refresh command * formatting
This commit is contained in:
@@ -10,9 +10,9 @@ agent-base@4, agent-base@^4.1.0:
|
||||
es6-promisify "^5.0.0"
|
||||
|
||||
ajv@^6.5.5:
|
||||
version "6.8.1"
|
||||
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.8.1.tgz#0890b93742985ebf8973cd365c5b23920ce3cb20"
|
||||
integrity sha512-eqxCp82P+JfqL683wwsL73XmFs1eG6qjw+RD3YHx+Jll1r0jNd4dh8QG9NYAeNGA/hnZjeEDgtTskgJULbxpWQ==
|
||||
version "6.10.0"
|
||||
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.10.0.tgz#90d0d54439da587cd7e843bfb7045f50bd22bdf1"
|
||||
integrity sha512-nffhOpkymDECQyR0mnsUtoCE8RlX38G0rYP+wgLWFyZuUyuuojSSvi/+euOiQBIn63whYwYVIIH1TvE3tu4OEg==
|
||||
dependencies:
|
||||
fast-deep-equal "^2.0.1"
|
||||
fast-json-stable-stringify "^2.0.0"
|
||||
@@ -562,17 +562,17 @@ make-dir@^1.0.0:
|
||||
dependencies:
|
||||
pify "^3.0.0"
|
||||
|
||||
mime-db@~1.37.0:
|
||||
version "1.37.0"
|
||||
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.37.0.tgz#0b6a0ce6fdbe9576e25f1f2d2fde8830dc0ad0d8"
|
||||
integrity sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg==
|
||||
mime-db@~1.38.0:
|
||||
version "1.38.0"
|
||||
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.38.0.tgz#1a2aab16da9eb167b49c6e4df2d9c68d63d8e2ad"
|
||||
integrity sha512-bqVioMFFzc2awcdJZIzR3HjZFX20QhilVS7hytkKrv7xFAn8bM1gzc/FOX2awLISvWe0PV8ptFKcon+wZ5qYkg==
|
||||
|
||||
mime-types@^2.1.12, mime-types@~2.1.19:
|
||||
version "2.1.21"
|
||||
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.21.tgz#28995aa1ecb770742fe6ae7e58f9181c744b3f96"
|
||||
integrity sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg==
|
||||
version "2.1.22"
|
||||
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.22.tgz#fe6b355a190926ab7698c9a0556a11199b2199bd"
|
||||
integrity sha512-aGl6TZGnhm/li6F7yx82bJiBZwgiEa4Hf6CNr8YO+r5UHr53tSTYZb102zyU50DOWWKeOv0uQLRL0/9EiKWCog==
|
||||
dependencies:
|
||||
mime-db "~1.37.0"
|
||||
mime-db "~1.38.0"
|
||||
|
||||
minimist@0.0.8:
|
||||
version "0.0.8"
|
||||
|
||||
@@ -24,13 +24,6 @@ import { ObjectExplorerActionsContext } from 'sql/parts/objectExplorer/viewlet/o
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMessageService';
|
||||
import { ConnectionViewletPanel } from 'sql/parts/dataExplorer/objectExplorer/connectionViewlet/connectionViewletPanel';
|
||||
import { ConnectionManagementService } from 'sql/platform/connection/common/connectionManagementService';
|
||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
|
||||
import { ViewsRegistry } from 'vs/workbench/common/views';
|
||||
import { ICustomViewDescriptor, TreeViewItemHandleArg } from 'sql/workbench/common/views';
|
||||
import { IOEShimService } from 'sql/parts/objectExplorer/common/objectExplorerViewTreeShim';
|
||||
|
||||
export class RefreshAction extends Action {
|
||||
|
||||
|
||||
@@ -323,7 +323,7 @@ export class CustomTreeView extends Disposable implements ITreeView {
|
||||
const menus = this.instantiationService.createInstance(TreeMenus, this.id);
|
||||
const dataSource = this.instantiationService.createInstance(TreeDataSource, this, this.container, this.id);
|
||||
const renderer = this.instantiationService.createInstance(TreeRenderer, this.id, menus, actionItemProvider);
|
||||
const controller = this.instantiationService.createInstance(TreeController, this.id, menus);
|
||||
const controller = this.instantiationService.createInstance(TreeController, this.id, this.container.id, menus);
|
||||
this.tree = this.instantiationService.createInstance(FileIconThemableWorkbenchTree, this.treeContainer, { dataSource, renderer, controller }, {});
|
||||
this.tree.contextKeyService.createKey<boolean>(this.id, true);
|
||||
this._register(this.tree);
|
||||
@@ -738,6 +738,7 @@ class TreeController extends WorkbenchTreeController {
|
||||
|
||||
constructor(
|
||||
private treeViewId: string,
|
||||
private containerId: string,
|
||||
private menus: TreeMenus,
|
||||
@IContextMenuService private contextMenuService: IContextMenuService,
|
||||
@IKeybindingService private readonly _keybindingService: IKeybindingService,
|
||||
@@ -779,7 +780,7 @@ class TreeController extends WorkbenchTreeController {
|
||||
}
|
||||
},
|
||||
|
||||
getActionsContext: () => (<TreeViewItemHandleArg>{ $treeViewId: this.treeViewId, $treeItemHandle: node.handle, $treeItem: node }),
|
||||
getActionsContext: () => (<TreeViewItemHandleArg>{ $treeViewId: this.treeViewId, $treeItemHandle: node.handle, $treeItem: node, $treeContainerId: this.containerId }),
|
||||
|
||||
actionRunner: new MultipleSelectionActionRunner(() => tree.getSelection())
|
||||
});
|
||||
|
||||
@@ -32,7 +32,8 @@ export interface ITreeView extends vsITreeView {
|
||||
export type TreeViewItemHandleArg = {
|
||||
$treeViewId: string,
|
||||
$treeItemHandle: string,
|
||||
$treeItem?: ITreeItem
|
||||
$treeItem?: ITreeItem,
|
||||
$treeContainerId?: string
|
||||
};
|
||||
|
||||
export interface ICustomViewDescriptor extends IViewDescriptor {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import { NodeContextKey } from 'sql/workbench/parts/dataExplorer/common/nodeContext';
|
||||
import { localize } from 'vs/nls';
|
||||
import { MenuId, MenuRegistry } from 'vs/platform/actions/common/actions';
|
||||
import { DISCONNECT_COMMAND_ID } from './nodeCommands';
|
||||
import { DISCONNECT_COMMAND_ID, MANAGE_COMMAND_ID, NEW_QUERY_COMMAND_ID, REFRESH_COMMAND_ID } from './nodeCommands';
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||
group: 'connection',
|
||||
@@ -17,3 +17,31 @@ MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||
},
|
||||
when: NodeContextKey.IsConnected
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||
group: 'connection',
|
||||
command: {
|
||||
id: NEW_QUERY_COMMAND_ID,
|
||||
title: localize('newQuery', 'New Query')
|
||||
},
|
||||
when: NodeContextKey.IsConnectable
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||
group: 'connection',
|
||||
order: 4,
|
||||
command: {
|
||||
id: MANAGE_COMMAND_ID,
|
||||
title: localize('manage', 'Manage')
|
||||
},
|
||||
when: NodeContextKey.IsConnectable
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||
group: 'connection',
|
||||
order: 4,
|
||||
command: {
|
||||
id: REFRESH_COMMAND_ID,
|
||||
title: localize('refresh', 'Refresh')
|
||||
}
|
||||
});
|
||||
|
||||
@@ -4,11 +4,20 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IOEShimService } from 'sql/parts/objectExplorer/common/objectExplorerViewTreeShim';
|
||||
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
import { ConnectionType, IConnectableInput, IConnectionCompletionOptions, IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
import { generateUri } from 'sql/platform/connection/common/utils';
|
||||
import { ICustomViewDescriptor, TreeViewItemHandleArg } from 'sql/workbench/common/views';
|
||||
import { IQueryEditorService } from 'sql/workbench/services/queryEditor/common/queryEditorService';
|
||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { ViewsRegistry } from 'vs/workbench/common/views';
|
||||
import { IProgressService2 } from 'vs/platform/progress/common/progress';
|
||||
|
||||
export const DISCONNECT_COMMAND_ID = 'dataExplorer.disconnect';
|
||||
export const MANAGE_COMMAND_ID = 'dataExplorer.manage';
|
||||
export const NEW_QUERY_COMMAND_ID = 'dataExplorer.newQuery';
|
||||
export const REFRESH_COMMAND_ID = 'dataExplorer.refresh';
|
||||
|
||||
CommandsRegistry.registerCommand({
|
||||
id: DISCONNECT_COMMAND_ID,
|
||||
@@ -24,3 +33,64 @@ CommandsRegistry.registerCommand({
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
});
|
||||
|
||||
CommandsRegistry.registerCommand({
|
||||
id: NEW_QUERY_COMMAND_ID,
|
||||
handler: (accessor, args: TreeViewItemHandleArg) => {
|
||||
if (args.$treeItem) {
|
||||
const queryEditorService = accessor.get(IQueryEditorService);
|
||||
const connectionService = accessor.get(IConnectionManagementService);
|
||||
const capabilitiesService = accessor.get(ICapabilitiesService);
|
||||
return queryEditorService.newSqlEditor().then((owner: IConnectableInput) => {
|
||||
// Connect our editor to the input connection
|
||||
let options: IConnectionCompletionOptions = {
|
||||
params: { connectionType: ConnectionType.editor, input: owner },
|
||||
saveTheConnection: false,
|
||||
showDashboard: false,
|
||||
showConnectionDialogOnError: true,
|
||||
showFirewallRuleOnError: true
|
||||
};
|
||||
return connectionService.connect(new ConnectionProfile(capabilitiesService, args.$treeItem.payload), owner.uri, options);
|
||||
});
|
||||
}
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
});
|
||||
|
||||
CommandsRegistry.registerCommand({
|
||||
id: MANAGE_COMMAND_ID,
|
||||
handler: (accessor, args: TreeViewItemHandleArg) => {
|
||||
if (args.$treeItem) {
|
||||
const connectionService = accessor.get(IConnectionManagementService);
|
||||
const capabilitiesService = accessor.get(ICapabilitiesService);
|
||||
let options = {
|
||||
showDashboard: true,
|
||||
saveTheConnection: false,
|
||||
params: undefined,
|
||||
showConnectionDialogOnError: true,
|
||||
showFirewallRuleOnError: true
|
||||
};
|
||||
let profile = new ConnectionProfile(capabilitiesService, args.$treeItem.payload);
|
||||
let uri = generateUri(profile, 'dashboard');
|
||||
return connectionService.connect(new ConnectionProfile(capabilitiesService, args.$treeItem.payload), uri, options);
|
||||
}
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
});
|
||||
|
||||
CommandsRegistry.registerCommand({
|
||||
id: REFRESH_COMMAND_ID,
|
||||
handler: (accessor, args: TreeViewItemHandleArg) => {
|
||||
const progressSerivce = accessor.get(IProgressService2);
|
||||
if (args.$treeItem) {
|
||||
const { treeView } = (<ICustomViewDescriptor>ViewsRegistry.getView(args.$treeViewId));
|
||||
if (args.$treeContainerId) {
|
||||
return progressSerivce.withProgress({ location: args.$treeContainerId }, () => treeView.refresh([args.$treeItem]).then(() => true));
|
||||
} else {
|
||||
return treeView.refresh([args.$treeItem]).then(() => true);
|
||||
}
|
||||
|
||||
}
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user