mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 20:24:18 -06:00
New Editor: use unit picker (#22033)
* use unit picker * export correct file name * override is the same
This commit is contained in:
parent
a58d2b87f8
commit
66191f946d
@ -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 {
|
||||
|
@ -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: {
|
||||
|
22
packages/grafana-ui/src/components/FieldConfigs/units.tsx
Normal file
22
packages/grafana-ui/src/components/FieldConfigs/units.tsx
Normal 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} />;
|
||||
};
|
Loading…
Reference in New Issue
Block a user