datatrails: reloaded trail bugs related to no selected metric (#87344)

* fix: reloaded scene first step topScene

The top scene was not being initialized
when reloading trails, causing it to use
the top scene of whatever was selected
previously.

* fix: select new metric node not reloading right

On reloading trails, any metric node that
was 'green' with a undefined metric due to
clicking on the "select new metric" button,
was reloading with the metric of the step
directly before it (in index order).
pull/87347/head
Darren Janeczek 1 year ago committed by GitHub
parent 683390a4ec
commit e9b932c8f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 7
      public/app/features/trails/DataTrail.tsx

@ -169,6 +169,11 @@ export class DataTrail extends SceneObjectBase<DataTrailState> {
public restoreFromHistoryStep(state: DataTrailState) {
this.disableUrlSync();
if (!state.topScene && !state.metric) {
// If the top scene for an is missing, correct it.
state.topScene = new MetricSelectScene({});
}
this.setState(
sceneUtils.cloneSceneObjectState(state, {
history: this.state.history,
@ -213,7 +218,7 @@ export class DataTrail extends SceneObjectBase<DataTrailState> {
if (this.state.metric !== values.metric) {
Object.assign(stateUpdate, this.getSceneUpdatesForNewMetricValue(values.metric));
}
} else if (values.metric === null) {
} else if (values.metric == null) {
stateUpdate.metric = undefined;
stateUpdate.topScene = new MetricSelectScene({});
}

Loading…
Cancel
Save