-
Notifications
You must be signed in to change notification settings - Fork 108
Plots in an editor #4364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Plots in an editor #4364
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
7120f74
Basic plots editor
timtmok 5d83e99
Display plot in editor
timtmok 4841985
Update open plot editor icon
timtmok 6ba2915
Set editor name to plot id
timtmok ac60398
Show plot editor button when applicable
timtmok 36e073c
Add feature flag
timtmok db00b39
Move setting to Application/Experimental
timtmok 0f89206
Apply suggestions from code review
timtmok 738df01
Review changes
timtmok 8cb23bb
Create plot client in backend
timtmok 0613f67
Revert "Create plot client in backend"
timtmok d0e7d0d
Shared plot comm
timtmok 6433e28
Initial comm cleanup when removing plots
timtmok 2b9ee3b
Handle comm close on editor close
timtmok 6104ec2
Fix unregisterPlotClient
timtmok c620eb9
Clean up preview calls
timtmok b72be8f
Fix disposing editor's plot client
timtmok e1ad439
Fix plot client disposed too early
timtmok 36e08bc
Formatting
timtmok dd16e43
Reconnect comm events
timtmok 1736e56
Apply suggestions from code review
timtmok 4c92b34
Review changes
timtmok 7f16e39
Fix rendering plot element
timtmok b695fbc
Refactor need for useCallback hook
timtmok File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ import { ICommandService } from 'vs/platform/commands/common/commands'; | |
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; | ||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; | ||
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; | ||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; | ||
import { IConfigurationChangeEvent, IConfigurationService } from 'vs/platform/configuration/common/configuration'; | ||
import { PositronActionBar } from 'vs/platform/positronActionBar/browser/positronActionBar'; | ||
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; | ||
import { ActionBarRegion } from 'vs/platform/positronActionBar/browser/components/actionBarRegion'; | ||
|
@@ -28,6 +28,7 @@ import { INotificationService } from 'vs/platform/notification/common/notificati | |
import { PlotsClearAction, PlotsCopyAction, PlotsNextAction, PlotsPopoutAction, PlotsPreviousAction, PlotsSaveAction } from 'vs/workbench/contrib/positronPlots/browser/positronPlotsActions'; | ||
import { IHoverService } from 'vs/platform/hover/browser/hover'; | ||
import { HtmlPlotClient } from 'vs/workbench/contrib/positronPlots/browser/htmlPlotClient'; | ||
import { POSITRON_EDITOR_PLOTS, positronPlotsEditorEnabled } from 'vs/workbench/contrib/positronPlotsEditor/browser/positronPlotsEditor.contribution'; | ||
|
||
// Constants. | ||
const kPaddingLeft = 14; | ||
|
@@ -58,6 +59,7 @@ export interface ActionBarsProps { | |
export const ActionBars = (props: PropsWithChildren<ActionBarsProps>) => { | ||
// Hooks. | ||
const positronPlotsContext = usePositronPlotsContext(); | ||
const [useEditorPlots, setUseEditorPlots] = React.useState<boolean>(positronPlotsEditorEnabled(props.configurationService)); | ||
|
||
// Do we have any plots? | ||
const noPlots = positronPlotsContext.positronPlotInstances.length === 0; | ||
|
@@ -85,9 +87,18 @@ export const ActionBars = (props: PropsWithChildren<ActionBarsProps>) => { | |
const enablePopoutPlot = hasPlots && | ||
selectedPlot instanceof HtmlPlotClient; | ||
|
||
const enableEditorPlot = hasPlots && useEditorPlots | ||
&& (selectedPlot instanceof PlotClientInstance | ||
|| selectedPlot instanceof StaticPlotClient); | ||
|
||
useEffect(() => { | ||
// Empty for now. | ||
}); | ||
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 = () => { | ||
|
@@ -136,28 +147,43 @@ export const ActionBars = (props: PropsWithChildren<ActionBarsProps>) => { | |
<ActionBarButton iconId='positron-right-arrow' disabled={disableRight} tooltip={localize('positronShowNextPlot', "Show next plot")} | ||
ariaLabel={localize('positronShowNextPlot', "Show next plot")} onPressed={showNextPlotHandler} /> | ||
|
||
{(enableSizingPolicy || enableSavingPlots || enableZoomPlot || enablePopoutPlot) && <ActionBarSeparator />} | ||
{enableSavingPlots && <ActionBarButton iconId='positron-save' tooltip={localize('positronSavePlot', "Save plot")} | ||
ariaLabel={localize('positronSavePlot', "Save plot")} onPressed={savePlotHandler} />} | ||
{enableCopyPlot && <ActionBarButton iconId='copy' disabled={!hasPlots} tooltip={localize('positron-copy-plot', "Copy plot to clipboard")} ariaLabel={localize('positron-copy-plot', "Copy plot to clipboard")} | ||
onPressed={copyPlotHandler} />} | ||
{enableZoomPlot && <ZoomPlotMenuButton actionHandler={zoomPlotHandler} zoomLevel={props.zoomLevel} />} | ||
{enableSizingPolicy && | ||
{(enableSizingPolicy || enableSavingPlots || enableZoomPlot || enablePopoutPlot) ? <ActionBarSeparator /> : null} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. super-nit: I would maybe extract the long |
||
{enableSavingPlots ? <ActionBarButton iconId='positron-save' tooltip={localize('positronSavePlot', "Save plot")} | ||
ariaLabel={localize('positronSavePlot', "Save plot")} onPressed={savePlotHandler} /> : null} | ||
{enableCopyPlot ? <ActionBarButton iconId='copy' disabled={!hasPlots} tooltip={localize('positron-copy-plot', "Copy plot to clipboard")} ariaLabel={localize('positron-copy-plot', "Copy plot to clipboard")} | ||
onPressed={copyPlotHandler} /> : null} | ||
{enableZoomPlot ? <ZoomPlotMenuButton actionHandler={zoomPlotHandler} zoomLevel={props.zoomLevel} /> : null} | ||
{enableSizingPolicy ? | ||
<SizingPolicyMenuButton | ||
keybindingService={props.keybindingService} | ||
layoutService={props.layoutService} | ||
notificationService={positronPlotsContext.notificationService} | ||
plotsService={positronPlotsContext.positronPlotsService} | ||
plotClient={selectedPlot} | ||
/> | ||
: null | ||
} | ||
{enablePopoutPlot && | ||
{enablePopoutPlot ? | ||
<ActionBarButton | ||
iconId='positron-open-in-new-window' | ||
align='right' | ||
tooltip={localize('positron-popout-plot', "Open plot in new window")} | ||
ariaLabel={localize('positron-popout-plot', "Open plot in new window")} | ||
onPressed={popoutPlotHandler} /> | ||
: null | ||
} | ||
{enableEditorPlot ? | ||
<ActionBarButton | ||
iconId='go-to-file' | ||
align='right' | ||
tooltip={localize('positron-open-plot-editor', "Open plot in editor")} | ||
ariaLabel={localize('positron-open-plot-editor', "Open plot in editor")} | ||
onPressed={() => { | ||
if (hasPlots) { | ||
positronPlotsContext.positronPlotsService.openEditor(); | ||
} | ||
}} /> | ||
: null | ||
} | ||
</ActionBarRegion> | ||
<ActionBarRegion location='right'> | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call on the initial value to avoid a potentially unnecessary render.