From 01251927b3c085aee6df85c4bf1bc54b5a61355f Mon Sep 17 00:00:00 2001 From: Peter Holmberg Date: Wed, 16 Jan 2019 14:43:22 +0000 Subject: [PATCH] redoing input props --- .../components/FormField/FormField.test.tsx | 6 ++--- .../src/components/FormField/FormField.tsx | 6 ++--- .../ValueMappingsEditor/MappingRow.tsx | 24 +++++++------------ .../panel/gauge/GaugeOptionsEditor.tsx | 12 ++-------- .../app/plugins/panel/gauge/ValueOptions.tsx | 24 +++++++------------ 5 files changed, 24 insertions(+), 48 deletions(-) diff --git a/packages/grafana-ui/src/components/FormField/FormField.test.tsx b/packages/grafana-ui/src/components/FormField/FormField.test.tsx index 4474b0680c5..3c89a347e86 100644 --- a/packages/grafana-ui/src/components/FormField/FormField.test.tsx +++ b/packages/grafana-ui/src/components/FormField/FormField.test.tsx @@ -6,10 +6,8 @@ const setup = (propOverrides?: object) => { const props: Props = { label: 'Test', labelWidth: 11, - inputProps: { - value: 10, - onChange: jest.fn(), - }, + value: 10, + onChange: jest.fn(), }; Object.assign(props, propOverrides); diff --git a/packages/grafana-ui/src/components/FormField/FormField.tsx b/packages/grafana-ui/src/components/FormField/FormField.tsx index aa026a74197..14bec79b57f 100644 --- a/packages/grafana-ui/src/components/FormField/FormField.tsx +++ b/packages/grafana-ui/src/components/FormField/FormField.tsx @@ -1,20 +1,18 @@ import React, { InputHTMLAttributes, FunctionComponent } from 'react'; import { Label } from '..'; -export interface Props { +export interface Props extends InputHTMLAttributes { label: string; - inputProps: InputHTMLAttributes; labelWidth?: number; inputWidth?: number; } const defaultProps = { labelWidth: 6, - inputProps: {}, inputWidth: 12, }; -const FormField: FunctionComponent = ({ label, labelWidth, inputProps, inputWidth }) => { +const FormField: FunctionComponent = ({ label, labelWidth, inputWidth, ...inputProps }) => { return (
diff --git a/packages/grafana-ui/src/components/ValueMappingsEditor/MappingRow.tsx b/packages/grafana-ui/src/components/ValueMappingsEditor/MappingRow.tsx index 3da2cfc2d98..db970046fc4 100644 --- a/packages/grafana-ui/src/components/ValueMappingsEditor/MappingRow.tsx +++ b/packages/grafana-ui/src/components/ValueMappingsEditor/MappingRow.tsx @@ -64,22 +64,18 @@ export default class MappingRow extends PureComponent { ) => this.onMappingFromChange(event), - onBlur: () => this.updateMapping(), - value: from, - }} inputWidth={8} + onChange={(event: ChangeEvent) => this.onMappingFromChange(event)} + onBlur={() => this.updateMapping()} + value={from} /> this.updateMapping, - onChange: (event: ChangeEvent) => this.onMappingToChange(event), - value: to, - }} inputWidth={8} + onBlur={() => this.updateMapping} + onChange={(event: ChangeEvent) => this.onMappingToChange(event)} + value={to} />
@@ -99,11 +95,9 @@ export default class MappingRow extends PureComponent { this.updateMapping, - onChange: (event: ChangeEvent) => this.onMappingValueChange(event), - value: value, - }} + onBlur={() => this.updateMapping} + onChange={(event: ChangeEvent) => this.onMappingValueChange(event)} + value={value} inputWidth={8} />
diff --git a/public/app/plugins/panel/gauge/GaugeOptionsEditor.tsx b/public/app/plugins/panel/gauge/GaugeOptionsEditor.tsx index b971e67939c..6b8c92e3fe7 100644 --- a/public/app/plugins/panel/gauge/GaugeOptionsEditor.tsx +++ b/public/app/plugins/panel/gauge/GaugeOptionsEditor.tsx @@ -21,16 +21,8 @@ export default class GaugeOptionsEditor extends PureComponent - this.onMinValueChange(event), value: minValue }} - /> - this.onMaxValueChange(event), value: maxValue }} - /> + this.onMinValueChange(event)} value={minValue} /> + this.onMaxValueChange(event)} value={maxValue} /> this.onDecimalChange(event), - value: decimals || '', - type: 'number', - }} + placeholder="auto" + onChange={event => this.onDecimalChange(event)} + value={decimals || ''} + type="number" /> this.onPrefixChange(event), - value: prefix || '', - }} + onChange={event => this.onPrefixChange(event)} + value={prefix || ''} /> this.onSuffixChange(event), - value: suffix || '', - }} + onChange={event => this.onSuffixChange(event)} + value={suffix || ''} /> );