From efaf83ba2e4e828c8b93b84a6dcf158abb6265ec Mon Sep 17 00:00:00 2001 From: Tim Mok Date: Tue, 28 Jan 2025 16:45:49 -0500 Subject: [PATCH] Remove plot in editor tab flag --- .../browser/components/actionBars.tsx | 17 +++------------ .../browser/positronPlotsActions.ts | 8 +++---- .../positronPlotsEditor.contribution.ts | 21 ------------------- 3 files changed, 7 insertions(+), 39 deletions(-) diff --git a/src/vs/workbench/contrib/positronPlots/browser/components/actionBars.tsx b/src/vs/workbench/contrib/positronPlots/browser/components/actionBars.tsx index 0395f9cf141..6c80dded4be 100644 --- a/src/vs/workbench/contrib/positronPlots/browser/components/actionBars.tsx +++ b/src/vs/workbench/contrib/positronPlots/browser/components/actionBars.tsx @@ -7,7 +7,7 @@ import './actionBars.css'; // React. -import React, { PropsWithChildren, useEffect } from 'react'; +import React, { PropsWithChildren } from 'react'; // Other dependencies. import { localize } from '../../../../../nls.js'; @@ -15,7 +15,7 @@ import { ICommandService } from '../../../../../platform/commands/common/command import { IKeybindingService } from '../../../../../platform/keybinding/common/keybinding.js'; import { IContextKeyService } from '../../../../../platform/contextkey/common/contextkey.js'; import { IContextMenuService } from '../../../../../platform/contextview/browser/contextView.js'; -import { IConfigurationChangeEvent, IConfigurationService } from '../../../../../platform/configuration/common/configuration.js'; +import { IConfigurationService } from '../../../../../platform/configuration/common/configuration.js'; import { PositronActionBar } from '../../../../../platform/positronActionBar/browser/positronActionBar.js'; import { IWorkbenchLayoutService } from '../../../../services/layout/browser/layoutService.js'; import { ActionBarRegion } from '../../../../../platform/positronActionBar/browser/components/actionBarRegion.js'; @@ -32,7 +32,6 @@ import { INotificationService } from '../../../../../platform/notification/commo import { PlotActionTarget, PlotsClearAction, PlotsCopyAction, PlotsNextAction, PlotsPopoutAction, PlotsPreviousAction, PlotsSaveAction } from '../positronPlotsActions.js'; import { IHoverService } from '../../../../../platform/hover/browser/hover.js'; import { HtmlPlotClient } from '../htmlPlotClient.js'; -import { POSITRON_EDITOR_PLOTS, positronPlotsEditorEnabled } from '../../../positronPlotsEditor/browser/positronPlotsEditor.contribution.js'; import { IAccessibilityService } from '../../../../../platform/accessibility/common/accessibility.js'; import { OpenInEditorMenuButton } from './openInEditorMenuButton.js'; @@ -66,7 +65,6 @@ export interface ActionBarsProps { export const ActionBars = (props: PropsWithChildren) => { // Hooks. const positronPlotsContext = usePositronPlotsContext(); - const [useEditorPlots, setUseEditorPlots] = React.useState(positronPlotsEditorEnabled(props.configurationService)); // Do we have any plots? const noPlots = positronPlotsContext.positronPlotInstances.length === 0; @@ -94,19 +92,10 @@ export const ActionBars = (props: PropsWithChildren) => { const enablePopoutPlot = hasPlots && selectedPlot instanceof HtmlPlotClient; - const enableEditorPlot = hasPlots && useEditorPlots + const enableEditorPlot = hasPlots && (selectedPlot instanceof PlotClientInstance || selectedPlot instanceof StaticPlotClient); - useEffect(() => { - const disposable = props.configurationService.onDidChangeConfiguration((event: IConfigurationChangeEvent) => { - if (event.affectedKeys.has(POSITRON_EDITOR_PLOTS)) { - setUseEditorPlots(positronPlotsEditorEnabled(props.configurationService)); - } - }); - return () => disposable.dispose(); - }, [props.configurationService]); - // Clear all the plots from the service. const clearAllPlotsHandler = () => { if (hasPlots) { diff --git a/src/vs/workbench/contrib/positronPlots/browser/positronPlotsActions.ts b/src/vs/workbench/contrib/positronPlots/browser/positronPlotsActions.ts index c9a9d8a252b..80e4d0d838f 100644 --- a/src/vs/workbench/contrib/positronPlots/browser/positronPlotsActions.ts +++ b/src/vs/workbench/contrib/positronPlots/browser/positronPlotsActions.ts @@ -455,11 +455,11 @@ export class PlotsActiveEditorCopyAction extends Action2 { category, f1: false, // do not show in the command palette icon: Codicon.copy, - precondition: ContextKeyExpr.and(ContextKeyExpr.equals(`config.${POSITRON_EDITOR_PLOTS}`, true), PLOT_IS_ACTIVE_EDITOR), + precondition: PLOT_IS_ACTIVE_EDITOR, menu: [ { id: MenuId.EditorTitle, - when: ContextKeyExpr.and(ContextKeyExpr.equals(`config.${POSITRON_EDITOR_PLOTS}`, true), PLOT_IS_ACTIVE_EDITOR), + when: PLOT_IS_ACTIVE_EDITOR, group: 'navigation', order: 2, } @@ -492,11 +492,11 @@ export class PlotsActiveEditorSaveAction extends Action2 { category, f1: false, // do not show in the command palette icon: Codicon.positronSave, - precondition: ContextKeyExpr.and(ContextKeyExpr.equals(`config.${POSITRON_EDITOR_PLOTS}`, true), PLOT_IS_ACTIVE_EDITOR), + precondition: PLOT_IS_ACTIVE_EDITOR, menu: [ { id: MenuId.EditorTitle, - when: ContextKeyExpr.and(ContextKeyExpr.equals(`config.${POSITRON_EDITOR_PLOTS}`, true), PLOT_IS_ACTIVE_EDITOR), + when: PLOT_IS_ACTIVE_EDITOR, group: 'navigation', order: 1, } diff --git a/src/vs/workbench/contrib/positronPlotsEditor/browser/positronPlotsEditor.contribution.ts b/src/vs/workbench/contrib/positronPlotsEditor/browser/positronPlotsEditor.contribution.ts index e4d4bcf07c5..f556cbbc2c4 100644 --- a/src/vs/workbench/contrib/positronPlotsEditor/browser/positronPlotsEditor.contribution.ts +++ b/src/vs/workbench/contrib/positronPlotsEditor/browser/positronPlotsEditor.contribution.ts @@ -6,14 +6,11 @@ import { Disposable } from '../../../../base/common/lifecycle.js'; import { Schemas } from '../../../../base/common/network.js'; import { localize } from '../../../../nls.js'; -import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js'; -import { IConfigurationRegistry, Extensions as ConfigurationExtensions, ConfigurationScope } from '../../../../platform/configuration/common/configurationRegistry.js'; import { ContextKeyExpr } from '../../../../platform/contextkey/common/contextkey.js'; import { SyncDescriptor } from '../../../../platform/instantiation/common/descriptors.js'; import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js'; import { Registry } from '../../../../platform/registry/common/platform.js'; import { EditorPaneDescriptor, IEditorPaneRegistry } from '../../../browser/editor.js'; -import { applicationConfigurationNodeBase } from '../../../common/configuration.js'; import { registerWorkbenchContribution2, WorkbenchPhase } from '../../../common/contributions.js'; import { EditorExtensions } from '../../../common/editor.js'; import { PositronPlotsEditor } from './positronPlotsEditor.js'; @@ -79,22 +76,4 @@ registerWorkbenchContribution2( WorkbenchPhase.AfterRestored ); -const configurationRegistry = Registry.as(ConfigurationExtensions.Configuration); -configurationRegistry.registerConfiguration({ - ...applicationConfigurationNodeBase, - properties: { - [POSITRON_EDITOR_PLOTS]: { - scope: ConfigurationScope.APPLICATION, - type: 'boolean', - default: false, - tags: ['experimental'], - description: localize('workbench.positronPlotsEditor.description', 'When enabled, plots can be opened in an editor tab.') - } - } -}); - -export function positronPlotsEditorEnabled(configurationService: IConfigurationService) { - return Boolean(configurationService.getValue(POSITRON_EDITOR_PLOTS)); -} - export const PLOT_IS_ACTIVE_EDITOR = ContextKeyExpr.equals('activeEditor', PositronPlotsEditorInput.EditorID);