DataTrails: Do not create a new VizPanel every activation (#85693)
This commit is contained in:
@@ -20,10 +20,11 @@ export class AutoVizPanel extends SceneObjectBase<AutoVizPanelState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public onActivate() {
|
public onActivate() {
|
||||||
const { autoQuery } = getMetricSceneFor(this).state;
|
if (!this.state.panel) {
|
||||||
this.setState({
|
const { autoQuery } = getMetricSceneFor(this).state;
|
||||||
panel: this.getVizPanelFor(autoQuery.main),
|
|
||||||
});
|
this.setState({ panel: this.getVizPanelFor(autoQuery.main) });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private getQuerySelector(def: AutoQueryDef) {
|
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)!;
|
const def = metricScene.state.autoQuery.variants.find((q) => q.variant === variant)!;
|
||||||
|
|
||||||
this.setState({
|
this.setState({ panel: this.getVizPanelFor(def) });
|
||||||
panel: this.getVizPanelFor(def),
|
|
||||||
});
|
|
||||||
metricScene.setState({ queryDef: def });
|
metricScene.setState({ queryDef: def });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -72,8 +72,6 @@ function getStyles(theme: GrafanaTheme2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function buildGraphTopView() {
|
function buildGraphTopView() {
|
||||||
const bodyAutoVizPanel = new AutoVizPanel({});
|
|
||||||
|
|
||||||
return new SceneFlexLayout({
|
return new SceneFlexLayout({
|
||||||
direction: 'column',
|
direction: 'column',
|
||||||
$behaviors: [new behaviors.CursorSync({ key: 'metricCrosshairSync', sync: DashboardCursorSync.Crosshair })],
|
$behaviors: [new behaviors.CursorSync({ key: 'metricCrosshairSync', sync: DashboardCursorSync.Crosshair })],
|
||||||
@@ -81,7 +79,7 @@ function buildGraphTopView() {
|
|||||||
new SceneFlexItem({
|
new SceneFlexItem({
|
||||||
minHeight: MAIN_PANEL_MIN_HEIGHT,
|
minHeight: MAIN_PANEL_MIN_HEIGHT,
|
||||||
maxHeight: MAIN_PANEL_MAX_HEIGHT,
|
maxHeight: MAIN_PANEL_MAX_HEIGHT,
|
||||||
body: bodyAutoVizPanel,
|
body: new AutoVizPanel({}),
|
||||||
}),
|
}),
|
||||||
new SceneFlexItem({
|
new SceneFlexItem({
|
||||||
ySizing: 'content',
|
ySizing: 'content',
|
||||||
|
|||||||
Reference in New Issue
Block a user