Schema: Add TimeZone to mudball (#61003)

This commit is contained in:
Ryan McKinley 2023-01-12 14:54:02 -08:00 committed by GitHub
parent 245a589336
commit da3f02d81b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 8 deletions

View File

@ -1,3 +1,10 @@
import {
TimeZone as SchemaTimeZone,
TimeZoneBrowser as SchemaTimeZoneBrowser,
TimeZoneUtc as SchemaTimeZoneUtc,
defaultTimeZone,
} from '@grafana/schema';
import { dateTime, DateTime } from '../datetime/moment_wrapper';
export interface RawTimeRange {
@ -30,18 +37,24 @@ export interface IntervalValues {
intervalMs: number;
}
export type TimeZoneUtc = 'utc';
export type TimeZoneBrowser = 'browser';
export type TimeZone = TimeZoneBrowser | TimeZoneUtc | string;
export const DefaultTimeZone: TimeZone = 'browser';
export interface TimeOption {
from: string;
to: string;
display: string;
}
/** @deprecated use TimeZone from schema */
export type TimeZone = SchemaTimeZone;
/** @deprecated use TimeZoneBrowser from schema */
export type TimeZoneBrowser = SchemaTimeZoneBrowser;
/** @deprecated use TimeZoneUtc from schema */
export type TimeZoneUtc = SchemaTimeZoneUtc;
/** @deprecated use defaultTimeZone from schema */
export const DefaultTimeZone = defaultTimeZone;
export interface TimeOptions {
[key: string]: TimeOption[];
}

View File

@ -177,7 +177,7 @@ OptionsWithLegend: {
// TODO docs
OptionsWithTimezones: {
timezone?: [...string]
timezone?: [...TimeZone]
} @cuetsy(kind="interface")
// TODO docs
@ -300,3 +300,13 @@ VizTooltipOptions: {
mode: TooltipDisplayMode
sort: SortOrder
} @cuetsy(kind="interface")
// Use UTC/GMT timezone
TimeZoneUtc: "utc" @cuetsy(kind="type")
// Use the timezone defined by end user web browser
TimeZoneBrowser: "browser" @cuetsy(kind="type")
// A specific timezone from https://en.wikipedia.org/wiki/Tz_database
TimeZone: TimeZoneUtc | TimeZoneBrowser | string | *"browser" @cuetsy(kind="type")

View File

@ -331,7 +331,7 @@ export interface OptionsWithLegend {
* TODO docs
*/
export interface OptionsWithTimezones {
timezone?: Array<string>;
timezone?: Array<TimeZone>;
}
export const defaultOptionsWithTimezones: Partial<OptionsWithTimezones> = {
@ -547,3 +547,20 @@ export interface VizTooltipOptions {
mode: TooltipDisplayMode;
sort: SortOrder;
}
/**
* Use UTC/GMT timezone
*/
export type TimeZoneUtc = 'utc';
/**
* Use the timezone defined by end user web browser
*/
export type TimeZoneBrowser = 'browser';
/**
* A specific timezone from https://en.wikipedia.org/wiki/Tz_database
*/
export type TimeZone = (TimeZoneUtc | TimeZoneBrowser | string);
export const defaultTimeZone: TimeZone = 'browser';