grafana/public/test/helpers/getQueryOptions.ts
Torkel Ödegaard 45b7de1910
Explore: Moves PromContext from query level to DataQueryRequest level (#21260)
Closes #19598

Fixes bug introduced recently where the new PromQueryEditor did not preserve
the PromContext.Explore set on the query model by PromQueryField which caused
the table to be empty for Prometheus in explore.
2019-12-27 09:11:16 +01:00

29 lines
721 B
TypeScript

import { DataQueryRequest, DataQuery, CoreApp } from '@grafana/data';
import { dateTime } from '@grafana/data';
export function getQueryOptions<TQuery extends DataQuery>(
options: Partial<DataQueryRequest<TQuery>>
): DataQueryRequest<TQuery> {
const raw = { from: 'now', to: 'now-1h' };
const range = { from: dateTime(), to: dateTime(), raw: raw };
const defaults: DataQueryRequest<TQuery> = {
requestId: 'TEST',
app: CoreApp.Dashboard,
range: range,
targets: [],
scopedVars: {},
timezone: 'browser',
panelId: 1,
dashboardId: 1,
interval: '60s',
intervalMs: 60000,
maxDataPoints: 500,
startTime: 0,
};
Object.assign(defaults, options);
return defaults;
}