TimeZonePicker: expose for panel configuraiton (#23523)

This commit is contained in:
Ryan McKinley 2020-06-29 07:50:44 -07:00 committed by GitHub
parent 1378cadb68
commit c344422a68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 1 deletions

View File

@ -192,6 +192,15 @@ export class PanelOptionsEditorBuilder<TOptions> extends OptionsUIRegistryBuilde
});
}
addTimeZonePicker<TSettings = any>(config: PanelOptionsEditorConfig<TOptions, TSettings, string>): this {
return this.addCustomEditor({
...config,
id: config.path,
editor: standardEditorsRegistry.get('timezone').editor as any,
settings: config.settings || {},
});
}
addUnitPicker<TSettings = any>(
config: PanelOptionsEditorConfig<TOptions, TSettings & UnitFieldConfigSettings, string>
): this {

View File

@ -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<TimeZone> = {
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,
];
};