diff --git a/public/app/features/trails/DataTrailsHistory.tsx b/public/app/features/trails/DataTrailsHistory.tsx index c562b85cd30..c0c4fd2f6d6 100644 --- a/public/app/features/trails/DataTrailsHistory.tsx +++ b/public/app/features/trails/DataTrailsHistory.tsx @@ -69,7 +69,7 @@ export class DataTrailHistory extends SceneObjectBase { this.state.steps[0].trailState = sceneUtils.cloneSceneObjectState(oldState, { history: this }); } - if (newState.metric) { + if (newState.metric || oldState.metric) { this.addTrailStep(trail, 'metric'); } } @@ -131,7 +131,7 @@ export class DataTrailHistory extends SceneObjectBase { return (
{step.type}
- {step.type === 'metric' &&
{step.trailState.metric}
} + {step.type === 'metric' &&
{step.trailState.metric || 'Select new metric'}
}
); } @@ -163,29 +163,38 @@ export class DataTrailHistory extends SceneObjectBase { return (
History
- {steps.map((step, index) => ( - model.renderStepTooltip(step)} key={index}> - - - ))} + {steps.map((step, index) => { + let stepType = step.type; + + if (stepType === 'metric' && step.trailState.metric === undefined) { + // If we're resetting the metric, we want it to look like a start node + stepType = 'start'; + } + + return ( + model.renderStepTooltip(step)} key={index}> + + + ); + })}
); }; diff --git a/public/app/features/trails/MetricScene.tsx b/public/app/features/trails/MetricScene.tsx index 29971855954..0ffd8f7ad63 100644 --- a/public/app/features/trails/MetricScene.tsx +++ b/public/app/features/trails/MetricScene.tsx @@ -29,6 +29,7 @@ import { ActionViewType, getVariablesWithMetricConstant, MakeOptional, + MetricSelectedEvent, trailDS, VAR_GROUP_BY, VAR_METRIC_EXPR, @@ -155,6 +156,13 @@ export class MetricActionBar extends SceneObjectBase {
+ trail.publishEvent(new MetricSelectedEvent(undefined))} + > + Select new metric + { +export class MetricSelectedEvent extends BusEventWithPayload { public static type = 'metric-selected-event'; }