diff --git a/packages/grafana-ui/src/components/SingleStatShared/FieldDisplayEditor.tsx b/packages/grafana-ui/src/components/SingleStatShared/FieldDisplayEditor.tsx index c663461224e..85a25565636 100644 --- a/packages/grafana-ui/src/components/SingleStatShared/FieldDisplayEditor.tsx +++ b/packages/grafana-ui/src/components/SingleStatShared/FieldDisplayEditor.tsx @@ -2,7 +2,6 @@ import React, { PureComponent, ChangeEvent } from 'react'; // Components -import { PanelOptionsGroup } from '../PanelOptionsGroup/PanelOptionsGroup'; import { FormLabel } from '../FormLabel/FormLabel'; import { FormField } from '../FormField/FormField'; import { StatsPicker } from '../StatsPicker/StatsPicker'; @@ -28,75 +27,71 @@ const showOptions: Array> = [ ]; export interface Props { - options: FieldDisplayOptions; - onChange: (valueOptions: FieldDisplayOptions) => void; labelWidth?: number; - children?: JSX.Element[]; + value: FieldDisplayOptions; + onChange: (value: FieldDisplayOptions, event?: React.SyntheticEvent) => void; } export class FieldDisplayEditor extends PureComponent { onShowValuesChange = (item: SelectOptionItem) => { const val = item.value === true; - this.props.onChange({ ...this.props.options, values: val }); + this.props.onChange({ ...this.props.value, values: val }); }; onCalcsChange = (calcs: string[]) => { - this.props.onChange({ ...this.props.options, calcs }); + this.props.onChange({ ...this.props.value, calcs }); }; onDefaultsChange = (value: Partial) => { - this.props.onChange({ ...this.props.options, defaults: value }); + this.props.onChange({ ...this.props.value, defaults: value }); }; onLimitChange = (event: ChangeEvent) => { this.props.onChange({ - ...this.props.options, + ...this.props.value, limit: toIntegerOrUndefined(event.target.value), }); }; render() { - const { options, children } = this.props; - const { calcs, values, limit } = options; + const { value } = this.props; + const { calcs, values, limit } = value; const labelWidth = this.props.labelWidth || 5; return ( - - <> + <> +
+ Show + Calc +
- {values ? ( - - ) : ( -
- Calc - -
- )} - {children} - -
+ )} + ); } } diff --git a/packages/grafana-ui/src/components/SingleStatShared/FieldPropertiesEditor.tsx b/packages/grafana-ui/src/components/SingleStatShared/FieldPropertiesEditor.tsx index d8fdb34341e..0c7858aef69 100644 --- a/packages/grafana-ui/src/components/SingleStatShared/FieldPropertiesEditor.tsx +++ b/packages/grafana-ui/src/components/SingleStatShared/FieldPropertiesEditor.tsx @@ -2,7 +2,6 @@ import React, { PureComponent, ChangeEvent } from 'react'; // Components -import { PanelOptionsGroup } from '../PanelOptionsGroup/PanelOptionsGroup'; import { FormField } from '../FormField/FormField'; import { FormLabel } from '../FormLabel/FormLabel'; import { UnitPicker } from '../UnitPicker/UnitPicker'; @@ -17,43 +16,42 @@ import { VAR_SERIES_NAME, VAR_FIELD_NAME, VAR_CALC, VAR_CELL_PREFIX } from '../. const labelWidth = 6; export interface Props { - title: string; - options: Partial; - onChange: (fieldProperties: Partial) => void; showMinMax: boolean; + value: Partial; + onChange: (value: Partial, event?: React.SyntheticEvent) => void; } export class FieldPropertiesEditor extends PureComponent { onTitleChange = (event: ChangeEvent) => - this.props.onChange({ ...this.props.options, title: event.target.value }); + this.props.onChange({ ...this.props.value, title: event.target.value }); // @ts-ignore onUnitChange = (unit: SelectOptionItem) => this.props.onChange({ ...this.props.value, unit: unit.value }); onDecimalChange = (event: ChangeEvent) => { this.props.onChange({ - ...this.props.options, + ...this.props.value, decimals: toIntegerOrUndefined(event.target.value), }); }; onMinChange = (event: ChangeEvent) => { this.props.onChange({ - ...this.props.options, + ...this.props.value, min: toIntegerOrUndefined(event.target.value), }); }; onMaxChange = (event: ChangeEvent) => { this.props.onChange({ - ...this.props.options, + ...this.props.value, max: toIntegerOrUndefined(event.target.value), }); }; render() { - const { showMinMax, title } = this.props; - const { unit, decimals, min, max } = this.props.options; + const { showMinMax } = this.props; + const { unit, decimals, min, max } = this.props.value; const titleTooltip = (
@@ -68,49 +66,47 @@ export class FieldPropertiesEditor extends PureComponent { ); return ( - - <> - + <> + -
- Unit - -
- {showMinMax && ( - <> - - - - )} - - -
+
+ Unit + +
+ {showMinMax && ( + <> + + + + )} + + ); } } diff --git a/public/app/plugins/panel/bargauge/BarGaugePanelEditor.tsx b/public/app/plugins/panel/bargauge/BarGaugePanelEditor.tsx index ddfb8822257..87e52b2e08f 100644 --- a/public/app/plugins/panel/bargauge/BarGaugePanelEditor.tsx +++ b/public/app/plugins/panel/bargauge/BarGaugePanelEditor.tsx @@ -10,6 +10,7 @@ import { FieldDisplayOptions, Field, FieldPropertiesEditor, + PanelOptionsGroup, } from '@grafana/ui'; // Types @@ -54,7 +55,8 @@ export class BarGaugePanelEditor extends PureComponent - + +
Orientation