New Editor: use unit picker (#22033)

* use unit picker

* export correct file name

* override is the same
This commit is contained in:
Ryan McKinley 2020-02-09 10:29:10 +01:00 committed by GitHub
parent a58d2b87f8
commit 66191f946d
3 changed files with 27 additions and 4 deletions

View File

@ -25,7 +25,7 @@ export interface FieldConfigSource {
export interface FieldConfigEditorProps<TValue, TSettings> {
item: FieldPropertyEditorItem<TValue, TSettings>; // The property info
value: TValue;
onChange: (value: TValue) => void;
onChange: (value?: TValue) => void;
}
export interface FieldOverrideContext {
@ -38,7 +38,7 @@ export interface FieldOverrideEditorProps<TValue, TSettings> {
item: FieldPropertyEditorItem<TValue, TSettings>;
value: any;
context: FieldOverrideContext;
onChange: (value: any) => void;
onChange: (value?: any) => void;
}
export interface FieldPropertyEditorItem<TValue = any, TSettings = any> extends RegistryItem {

View File

@ -1,6 +1,7 @@
import { FieldConfigEditorRegistry, Registry, FieldPropertyEditorItem, ThresholdsConfig } from '@grafana/data';
import { StringValueEditor, StringOverrideEditor, stringOverrideProcessor, StringFieldConfigSettings } from './string';
import { NumberValueEditor, NumberOverrideEditor, numberOverrideProcessor, NumberFieldConfigSettings } from './number';
import { UnitValueEditor, UnitOverrideEditor } from './units';
import {
ThresholdsValueEditor,
ThresholdsOverrideEditor,
@ -27,8 +28,8 @@ const unit: FieldPropertyEditorItem<string, StringFieldConfigSettings> = {
name: 'Unit',
description: 'value units',
editor: StringValueEditor,
override: StringOverrideEditor,
editor: UnitValueEditor,
override: UnitOverrideEditor,
process: stringOverrideProcessor,
settings: {

View File

@ -0,0 +1,22 @@
import React from 'react';
import { FieldOverrideEditorProps, FieldConfigEditorProps } from '@grafana/data';
import { UnitPicker } from '../UnitPicker/UnitPicker';
export interface UnitFieldConfigSettings {
// ??
}
export const UnitValueEditor: React.FC<FieldConfigEditorProps<string, UnitFieldConfigSettings>> = ({
value,
onChange,
}) => {
return <UnitPicker value={value} onChange={onChange} />;
};
export const UnitOverrideEditor: React.FC<FieldOverrideEditorProps<string, UnitFieldConfigSettings>> = ({
value,
onChange,
}) => {
return <UnitPicker value={value} onChange={onChange} />;
};