From f12f3333e9cf5657f00f6786b4557cc5d5108b61 Mon Sep 17 00:00:00 2001 From: djhi Date: Tue, 13 Aug 2019 10:41:07 +0200 Subject: [PATCH 1/2] [RFR] Migrate DisabledInput to use useInput --- .../src/input/DisabledInput.js | 47 ++++++++++--------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/packages/ra-ui-materialui/src/input/DisabledInput.js b/packages/ra-ui-materialui/src/input/DisabledInput.js index 5f268d70db1..de9433969d1 100644 --- a/packages/ra-ui-materialui/src/input/DisabledInput.js +++ b/packages/ra-ui-materialui/src/input/DisabledInput.js @@ -1,42 +1,47 @@ import React from 'react'; import PropTypes from 'prop-types'; import TextField from '@material-ui/core/TextField'; -import { addField, FieldTitle } from 'ra-core'; +import { useInput, FieldTitle } from 'ra-core'; import sanitizeRestProps from './sanitizeRestProps'; const DisabledInput = ({ - classes, - className, record, - input: { value }, label, resource, source, options, ...rest -}) => ( - } - className={className} - classes={classes} - {...options} - {...sanitizeRestProps(rest)} - /> -); +}) => { + const { + id, + input: { value }, + } = useInput({ + resource, + source, + type: 'checkbox', + }); + + return ( + + } + {...options} + {...sanitizeRestProps(rest)} + /> + ); +}; DisabledInput.propTypes = { - classes: PropTypes.object, - className: PropTypes.string, label: PropTypes.string, - input: PropTypes.object, options: PropTypes.object, - record: PropTypes.object, resource: PropTypes.string, source: PropTypes.string, }; -export default addField(DisabledInput); +export default DisabledInput; From 1f5dbe1ea634fdddf422ba69df7326d4c9177f49 Mon Sep 17 00:00:00 2001 From: djhi Date: Tue, 13 Aug 2019 12:22:18 +0200 Subject: [PATCH 2/2] Fix wrong copy/paste --- packages/ra-ui-materialui/src/input/DisabledInput.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/ra-ui-materialui/src/input/DisabledInput.js b/packages/ra-ui-materialui/src/input/DisabledInput.js index de9433969d1..7758069885c 100644 --- a/packages/ra-ui-materialui/src/input/DisabledInput.js +++ b/packages/ra-ui-materialui/src/input/DisabledInput.js @@ -19,7 +19,6 @@ const DisabledInput = ({ } = useInput({ resource, source, - type: 'checkbox', }); return (