Path: blob/main/src/vs/workbench/contrib/notebook/browser/controller/variablesActions.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { localize2 } from '../../../../../nls.js';6import { MenuId, registerAction2 } from '../../../../../platform/actions/common/actions.js';7import { ContextKeyExpr } from '../../../../../platform/contextkey/common/contextkey.js';8import { ServicesAccessor } from '../../../../../platform/instantiation/common/instantiation.js';9import { IViewsService } from '../../../../services/views/common/viewsService.js';10import { KERNEL_HAS_VARIABLE_PROVIDER } from '../../common/notebookContextKeys.js';11import { NOTEBOOK_VARIABLE_VIEW_ENABLED } from '../contrib/notebookVariables/notebookVariableContextKeys.js';12import * as icons from '../notebookIcons.js';1314import { INotebookActionContext, NotebookAction } from './coreActions.js';1516const OPEN_VARIABLES_VIEW_COMMAND_ID = 'notebook.openVariablesView';1718registerAction2(class OpenVariablesViewAction extends NotebookAction {1920constructor() {21super({22id: OPEN_VARIABLES_VIEW_COMMAND_ID,23title: localize2('notebookActions.openVariablesView', "Variables"),24icon: icons.variablesViewIcon,25menu: [26{27id: MenuId.InteractiveToolbar,28group: 'navigation',29when: ContextKeyExpr.and(30KERNEL_HAS_VARIABLE_PROVIDER,31// jupyter extension currently contributes their own goto variables button32ContextKeyExpr.notEquals('jupyter.kernel.isjupyter', true),33NOTEBOOK_VARIABLE_VIEW_ENABLED34)35},36{37id: MenuId.EditorTitle,38order: -1,39group: 'navigation',40when: ContextKeyExpr.and(41KERNEL_HAS_VARIABLE_PROVIDER,42// jupyter extension currently contributes their own goto variables button43ContextKeyExpr.notEquals('jupyter.kernel.isjupyter', true),44ContextKeyExpr.notEquals('config.notebook.globalToolbar', true),45NOTEBOOK_VARIABLE_VIEW_ENABLED46)47},48{49id: MenuId.NotebookToolbar,50order: -1,51group: 'navigation',52when: ContextKeyExpr.and(53KERNEL_HAS_VARIABLE_PROVIDER,54// jupyter extension currently contributes their own goto variables button55ContextKeyExpr.notEquals('jupyter.kernel.isjupyter', true),56ContextKeyExpr.equals('config.notebook.globalToolbar', true),57NOTEBOOK_VARIABLE_VIEW_ENABLED58)59}60]61});62}6364override async runWithContext(accessor: ServicesAccessor, context: INotebookActionContext) {65const variableViewId = 'workbench.notebook.variables';66accessor.get(IViewsService).openView(variableViewId, true);67}68});697071