Graphite: Add from and until params to tag handling methods (#41319)

This commit is contained in:
carrieedwards 2021-11-04 10:17:21 -07:00 committed by GitHub
parent 07d3bde4eb
commit 9f205cf1d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View File

@ -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(() => {

View File

@ -106,7 +106,7 @@ export function getTagOperatorsSelectables(): Array<SelectableValue<GraphiteTagO
async function getTags(state: GraphiteQueryEditorState, index: number, tagPrefix: string): Promise<string[]> {
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,