DataTrails: Do not create a new VizPanel every activation (#85693)

This commit is contained in:
Torkel Ödegaard 2024-04-09 08:39:26 +02:00 committed by GitHub
parent 509691b416
commit 4f290ebf99
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 10 deletions

View File

@ -20,10 +20,11 @@ export class AutoVizPanel extends SceneObjectBase<AutoVizPanelState> {
}
public onActivate() {
const { autoQuery } = getMetricSceneFor(this).state;
this.setState({
panel: this.getVizPanelFor(autoQuery.main),
});
if (!this.state.panel) {
const { autoQuery } = getMetricSceneFor(this).state;
this.setState({ panel: this.getVizPanelFor(autoQuery.main) });
}
}
private getQuerySelector(def: AutoQueryDef) {
@ -43,9 +44,7 @@ export class AutoVizPanel extends SceneObjectBase<AutoVizPanelState> {
const def = metricScene.state.autoQuery.variants.find((q) => q.variant === variant)!;
this.setState({
panel: this.getVizPanelFor(def),
});
this.setState({ panel: this.getVizPanelFor(def) });
metricScene.setState({ queryDef: def });
};

View File

@ -72,8 +72,6 @@ function getStyles(theme: GrafanaTheme2) {
}
function buildGraphTopView() {
const bodyAutoVizPanel = new AutoVizPanel({});
return new SceneFlexLayout({
direction: 'column',
$behaviors: [new behaviors.CursorSync({ key: 'metricCrosshairSync', sync: DashboardCursorSync.Crosshair })],
@ -81,7 +79,7 @@ function buildGraphTopView() {
new SceneFlexItem({
minHeight: MAIN_PANEL_MIN_HEIGHT,
maxHeight: MAIN_PANEL_MAX_HEIGHT,
body: bodyAutoVizPanel,
body: new AutoVizPanel({}),
}),
new SceneFlexItem({
ySizing: 'content',