From c344422a681022fca96aa1d9853a7de35fcda74d Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Mon, 29 Jun 2020 07:50:44 -0700 Subject: [PATCH] TimeZonePicker: expose for panel configuraiton (#23523) --- .../src/utils/OptionsUIBuilders.ts | 9 +++++++ .../grafana-ui/src/utils/standardEditors.tsx | 25 ++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/packages/grafana-data/src/utils/OptionsUIBuilders.ts b/packages/grafana-data/src/utils/OptionsUIBuilders.ts index 5b828c89c18..52e4aef73ef 100644 --- a/packages/grafana-data/src/utils/OptionsUIBuilders.ts +++ b/packages/grafana-data/src/utils/OptionsUIBuilders.ts @@ -192,6 +192,15 @@ export class PanelOptionsEditorBuilder extends OptionsUIRegistryBuilde }); } + addTimeZonePicker(config: PanelOptionsEditorConfig): this { + return this.addCustomEditor({ + ...config, + id: config.path, + editor: standardEditorsRegistry.get('timezone').editor as any, + settings: config.settings || {}, + }); + } + addUnitPicker( config: PanelOptionsEditorConfig ): this { diff --git a/packages/grafana-ui/src/utils/standardEditors.tsx b/packages/grafana-ui/src/utils/standardEditors.tsx index 2e1f727fcbe..ba44239fcd1 100644 --- a/packages/grafana-ui/src/utils/standardEditors.tsx +++ b/packages/grafana-ui/src/utils/standardEditors.tsx @@ -17,6 +17,7 @@ import { ValueMappingFieldConfigSettings, valueMappingsOverrideProcessor, ThresholdsMode, + TimeZone, } from '@grafana/data'; import { Switch } from '../components/Switch/Switch'; @@ -26,6 +27,7 @@ import { StringValueEditor, StringArrayEditor, SelectValueEditor, + TimeZonePicker, } from '../components'; import { ValueMappingsValueEditor } from '../components/OptionsUI/mappings'; import { ThresholdsValueEditor } from '../components/OptionsUI/thresholds'; @@ -303,5 +305,26 @@ export const getStandardOptionEditors = () => { description: '', }; - return [text, number, boolean, radio, select, unit, mappings, thresholds, links, color, statsPicker, strings]; + const timeZone: StandardEditorsRegistryItem = { + id: 'timezone', + name: 'Time Zone', + description: 'Time zone selection', + editor: TimeZonePicker as any, + }; + + return [ + text, + number, + boolean, + radio, + select, + unit, + mappings, + thresholds, + links, + color, + statsPicker, + strings, + timeZone, + ]; };