diff --git a/public/app/plugins/datasource/graphite/state/actions.ts b/public/app/plugins/datasource/graphite/state/actions.ts index faa5ae79561..f690366e3fb 100644 --- a/public/app/plugins/datasource/graphite/state/actions.ts +++ b/public/app/plugins/datasource/graphite/state/actions.ts @@ -8,7 +8,12 @@ import { TimeRange } from '@grafana/data'; */ const init = createAction('init'); -const updateTimeRange = createAction('update-time-range'); + +/** + * Used only to sync it with selected range from Explore/Panel. This action + * does not allow to modify the currently selected range. + */ +const timeRangeChanged = createAction('time-range-changed'); // Metrics & Tags const segmentValueChanged = createAction<{ segment: GraphiteSegment | string; index: number }>('segment-value-changed'); @@ -31,7 +36,7 @@ const toggleEditorMode = createAction('toggle-editor'); export const actions = { init, - updateTimeRange, + timeRangeChanged, segmentValueChanged, tagChanged, addNewTag, diff --git a/public/app/plugins/datasource/graphite/state/context.tsx b/public/app/plugins/datasource/graphite/state/context.tsx index 750c315c5f0..6433325f773 100644 --- a/public/app/plugins/datasource/graphite/state/context.tsx +++ b/public/app/plugins/datasource/graphite/state/context.tsx @@ -37,8 +37,8 @@ export const GraphiteQueryEditorContext = ({ }, []); useEffect(() => { - dispatch(actions.updateTimeRange(range)); - }, [range]); + dispatch(actions.timeRangeChanged(range)); + }, [dispatch, range]); if (!state) { dispatch( diff --git a/public/app/plugins/datasource/graphite/state/store.ts b/public/app/plugins/datasource/graphite/state/store.ts index b0f64f46e3d..91699735ce4 100644 --- a/public/app/plugins/datasource/graphite/state/store.ts +++ b/public/app/plugins/datasource/graphite/state/store.ts @@ -72,7 +72,7 @@ const reducer = async (action: Action, state: GraphiteQueryEditorState): Promise await buildSegments(state, false); } - if (actions.updateTimeRange.match(action)) { + if (actions.timeRangeChanged.match(action)) { state.range = action.payload; } if (actions.segmentValueChanged.match(action)) {