Fix New Notebook issues (#5958)

* Fix New Notebook issues
- Fix #5338 New Notebook menu item should be next to New Query
- Fix #4936 Add a shortcut to create a notebook in the document well

Created a built-in New Notebook command
that routes to the existing extension-based command.
This avoided a rearchitecture that was more complex that seemed worth it.
Per VSCode patterns, used a _ modifier for the existing command so it's "private"
This commit is contained in:
Kevin Cunnane
2019-06-10 16:38:07 -07:00
committed by GitHub
parent 730ad4b814
commit 14a6bf581c
9 changed files with 72 additions and 18 deletions

View File

@@ -31,6 +31,7 @@ import { IQueryManagementService } from 'sql/platform/query/common/queryManageme
import { IScriptingService } from 'sql/platform/scripting/common/scriptingService';
import { ServerInfoContextKey } from 'sql/workbench/parts/connection/common/serverInfoContextKey';
import { fillInActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
import { NewNotebookAction } from 'sql/workbench/parts/notebook/notebookActions';
/**
* Provides actions for the server tree elements
@@ -111,7 +112,7 @@ export class ServerTreeActionProvider extends ContributableActionProvider {
private getBuiltinConnectionActions(context: ObjectExplorerContext): IAction[] {
let actions: IAction[] = [];
actions.push(this._instantiationService.createInstance(ManageConnectionAction, ManageConnectionAction.ID, ManageConnectionAction.LABEL, context.tree));
this.addNewQueryAction(context, actions);
this.addNewQueryNotebookActions(context, actions);
if (this._connectionManagementService.isProfileConnected(context.profile)) {
actions.push(this._instantiationService.createInstance(DisconnectConnectionAction, DisconnectConnectionAction.ID, DisconnectConnectionAction.LABEL, context.profile));
@@ -165,7 +166,7 @@ export class ServerTreeActionProvider extends ContributableActionProvider {
if (TreeUpdateUtils.isAvailableDatabaseNode(treeNode)) {
isAvailableDatabaseNode = true;
actions.push(this._instantiationService.createInstance(ManageConnectionAction, ManageConnectionAction.ID, ManageConnectionAction.LABEL, context.tree));
this.addNewQueryAction(context, actions);
this.addNewQueryNotebookActions(context, actions);
} else {
return actions;
}
@@ -186,9 +187,10 @@ export class ServerTreeActionProvider extends ContributableActionProvider {
return actions;
}
private addNewQueryAction(context: ObjectExplorerContext, actions: IAction[]): void {
private addNewQueryNotebookActions(context: ObjectExplorerContext, actions: IAction[]): void {
if (this._queryManagementService.isProviderRegistered(context.profile.providerName)) {
actions.push(this._instantiationService.createInstance(OEAction, NewQueryAction.ID, NewQueryAction.LABEL));
actions.push(this._instantiationService.createInstance(OEAction, NewNotebookAction.ID, NewNotebookAction.LABEL));
}
}