mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge pull request #14170 from grafana/davkal/explore-prometheus-range-sort
Sort Prometheus range suggestions by length
This commit is contained in:
commit
efcbb92b3f
@ -9,8 +9,8 @@ import {
|
|||||||
TypeaheadOutput,
|
TypeaheadOutput,
|
||||||
} from 'app/types/explore';
|
} from 'app/types/explore';
|
||||||
|
|
||||||
import { parseSelector, processLabels, RATE_RANGES } from './language_utils';
|
import { parseSelector, processLabels } from './language_utils';
|
||||||
import PromqlSyntax, { FUNCTIONS } from './promql';
|
import PromqlSyntax, { FUNCTIONS, RATE_RANGES } from './promql';
|
||||||
|
|
||||||
const DEFAULT_KEYS = ['job', 'instance'];
|
const DEFAULT_KEYS = ['job', 'instance'];
|
||||||
const EMPTY_SELECTOR = '{}';
|
const EMPTY_SELECTOR = '{}';
|
||||||
@ -172,7 +172,7 @@ export default class PromQlLanguageProvider extends LanguageProvider {
|
|||||||
suggestions: [
|
suggestions: [
|
||||||
{
|
{
|
||||||
label: 'Range vector',
|
label: 'Range vector',
|
||||||
items: [...RATE_RANGES].map(wrapLabel),
|
items: [...RATE_RANGES],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
@ -1,8 +1,19 @@
|
|||||||
/* tslint:disable max-line-length */
|
/* tslint:disable max-line-length */
|
||||||
|
|
||||||
|
import { CompletionItem } from 'app/types/explore';
|
||||||
|
|
||||||
|
export const RATE_RANGES: CompletionItem[] = [
|
||||||
|
{ label: '1m', sortText: '00:01:00' },
|
||||||
|
{ label: '5m', sortText: '00:05:00' },
|
||||||
|
{ label: '10m', sortText: '00:10:00' },
|
||||||
|
{ label: '30m', sortText: '00:30:00' },
|
||||||
|
{ label: '1h', sortText: '01:00:00' },
|
||||||
|
{ label: '1d', sortText: '24:00:00' },
|
||||||
|
];
|
||||||
|
|
||||||
export const OPERATORS = ['by', 'group_left', 'group_right', 'ignoring', 'on', 'offset', 'without'];
|
export const OPERATORS = ['by', 'group_left', 'group_right', 'ignoring', 'on', 'offset', 'without'];
|
||||||
|
|
||||||
const AGGREGATION_OPERATORS = [
|
const AGGREGATION_OPERATORS: CompletionItem[] = [
|
||||||
{
|
{
|
||||||
label: 'sum',
|
label: 'sum',
|
||||||
insertText: 'sum',
|
insertText: 'sum',
|
||||||
|
@ -76,9 +76,16 @@ describe('Language completion provider', () => {
|
|||||||
});
|
});
|
||||||
expect(result.context).toBe('context-range');
|
expect(result.context).toBe('context-range');
|
||||||
expect(result.refresher).toBeUndefined();
|
expect(result.refresher).toBeUndefined();
|
||||||
expect(result.suggestions).toEqual([
|
expect(result.suggestions).toMatchObject([
|
||||||
{
|
{
|
||||||
items: [{ label: '1m' }, { label: '5m' }, { label: '10m' }, { label: '30m' }, { label: '1h' }],
|
items: [
|
||||||
|
{ label: '1m' },
|
||||||
|
{ label: '5m' },
|
||||||
|
{ label: '10m' },
|
||||||
|
{ label: '30m' },
|
||||||
|
{ label: '1h' },
|
||||||
|
{ label: '1d' },
|
||||||
|
],
|
||||||
label: 'Range vector',
|
label: 'Range vector',
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
Loading…
Reference in New Issue
Block a user