Commit 66a4d1a5 by Ryan McKinley Committed by GitHub

Refactor: fix range util imports (#17988)

parent ccc3d88c
import { TimeRange, TIME_FORMAT, RawTimeRange, TimeZone } from '@grafana/data'; import {
import { describeTimeRange } from '@grafana/data/src/utils/rangeutil'; TimeRange,
import { dateMath } from '@grafana/data'; TIME_FORMAT,
import { isDateTime, dateTime, DateTime, toUtc } from '@grafana/data'; RawTimeRange,
TimeZone,
rangeUtil,
dateMath,
isDateTime,
dateTime,
DateTime,
toUtc,
} from '@grafana/data';
export const rawToTimeRange = (raw: RawTimeRange, timeZone?: TimeZone): TimeRange => { export const rawToTimeRange = (raw: RawTimeRange, timeZone?: TimeZone): TimeRange => {
const from = stringToDateTimeType(raw.from, false, timeZone); const from = stringToDateTimeType(raw.from, false, timeZone);
...@@ -32,7 +40,7 @@ export const stringToDateTimeType = (value: string | DateTime, roundUp?: boolean ...@@ -32,7 +40,7 @@ export const stringToDateTimeType = (value: string | DateTime, roundUp?: boolean
}; };
export const mapTimeRangeToRangeString = (timeRange: RawTimeRange): string => { export const mapTimeRangeToRangeString = (timeRange: RawTimeRange): string => {
return describeTimeRange(timeRange); return rangeUtil.describeTimeRange(timeRange);
}; };
export const isValidTimeString = (text: string) => dateMath.isValid(text); export const isValidTimeString = (text: string) => dateMath.isValid(text);
...@@ -2,12 +2,19 @@ ...@@ -2,12 +2,19 @@
import React, { PureComponent, ChangeEvent, FocusEvent } from 'react'; import React, { PureComponent, ChangeEvent, FocusEvent } from 'react';
// Utils // Utils
import { isValidTimeSpan } from '@grafana/data/src/utils/rangeutil'; import { rangeUtil } from '@grafana/data';
// Components // Components
import { DataSourceSelectItem, EventsWithValidation, Input, InputStatus, Switch, ValidationEvents } from '@grafana/ui'; import {
DataSourceSelectItem,
EventsWithValidation,
Input,
InputStatus,
Switch,
ValidationEvents,
FormLabel,
} from '@grafana/ui';
import { DataSourceOption } from './DataSourceOption'; import { DataSourceOption } from './DataSourceOption';
import { FormLabel } from '@grafana/ui';
// Types // Types
import { PanelModel } from '../state'; import { PanelModel } from '../state';
...@@ -19,7 +26,7 @@ const timeRangeValidationEvents: ValidationEvents = { ...@@ -19,7 +26,7 @@ const timeRangeValidationEvents: ValidationEvents = {
if (!value) { if (!value) {
return true; return true;
} }
return isValidTimeSpan(value); return rangeUtil.isValidTimeSpan(value);
}, },
errorMessage: 'Not a valid timespan', errorMessage: 'Not a valid timespan',
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment