From 293f9c22c49bf0ce63a17c776e9ba615ed787d00 Mon Sep 17 00:00:00 2001 From: Kevin Cunnane Date: Wed, 10 Apr 2019 14:04:36 -0700 Subject: [PATCH] Touchbar support for Run Cell, Run Query, Add Cell (#4972) * Basic touchbar support * Touchbar support for Run Cell, Run Query, Add Cell - Add top 3 notebook commands - Add top query command Actions only appear on having active editor of expected type. In order to make Notebook work as expected, added tabindex to support focusing and hide outline to ensure it doesn't get weird blue outline on click Note: does not have icons yet, which would be nice. However can add in subsequent PR once this comes from UX. --- extensions/notebook/package.json | 17 +++++++++++++++++ .../parts/query/common/query.contribution.ts | 16 ++++++++++++++-- .../parts/notebook/notebook.component.html | 2 +- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/extensions/notebook/package.json b/extensions/notebook/package.json index fc9842d853..40c230a40b 100644 --- a/extensions/notebook/package.json +++ b/extensions/notebook/package.json @@ -168,6 +168,23 @@ "when": "false" } ], + "touchBar": [ + { + "command": "notebook.command.runactivecell", + "when": "activeEditor == workbench.editor.notebookEditor", + "group": "1_notebook" + }, + { + "command": "notebook.command.addcode", + "when": "activeEditor == workbench.editor.notebookEditor", + "group": "2_notebook" + }, + { + "command": "notebook.command.addtext", + "when": "activeEditor == workbench.editor.notebookEditor", + "group": "2_notebook" + } + ], "objectExplorer/item/context": [ { "command": "notebook.command.new", diff --git a/src/sql/parts/query/common/query.contribution.ts b/src/sql/parts/query/common/query.contribution.ts index f63e7218ba..2e11230f8e 100644 --- a/src/sql/parts/query/common/query.contribution.ts +++ b/src/sql/parts/query/common/query.contribution.ts @@ -10,11 +10,12 @@ import { EditorDescriptor, IEditorRegistry, Extensions as EditorExtensions } fro import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/actions'; import { IConfigurationRegistry, Extensions as ConfigExtensions } from 'vs/platform/configuration/common/configurationRegistry'; -import { SyncActionDescriptor } from 'vs/platform/actions/common/actions'; +import { SyncActionDescriptor, MenuId, MenuRegistry } from 'vs/platform/actions/common/actions'; import { KeyMod, KeyCode, KeyChord } from 'vs/base/common/keyCodes'; import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; -import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; +import { ContextKeyExpr, ContextKeyEqualsExpr } from 'vs/platform/contextkey/common/contextkey'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; +import { isMacintosh } from 'vs/base/common/platform'; import { QueryEditor } from 'sql/parts/query/editor/queryEditor'; import { QueryResultsEditor } from 'sql/parts/query/editor/queryResultsEditor'; @@ -106,6 +107,17 @@ actionRegistry.registerWorkbenchAction( RunQueryKeyboardAction.LABEL ); +// Touch Bar +if (isMacintosh) { + // Only show Run Query if the active editor is a query editor. + MenuRegistry.appendMenuItem(MenuId.TouchBarContext, { + command: { id: RunQueryKeyboardAction.ID, title: RunQueryKeyboardAction.LABEL }, + group: 'query', + when: new ContextKeyEqualsExpr('activeEditor', 'workbench.editor.queryEditor') + }); +} + + actionRegistry.registerWorkbenchAction( new SyncActionDescriptor( RunCurrentQueryKeyboardAction, diff --git a/src/sql/workbench/parts/notebook/notebook.component.html b/src/sql/workbench/parts/notebook/notebook.component.html index be2c51272d..cc94dd6979 100644 --- a/src/sql/workbench/parts/notebook/notebook.component.html +++ b/src/sql/workbench/parts/notebook/notebook.component.html @@ -7,7 +7,7 @@
-
+