mirror of
https://github.com/grafana/grafana.git
synced 2025-02-14 17:43:35 -06:00
Grafana-ui: Get rid of duplicated code in TimeRangeContent
(#74112)
This commit is contained in:
parent
42efd13062
commit
e079e00bfb
@ -2,7 +2,6 @@ import { css } from '@emotion/css';
|
||||
import React, { FormEvent, useCallback, useEffect, useState } from 'react';
|
||||
|
||||
import {
|
||||
dateMath,
|
||||
DateTime,
|
||||
dateTimeFormat,
|
||||
dateTimeParse,
|
||||
@ -21,6 +20,7 @@ import { t, Trans } from '../../../utils/i18n';
|
||||
import { Button } from '../../Button';
|
||||
import { Field } from '../../Forms/Field';
|
||||
import { Input } from '../../Input/Input';
|
||||
import { isValid } from '../utils';
|
||||
|
||||
import TimePickerCalendar from './TimePickerCalendar';
|
||||
|
||||
@ -208,19 +208,6 @@ function valueAsString(value: DateTime | string, timeZone?: TimeZone): string {
|
||||
return value;
|
||||
}
|
||||
|
||||
function isValid(value: string, roundUp?: boolean, timeZone?: TimeZone): boolean {
|
||||
if (isDateTime(value)) {
|
||||
return value.isValid();
|
||||
}
|
||||
|
||||
if (dateMath.isMathString(value)) {
|
||||
return dateMath.isValid(value);
|
||||
}
|
||||
|
||||
const parsed = dateTimeParse(value, { roundUp, timeZone });
|
||||
return parsed.isValid();
|
||||
}
|
||||
|
||||
function getStyles(theme: GrafanaTheme2) {
|
||||
return {
|
||||
fieldContainer: css({
|
||||
|
Loading…
Reference in New Issue
Block a user