Isolate more features (#6854)

* working; new query and scripting

* working; removing manage from menus and combining data explorer contributions

* consolidate dashboard contributions; move manage action to dashboard contributions; make groupings the same

* fix notebook actions not firing

* fix notebook actions

* notebooks working

* move backup and restore entry points into their own file; move explorerwidget contribution into their respective files

* fix tests

* move extension actions to their own file

* fix tests

* change tests
This commit is contained in:
Anthony Dresser
2019-08-22 16:54:30 -07:00
committed by GitHub
parent 36244ed517
commit 82a8f09709
19 changed files with 616 additions and 589 deletions

View File

@@ -13,9 +13,6 @@ import {
DisconnectConnectionAction, AddServerAction,
DeleteConnectionAction, RefreshAction, EditServerGroupAction
} from 'sql/workbench/parts/objectExplorer/browser/connectionTreeAction';
import {
OEAction
} from 'sql/workbench/parts/objectExplorer/browser/objectExplorerActions';
import { TreeNode } from 'sql/workbench/parts/objectExplorer/common/treeNode';
import { NodeType } from 'sql/workbench/parts/objectExplorer/common/nodeType';
import { ConnectionProfileGroup } from 'sql/platform/connection/common/connectionProfileGroup';
@@ -23,13 +20,11 @@ import { ConnectionProfile } from 'sql/platform/connection/common/connectionProf
import { TreeUpdateUtils } from 'sql/workbench/parts/objectExplorer/browser/treeUpdateUtils';
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
import { MenuId, IMenuService } from 'vs/platform/actions/common/actions';
import { BackupAction, RestoreAction } from 'sql/workbench/common/actions';
import { ConnectionContextKey } from 'sql/workbench/parts/connection/common/connectionContextKey';
import { TreeNodeContextKey } from 'sql/workbench/parts/objectExplorer/common/treeNodeContextKey';
import { IQueryManagementService } from 'sql/platform/query/common/queryManagement';
import { ServerInfoContextKey } from 'sql/workbench/parts/connection/common/serverInfoContextKey';
import { fillInActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
import { NewNotebookAction } from 'sql/workbench/parts/notebook/browser/notebookActions';
/**
* Provides actions for the server tree elements
@@ -107,7 +102,6 @@ export class ServerTreeActionProvider extends ContributableActionProvider {
private getBuiltinConnectionActions(context: ObjectExplorerContext): IAction[] {
let actions: IAction[] = [];
this.addNewQueryNotebookActions(context, actions);
if (this._connectionManagementService.isProfileConnected(context.profile)) {
actions.push(this._instantiationService.createInstance(DisconnectConnectionAction, DisconnectConnectionAction.ID, DisconnectConnectionAction.LABEL, context.profile));
@@ -159,24 +153,13 @@ export class ServerTreeActionProvider extends ContributableActionProvider {
private getBuiltInNodeActions(context: ObjectExplorerContext): IAction[] {
let actions: IAction[] = [];
let treeNode = context.treeNode;
let isAvailableDatabaseNode = false;
if (TreeUpdateUtils.isDatabaseNode(treeNode)) {
if (TreeUpdateUtils.isAvailableDatabaseNode(treeNode)) {
isAvailableDatabaseNode = true;
this.addNewQueryNotebookActions(context, actions);
} else {
return actions;
}
}
let serverInfo = this._connectionManagementService.getServerInfo(context.profile.id);
let isCloud = serverInfo && serverInfo.isCloud;
if (isAvailableDatabaseNode && !isCloud) {
this.addBackupAction(context, actions);
this.addRestoreAction(context, actions);
}
// Contribute refresh action for scriptable objects via contribution
if (!this.isScriptableObject(context)) {
actions.push(this._instantiationService.createInstance(RefreshAction, RefreshAction.ID, RefreshAction.LABEL, context.tree, context.profile));
@@ -185,26 +168,6 @@ export class ServerTreeActionProvider extends ContributableActionProvider {
return actions;
}
private addNewQueryNotebookActions(context: ObjectExplorerContext, actions: IAction[]): void {
if (this._queryManagementService.isProviderRegistered(context.profile.providerName)) {
// Workaround for #6397 right-click and run New Notebook connects to wrong server. Use notebook action instead of generic command action
let notebookAction = this._instantiationService.createInstance(NewNotebookAction, NewNotebookAction.ID, NewNotebookAction.LABEL);
actions.push(notebookAction);
}
}
private addBackupAction(context: ObjectExplorerContext, actions: IAction[]): void {
if (this._queryManagementService.isProviderRegistered(context.profile.providerName)) {
actions.push(this._instantiationService.createInstance(OEAction, BackupAction.ID, BackupAction.LABEL));
}
}
private addRestoreAction(context: ObjectExplorerContext, actions: IAction[]): void {
if (this._queryManagementService.isProviderRegistered(context.profile.providerName)) {
actions.push(this._instantiationService.createInstance(OEAction, RestoreAction.ID, RestoreAction.LABEL));
}
}
private isScriptableObject(context: ObjectExplorerContext): boolean {
if (context.treeNode) {
if (NodeType.SCRIPTABLE_OBJECTS.includes(context.treeNode.nodeTypeId)) {