mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Explore: Improve parsing ranges from URL (#72498)
* Fix parsing absolute range * Silence warning issued by moment js * Introduce URLRangeValue to enforce better type-checking * Fix unit tests * Allow not passing range to generate ExploreUrl * Use updated time range format in a test * Allow empty object to be passed as a data link for backward compatibility * Update mocks * Post-merge fixes * Simplify checking if range is passed as an empty object * Update docs
This commit is contained in:
@@ -87,7 +87,7 @@ describe('getExploreUrl', () => {
|
||||
getDataSourceById: jest.fn(),
|
||||
},
|
||||
timeSrv: {
|
||||
timeRangeForUrl: () => '1',
|
||||
timeRange: () => ({ raw: { from: 'now-1h', to: 'now' } }),
|
||||
},
|
||||
} as unknown as GetExploreUrlArguments;
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
RawTimeRange,
|
||||
TimeRange,
|
||||
TimeZone,
|
||||
toURLRange,
|
||||
urlUtil,
|
||||
} from '@grafana/data';
|
||||
import { DataSourceSrv, getDataSourceSrv } from '@grafana/runtime';
|
||||
@@ -76,8 +77,8 @@ export async function getExploreUrl(args: GetExploreUrlArguments): Promise<strin
|
||||
let url: string | undefined;
|
||||
|
||||
if (exploreDatasource) {
|
||||
const range = timeSrv.timeRangeForUrl();
|
||||
let state: Partial<ExploreUrlState> = { range };
|
||||
const range = timeSrv.timeRange().raw;
|
||||
let state: Partial<ExploreUrlState> = { range: toURLRange(range) };
|
||||
if (exploreDatasource.interpolateVariablesInQueries) {
|
||||
const scopedVars = panel.scopedVars || {};
|
||||
state = {
|
||||
|
||||
Reference in New Issue
Block a user