From 9f205cf1d73a03f59c132e7d5a3340feac455064 Mon Sep 17 00:00:00 2001 From: carrieedwards Date: Thu, 4 Nov 2021 10:17:21 -0700 Subject: [PATCH] Graphite: Add from and until params to tag handling methods (#41319) --- .../datasource/graphite/specs/store.test.ts | 14 ++++++++++++++ .../plugins/datasource/graphite/state/providers.ts | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/public/app/plugins/datasource/graphite/specs/store.test.ts b/public/app/plugins/datasource/graphite/specs/store.test.ts index 0a5ab8ba57e..059a83956ef 100644 --- a/public/app/plugins/datasource/graphite/specs/store.test.ts +++ b/public/app/plugins/datasource/graphite/specs/store.test.ts @@ -210,6 +210,20 @@ describe('Graphite actions', async () => { }); }); + it('current time range is passed when getting list of tags when editing', async () => { + const currentRange = { from: 0, to: 1 }; + ctx.state.range = currentRange; + await getTagsSelectables(ctx.state, 0, 'any'); + expect(ctx.state.datasource.getTagsAutoComplete).toBeCalledWith([], 'any', { range: currentRange }); + }); + + it('current time range is passed when getting list of tags for adding', async () => { + const currentRange = { from: 0, to: 1 }; + ctx.state.range = currentRange; + await getTagsAsSegmentsSelectables(ctx.state, 'any'); + expect(ctx.state.datasource.getTagsAutoComplete).toBeCalledWith([], 'any', { range: currentRange }); + }); + describe('when autocomplete for metric names is not available', () => { silenceConsoleOutput(); beforeEach(() => { diff --git a/public/app/plugins/datasource/graphite/state/providers.ts b/public/app/plugins/datasource/graphite/state/providers.ts index ade27bd9578..18ffc53c63b 100644 --- a/public/app/plugins/datasource/graphite/state/providers.ts +++ b/public/app/plugins/datasource/graphite/state/providers.ts @@ -106,7 +106,7 @@ export function getTagOperatorsSelectables(): Array { try { const tagExpressions = state.queryModel.renderTagExpressions(index); - const values = await state.datasource.getTagsAutoComplete(tagExpressions, tagPrefix); + const values = await state.datasource.getTagsAutoComplete(tagExpressions, tagPrefix, { range: state.range }); const altTags = map(values, 'text'); altTags.splice(0, 0, state.removeTagValue); @@ -134,7 +134,7 @@ async function getTagsAsSegments(state: GraphiteQueryEditorState, tagPrefix: str let tagsAsSegments: GraphiteSegment[]; try { const tagExpressions = state.queryModel.renderTagExpressions(); - const values = await state.datasource.getTagsAutoComplete(tagExpressions, tagPrefix); + const values = await state.datasource.getTagsAutoComplete(tagExpressions, tagPrefix, { range: state.range }); tagsAsSegments = map(values, (val) => { return { value: val.text,