Skip to content
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

feat(panel-plugin): allow setting different views #1712

Merged
merged 7 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ export default function FlameGraphComponent(props: FlamegraphProps) {
};

const OpenInSandwichViewItem = () => {
if (!updateView) {
return null;
}

const handleClick = () => {
if (updateView) {
updateView('sandwich');
Expand Down Expand Up @@ -271,7 +275,7 @@ export default function FlameGraphComponent(props: FlamegraphProps) {
HighlightSimilarNodesItem(),
OpenInSandwichViewItem(),
FitModeItem(),
];
].filter(Boolean) as JSX.Element[];
},
[flamegraph, selectedItem, fitMode]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ class FlameGraphRenderer extends Component<
highlightQuery={this.getHighlightQuery()}
setActiveItem={this.setActiveItem}
selectedItem={this.state.selectedItem}
updateView={this.updateView}
updateView={this.props.onlyDisplay ? undefined : this.updateView}
fitMode={this.state.fitMode}
updateFitMode={this.updateFitMode}
zoom={this.state.flamegraphConfigs.zoom}
Expand Down
5 changes: 3 additions & 2 deletions packages/pyroscope-panel-plugin/src/SimplePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ export const SimplePanel: React.FC<Props> = ({ options, data }) => {
<div className={`flamegraph-wrapper ${styles.panel}`}>
<FlamegraphRenderer
flamebearer={flamebearer}
ExportData={<div />}
onlyDisplay="flamegraph"
onlyDisplay={
options.displayOnly === 'off' ? undefined : options.displayOnly
}
showToolbar={options.showToolbar}
colorMode={config.theme2.colors.mode}
/>
Expand Down
30 changes: 23 additions & 7 deletions packages/pyroscope-panel-plugin/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,27 @@ loadPluginCss({
export const plugin = new PanelPlugin<SimpleOptions>(
SimplePanel
).setPanelOptions((builder) => {
return builder.addBooleanSwitch({
description:
'Whether to show the toolbar. Keep in mind most of the same functionality can be accessed by right-clicking the flamegraph.',
path: 'showToolbar',
name: 'Show toolbar',
defaultValue: false,
});
return builder
.addBooleanSwitch({
description:
'Whether to show the toolbar. Keep in mind most of the same functionality can be accessed by right-clicking the flamegraph.',
path: 'showToolbar',
name: 'Show toolbar',
defaultValue: false,
})
.addSelect({
path: 'displayOnly',
name: 'Display only',
description: 'Only display a single view, not allowing to change',
defaultValue: 'flamegraph',
settings: {
options: [
{ value: 'flamegraph', label: 'Flamegraph' },
{ value: 'table', label: 'Table' },
{ value: 'both', label: 'Flamegraph + Table' },
{ value: 'sandwich', label: 'Sandwich' },
{ value: 'off', label: 'Off' },
],
},
});
});
1 change: 1 addition & 0 deletions packages/pyroscope-panel-plugin/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export interface SimpleOptions {
seriesCountSize: SeriesSize;

showToolbar: boolean;
displayOnly: 'flamegraph' | 'table' | 'both' | 'sandwich' | 'off';
}