From 1a41a1f5336ea040d168def6e534f42816f7ddde Mon Sep 17 00:00:00 2001 From: fzaninotto Date: Mon, 4 Feb 2019 17:26:16 +0100 Subject: [PATCH] Upgrade prettier and apply format --- examples/data-generator/src/finalize.js | 17 +++-- examples/demo/src/App.css | 24 ++++--- examples/demo/src/categories/CategoryEdit.js | 5 +- examples/demo/src/index.css | 6 +- examples/demo/src/orders/MobileGrid.js | 3 +- examples/demo/src/reviews/StarRatingField.js | 4 +- examples/demo/src/visitors/MobileGrid.js | 22 ++++--- examples/simple/src/comments/CommentList.js | 3 +- examples/simple/src/posts/PostEdit.js | 24 ++++--- examples/simple/src/users/Aside.js | 7 +- examples/simple/src/users/UserShow.spec.js | 20 ++++-- examples/tutorial/src/index.css | 6 +- package.json | 2 +- packages/ra-core/src/CoreAdminRouter.js | 3 +- .../src/controller/CreateController.js | 12 ++-- .../ra-core/src/controller/ListController.js | 4 +- .../controller/checkMinimumRequiredProps.js | 14 ++-- .../field/ReferenceManyFieldController.js | 4 +- .../input/ReferenceInputController.spec.js | 2 +- .../controller/input/referenceDataStatus.js | 4 +- packages/ra-core/src/createAdminStore.ts | 2 +- .../src/reducer/admin/resource/data.js | 16 +++-- .../src/reducer/admin/resource/data.spec.js | 4 +- packages/ra-core/src/sideEffect/auth.ts | 4 +- packages/ra-core/src/sideEffect/callback.ts | 7 +- .../ra-core/src/sideEffect/redirection.ts | 10 +-- .../src/util/getFieldLabelTranslationArgs.ts | 17 ++--- packages/ra-input-rich-text/src/styles.js | 2 +- .../ra-tree-ui-materialui/src/NodeActions.js | 5 +- .../ra-tree-ui-materialui/src/NodeForm.js | 47 +++++++------- .../ra-tree-ui-materialui/src/NodeView.js | 18 +++--- packages/ra-ui-materialui/src/auth/Login.js | 2 +- .../src/button/ExportButton.js | 6 +- .../ra-ui-materialui/src/button/ListButton.js | 7 +- .../src/button/RefreshButton.js | 2 +- .../src/button/RefreshIconButton.js | 2 +- .../ra-ui-materialui/src/button/SaveButton.js | 6 +- .../src/detail/SimpleShowLayout.js | 64 +++++++++---------- .../src/detail/TabbedShowLayout.js | 10 ++- .../src/detail/TabbedShowLayoutTabs.js | 4 +- .../src/detail/editFieldTypes.js | 6 +- .../src/field/BooleanField.js | 15 ++--- .../src/field/BooleanField.spec.js | 58 ++++++++++++++--- .../ra-ui-materialui/src/field/DateField.js | 4 +- .../src/field/FunctionField.spec.js | 6 +- .../ra-ui-materialui/src/field/SelectField.js | 4 +- packages/ra-ui-materialui/src/form/FormTab.js | 8 +-- .../ra-ui-materialui/src/form/SimpleForm.js | 3 +- .../src/form/SimpleFormIterator.js | 9 +-- .../ra-ui-materialui/src/form/TabbedForm.js | 7 +- packages/ra-ui-materialui/src/form/Toolbar.js | 59 ++++++++--------- .../src/input/AutocompleteArrayInput.js | 13 ++-- .../src/input/AutocompleteArrayInput.spec.js | 8 +-- .../src/input/AutocompleteInput.js | 2 +- .../src/input/AutocompleteInput.spec.js | 6 +- .../src/input/CheckboxGroupInput.js | 9 +-- .../ra-ui-materialui/src/input/FileInput.js | 10 +-- .../src/input/FileInput.spec.js | 4 +- .../src/input/ImageInput.spec.js | 4 +- .../src/input/RadioButtonGroupInput.js | 9 +-- .../src/input/ResettableTextField.js | 49 +++++++------- .../src/input/SelectArrayInput.js | 5 +- .../ra-ui-materialui/src/input/SelectInput.js | 10 +-- .../src/layout/CardContentInner.js | 24 +++---- .../ra-ui-materialui/src/layout/Confirm.js | 8 ++- .../ra-ui-materialui/src/layout/Layout.js | 4 +- .../src/layout/MenuItemLink.js | 5 +- .../ra-ui-materialui/src/layout/Responsive.js | 20 +++--- .../ra-ui-materialui/src/list/Datagrid.js | 33 +++++----- .../ra-ui-materialui/src/list/DatagridRow.js | 53 ++++++++------- .../src/list/PaginationActions.js | 41 ++++++------ yarn.lock | 8 +-- 72 files changed, 492 insertions(+), 433 deletions(-) diff --git a/examples/data-generator/src/finalize.js b/examples/data-generator/src/finalize.js index 5f3380850d..85a6bae154 100644 --- a/examples/data-generator/src/finalize.js +++ b/examples/data-generator/src/finalize.js @@ -44,13 +44,16 @@ export default function(db) { .forEach(customer => customer.groups.push('regular')); // add 'returns' group - db.commands.filter(command => command.returned).forEach(command => { - if ( - db.customers[command.customer_id].groups.indexOf('returns') === -1 - ) { - db.customers[command.customer_id].groups.push('returns'); - } - }); + db.commands + .filter(command => command.returned) + .forEach(command => { + if ( + db.customers[command.customer_id].groups.indexOf('returns') === + -1 + ) { + db.customers[command.customer_id].groups.push('returns'); + } + }); // add 'reviewer' group db.reviews.forEach(review => { diff --git a/examples/demo/src/App.css b/examples/demo/src/App.css index 15adfdc710..05df7488b0 100644 --- a/examples/demo/src/App.css +++ b/examples/demo/src/App.css @@ -1,24 +1,28 @@ .App { - text-align: center; + text-align: center; } .App-logo { - animation: App-logo-spin infinite 20s linear; - height: 80px; + animation: App-logo-spin infinite 20s linear; + height: 80px; } .App-header { - background-color: #222; - height: 150px; - padding: 20px; - color: white; + background-color: #222; + height: 150px; + padding: 20px; + color: white; } .App-intro { - font-size: large; + font-size: large; } @keyframes App-logo-spin { - from { transform: rotate(0deg); } - to { transform: rotate(360deg); } + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } } diff --git a/examples/demo/src/categories/CategoryEdit.js b/examples/demo/src/categories/CategoryEdit.js index ff82105633..12886ebde1 100644 --- a/examples/demo/src/categories/CategoryEdit.js +++ b/examples/demo/src/categories/CategoryEdit.js @@ -15,9 +15,8 @@ import ProductRefField from '../products/ProductRefField'; const CategoryTitle = translate(({ record, translate }) => ( - {translate('resources.categories.name', { smart_count: 1 })} "{ - record.name - }" + {translate('resources.categories.name', { smart_count: 1 })} " + {record.name}" )); diff --git a/examples/demo/src/index.css b/examples/demo/src/index.css index b4cc7250b9..22f8f18971 100644 --- a/examples/demo/src/index.css +++ b/examples/demo/src/index.css @@ -1,5 +1,5 @@ body { - margin: 0; - padding: 0; - font-family: sans-serif; + margin: 0; + padding: 0; + font-family: sans-serif; } diff --git a/examples/demo/src/orders/MobileGrid.js b/examples/demo/src/orders/MobileGrid.js index 8feba746c7..674100433d 100644 --- a/examples/demo/src/orders/MobileGrid.js +++ b/examples/demo/src/orders/MobileGrid.js @@ -73,7 +73,8 @@ const MobileGrid = ({ classes, ids, data, basePath, translate }) => ( - {translate('resources.commands.fields.basket.total')}:  + {translate('resources.commands.fields.basket.total')} + :  ( {Array(record.rating) .fill(true) - .map((_, i) => )} + .map((_, i) => ( + + ))} ); diff --git a/examples/demo/src/visitors/MobileGrid.js b/examples/demo/src/visitors/MobileGrid.js index da42e4e0e2..70b1c2a65c 100644 --- a/examples/demo/src/visitors/MobileGrid.js +++ b/examples/demo/src/visitors/MobileGrid.js @@ -52,7 +52,8 @@ const MobileGrid = ({ classes, ids, data, basePath, translate }) => ( />
- {translate('resources.customers.fields.last_seen_gte')}  + {translate('resources.customers.fields.last_seen_gte')} +   ( {translate( 'resources.commands.name', parseInt(data[id].nb_commands, 10) || 1 - )} :  ( />
- {translate('resources.customers.fields.total_spent')}  - :{' '} + {translate('resources.customers.fields.total_spent')} +   :{' '} ( />
- {data[id].groups && - data[id].groups.length > 0 && ( - - - - )} + {data[id].groups && data[id].groups.length > 0 && ( + + + + )} ))} diff --git a/examples/simple/src/comments/CommentList.js b/examples/simple/src/comments/CommentList.js index 8d0f0b16a2..f2d48e5ef8 100644 --- a/examples/simple/src/comments/CommentList.js +++ b/examples/simple/src/comments/CommentList.js @@ -74,7 +74,8 @@ const CommentPagination = translate( key="prev" onClick={() => setPage(page - 1)} > -   + +   {translate('ra.navigation.prev')} )} diff --git a/examples/simple/src/posts/PostEdit.js b/examples/simple/src/posts/PostEdit.js index 2e4ab5e7ad..60c52edf14 100644 --- a/examples/simple/src/posts/PostEdit.js +++ b/examples/simple/src/posts/PostEdit.js @@ -41,15 +41,15 @@ const EditActions = ({ resource, ...rest }) => ( - - - {hasShow && } - - ); + + + {hasShow && } + +); const PostEdit = props => ( } actions={} {...props}> @@ -83,7 +83,11 @@ const PostEdit = props => ( /> - + diff --git a/examples/simple/src/users/Aside.js b/examples/simple/src/users/Aside.js index 2e6de7755f..e56975e11e 100644 --- a/examples/simple/src/users/Aside.js +++ b/examples/simple/src/users/Aside.js @@ -5,7 +5,12 @@ const Aside = () => (
App Users - Eiusmod adipisicing tempor duis qui. Ullamco aliqua tempor incididunt aliquip aliquip qui ad minim aliqua. Aute et magna quis pariatur irure sunt. Aliquip velit consequat dolore ullamco laborum voluptate cupidatat. Proident minim reprehenderit id dolore elit sit occaecat ad amet tempor esse occaecat enim. Laborum aliqua excepteur qui ipsum in dolor et cillum est. + Eiusmod adipisicing tempor duis qui. Ullamco aliqua tempor + incididunt aliquip aliquip qui ad minim aliqua. Aute et magna quis + pariatur irure sunt. Aliquip velit consequat dolore ullamco laborum + voluptate cupidatat. Proident minim reprehenderit id dolore elit sit + occaecat ad amet tempor esse occaecat enim. Laborum aliqua excepteur + qui ipsum in dolor et cillum est.
); diff --git a/examples/simple/src/users/UserShow.spec.js b/examples/simple/src/users/UserShow.spec.js index 4a607c1c3f..33709255ef 100644 --- a/examples/simple/src/users/UserShow.spec.js +++ b/examples/simple/src/users/UserShow.spec.js @@ -24,14 +24,18 @@ const defaultProps = { describe('UserShow', () => { describe('As User', () => { it('should display one tab', () => { - const wrapper = shallow(); + const wrapper = shallow( + + ); const tab = wrapper.find(Tab); expect(tab.length).toBe(1); }); it('should show the user identity in the first tab', () => { - const wrapper = shallow(); + const wrapper = shallow( + + ); const tab = wrapper.find(Tab); const fields = tab.find(TextField); @@ -43,14 +47,18 @@ describe('UserShow', () => { describe('As Admin', () => { it('should display two tabs', () => { - const wrapper = shallow(); + const wrapper = shallow( + + ); const tabs = wrapper.find(Tab); expect(tabs.length).toBe(2); }); it('should show the user identity in the first tab', () => { - const wrapper = shallow(); + const wrapper = shallow( + + ); const tabs = wrapper.find(Tab); const fields = tabs.at(0).find(TextField); @@ -60,7 +68,9 @@ describe('UserShow', () => { }); it('should show the user role in the second tab', () => { - const wrapper = shallow(); + const wrapper = shallow( + + ); const tabs = wrapper.find(Tab); const fields = tabs.at(1).find(TextField); diff --git a/examples/tutorial/src/index.css b/examples/tutorial/src/index.css index b4cc7250b9..22f8f18971 100644 --- a/examples/tutorial/src/index.css +++ b/examples/tutorial/src/index.css @@ -1,5 +1,5 @@ body { - margin: 0; - padding: 0; - font-family: sans-serif; + margin: 0; + padding: 0; + font-family: sans-serif; } diff --git a/package.json b/package.json index 4b8bd295dd..c8887377fd 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "jest": "^23.6.0", "lerna": "~2.9.1", "lolex": "~2.3.2", - "prettier": "~1.13.7", + "prettier": "~1.16.4", "raf": "~3.4.0", "ts-jest": "^23.10.4", "tslint": "^5.11.0", diff --git a/packages/ra-core/src/CoreAdminRouter.js b/packages/ra-core/src/CoreAdminRouter.js index d6f5dffb9c..04670f7bec 100644 --- a/packages/ra-core/src/CoreAdminRouter.js +++ b/packages/ra-core/src/CoreAdminRouter.js @@ -107,7 +107,8 @@ export class CoreAdminRouter extends Component { ) { return (
- React-admin is properly configured.
+ React-admin is properly configured. +
Now you can add a first <Resource> as child of <Admin>.
diff --git a/packages/ra-core/src/controller/CreateController.js b/packages/ra-core/src/controller/CreateController.js index 6550410d32..ddf9c1d02c 100644 --- a/packages/ra-core/src/controller/CreateController.js +++ b/packages/ra-core/src/controller/CreateController.js @@ -61,8 +61,8 @@ export class CreateController extends Component { state && state.record ? state.record : search - ? parse(search, { arrayFormat: 'bracket' }) - : record; + ? parse(search, { arrayFormat: 'bracket' }) + : record; } defaultRedirectRoute() { @@ -140,14 +140,10 @@ function mapStateToProps(state) { } export default compose( - checkMinimumRequiredProps('Create', [ - 'basePath', - 'location', - 'resource', - ]), + checkMinimumRequiredProps('Create', ['basePath', 'location', 'resource']), connect( mapStateToProps, { crudCreate: crudCreateAction } ), - translate, + translate )(CreateController); diff --git a/packages/ra-core/src/controller/ListController.js b/packages/ra-core/src/controller/ListController.js index 408043ab28..400fda1607 100644 --- a/packages/ra-core/src/controller/ListController.js +++ b/packages/ra-core/src/controller/ListController.js @@ -174,8 +174,8 @@ export class ListController extends Component { Object.keys(this.props.query).length > 0 ? this.props.query : this.hasCustomParams(this.props.params) - ? { ...this.props.params } - : { filter: this.props.filterDefaultValues || {} }; + ? { ...this.props.params } + : { filter: this.props.filterDefaultValues || {} }; if (!query.sort) { query.sort = this.props.sort.field; diff --git a/packages/ra-core/src/controller/checkMinimumRequiredProps.js b/packages/ra-core/src/controller/checkMinimumRequiredProps.js index f95ee61be5..e3fb24c75a 100644 --- a/packages/ra-core/src/controller/checkMinimumRequiredProps.js +++ b/packages/ra-core/src/controller/checkMinimumRequiredProps.js @@ -1,19 +1,25 @@ import React from 'react'; -const checkMinimumRequiredProps = (displayName, requiredProps) => WrappedComponent => (props) => { +const checkMinimumRequiredProps = ( + displayName, + requiredProps +) => WrappedComponent => props => { const propNames = Object.keys(props); - const missingProps = requiredProps.filter(prop => !propNames.includes(prop)); + const missingProps = requiredProps.filter( + prop => !propNames.includes(prop) + ); if (missingProps.length > 0) { throw new Error( -`<${displayName}> component is not properly configured, some essential props are missing. + `<${displayName}> component is not properly configured, some essential props are missing. Be sure to pass the props from the parent. Example: const My${displayName} = props => ( <${displayName} {...props}> ); -The missing props are: ${missingProps.join(', ')}`) +The missing props are: ${missingProps.join(', ')}` + ); } return ; diff --git a/packages/ra-core/src/controller/field/ReferenceManyFieldController.js b/packages/ra-core/src/controller/field/ReferenceManyFieldController.js index 4629c613b6..321641f434 100644 --- a/packages/ra-core/src/controller/field/ReferenceManyFieldController.js +++ b/packages/ra-core/src/controller/field/ReferenceManyFieldController.js @@ -73,8 +73,8 @@ export class ReferenceManyFieldController extends Component { componentWillReceiveProps(nextProps) { if ( - this.props.record.id !== nextProps.record.id || - !isEqual(this.props.filter, nextProps.filter) + this.props.record.id !== nextProps.record.id || + !isEqual(this.props.filter, nextProps.filter) ) { this.fetchReferences(nextProps); } diff --git a/packages/ra-core/src/controller/input/ReferenceInputController.spec.js b/packages/ra-core/src/controller/input/ReferenceInputController.spec.js index e4593bf185..a25936f3ef 100644 --- a/packages/ra-core/src/controller/input/ReferenceInputController.spec.js +++ b/packages/ra-core/src/controller/input/ReferenceInputController.spec.js @@ -409,7 +409,7 @@ describe('', () => { it('should only call crudGetMatching when props are changed from outside', () => { const crudGetMatchingAccumulate = jest.fn(); const crudGetManyAccumulate = jest.fn(); - const ControllerWrapper = (props) => ( + const ControllerWrapper = props => ( !input.value || input.value.length === referenceRecords.length ? REFERENCES_STATUS_READY : referenceRecords.length > 0 - ? REFERENCES_STATUS_INCOMPLETE - : REFERENCES_STATUS_EMPTY; + ? REFERENCES_STATUS_INCOMPLETE + : REFERENCES_STATUS_EMPTY; export const getStatusForArrayInput = ({ input, diff --git a/packages/ra-core/src/createAdminStore.ts b/packages/ra-core/src/createAdminStore.ts index a640a2bdfc..8faf0aacda 100644 --- a/packages/ra-core/src/createAdminStore.ts +++ b/packages/ra-core/src/createAdminStore.ts @@ -62,7 +62,7 @@ export default ({ routerMiddleware(history) ), typeof typedWindow !== 'undefined' && - typedWindow.__REDUX_DEVTOOLS_EXTENSION__ + typedWindow.__REDUX_DEVTOOLS_EXTENSION__ ? typedWindow.__REDUX_DEVTOOLS_EXTENSION__() : f => f ) diff --git a/packages/ra-core/src/reducer/admin/resource/data.js b/packages/ra-core/src/reducer/admin/resource/data.js index f4701c8c75..c3be242404 100644 --- a/packages/ra-core/src/reducer/admin/resource/data.js +++ b/packages/ra-core/src/reducer/admin/resource/data.js @@ -60,7 +60,7 @@ const updateDataFetchedTime = (data, fetchedAt) => { Object.defineProperty(data, 'fetchedAt', { value: fetchedAt, }); -} +}; const initialState = {}; updateDataFetchedTime(initialState, {}); // non enumerable by default @@ -68,15 +68,17 @@ updateDataFetchedTime(initialState, {}); // non enumerable by default export default (previousState = initialState, { payload, meta }) => { if (meta && meta.optimistic) { if (meta.fetch === UPDATE) { - const updatedRecord = { ...previousState[payload.id], ...payload.data }; + const updatedRecord = { + ...previousState[payload.id], + ...payload.data, + }; return addRecords([updatedRecord], previousState); } if (meta.fetch === UPDATE_MANY) { - const updatedRecords = payload.ids - .map(id => ({ - ...previousState[id], - ...payload.data, - })); + const updatedRecords = payload.ids.map(id => ({ + ...previousState[id], + ...payload.data, + })); return addRecords(updatedRecords, previousState); } diff --git a/packages/ra-core/src/reducer/admin/resource/data.spec.js b/packages/ra-core/src/reducer/admin/resource/data.spec.js index ae3e761a25..22acca315e 100644 --- a/packages/ra-core/src/reducer/admin/resource/data.spec.js +++ b/packages/ra-core/src/reducer/admin/resource/data.spec.js @@ -112,7 +112,7 @@ describe('Resources data reducer', () => { meta: { fetch: DELETE, optimistic: true, - } + }, }), { record1: { id: 'record1', prop: 'value' }, @@ -136,7 +136,7 @@ describe('Resources data reducer', () => { meta: { fetch: DELETE_MANY, optimistic: true, - } + }, }), { record1: { id: 'record1', prop: 'value' }, diff --git a/packages/ra-core/src/sideEffect/auth.ts b/packages/ra-core/src/sideEffect/auth.ts index 3934597540..b55f4aaaa8 100644 --- a/packages/ra-core/src/sideEffect/auth.ts +++ b/packages/ra-core/src/sideEffect/auth.ts @@ -55,8 +55,8 @@ export default (authProvider?: AuthProvider) => { typeof e === 'string' ? e : typeof e === 'undefined' || !e.message - ? 'ra.auth.sign_in_error' - : e.message; + ? 'ra.auth.sign_in_error' + : e.message; yield put(showNotification(errorMessage, 'warning')); } break; diff --git a/packages/ra-core/src/sideEffect/callback.ts b/packages/ra-core/src/sideEffect/callback.ts index 9ceb16f443..df82113c7f 100644 --- a/packages/ra-core/src/sideEffect/callback.ts +++ b/packages/ra-core/src/sideEffect/callback.ts @@ -1,8 +1,9 @@ import { call, takeEvery } from 'redux-saga/effects'; -export type CallbackSideEffect = ( - args: { payload: any; requestPayload?: any } -) => any; +export type CallbackSideEffect = (args: { + payload: any; + requestPayload?: any; +}) => any; interface ActionWithSideEffect { type: string; diff --git a/packages/ra-core/src/sideEffect/redirection.ts b/packages/ra-core/src/sideEffect/redirection.ts index 802b715306..310396eb3b 100644 --- a/packages/ra-core/src/sideEffect/redirection.ts +++ b/packages/ra-core/src/sideEffect/redirection.ts @@ -49,15 +49,15 @@ export function* handleRedirection({ basePath, payload ? payload.id || - (payload.data ? payload.data.id : null) + (payload.data ? payload.data.id : null) : requestPayload - ? requestPayload.id - : null, + ? requestPayload.id + : null, payload && payload.data ? payload.data : requestPayload && requestPayload.data - ? requestPayload.data - : null + ? requestPayload.data + : null ) ) ) diff --git a/packages/ra-core/src/util/getFieldLabelTranslationArgs.ts b/packages/ra-core/src/util/getFieldLabelTranslationArgs.ts index 8e2f423c2a..c2f27e9d40 100644 --- a/packages/ra-core/src/util/getFieldLabelTranslationArgs.ts +++ b/packages/ra-core/src/util/getFieldLabelTranslationArgs.ts @@ -28,14 +28,11 @@ export default (options: Args): TranslationArguments => { return typeof label !== 'undefined' ? [label, { _: label }] : typeof source !== 'undefined' - ? [ - `resources.${resource}.fields.${source}`, - { - _: inflection.transform(source, [ - 'underscore', - 'humanize', - ]), - }, - ] - : ['']; + ? [ + `resources.${resource}.fields.${source}`, + { + _: inflection.transform(source, ['underscore', 'humanize']), + }, + ] + : ['']; }; diff --git a/packages/ra-input-rich-text/src/styles.js b/packages/ra-input-rich-text/src/styles.js index 11edcd0876..f742c27e8b 100644 --- a/packages/ra-input-rich-text/src/styles.js +++ b/packages/ra-input-rich-text/src/styles.js @@ -5,7 +5,7 @@ export default { '.ra-rich-text-input': { '& .ql-editor': { fontSize: '1rem', - fontFamily: "Roboto, sans-serif", + fontFamily: 'Roboto, sans-serif', padding: 0, '&:hover::before': { diff --git a/packages/ra-tree-ui-materialui/src/NodeActions.js b/packages/ra-tree-ui-materialui/src/NodeActions.js index 7b20409654..092f1a5407 100644 --- a/packages/ra-tree-ui-materialui/src/NodeActions.js +++ b/packages/ra-tree-ui-materialui/src/NodeActions.js @@ -23,9 +23,8 @@ export class NodeActions extends Component { const { children, classes, ...props } = this.props; return ( - {Children.map( - children, - action => (action ? cloneElement(action, props) : null) + {Children.map(children, action => + action ? cloneElement(action, props) : null )} ); diff --git a/packages/ra-tree-ui-materialui/src/NodeForm.js b/packages/ra-tree-ui-materialui/src/NodeForm.js index 4c8b2517b9..efd0242712 100644 --- a/packages/ra-tree-ui-materialui/src/NodeForm.js +++ b/packages/ra-tree-ui-materialui/src/NodeForm.js @@ -122,20 +122,10 @@ class NodeForm extends Component { undoable = true, } = this.props; - return handleSubmit( - values => - undoable - ? startUndoable( - crudUpdateAction( - resource, - record.id, - { ...record, ...values }, - record, - basePath, - false - ) - ) - : dispatchCrudUpdate( + return handleSubmit(values => + undoable + ? startUndoable( + crudUpdateAction( resource, record.id, { ...record, ...values }, @@ -143,6 +133,15 @@ class NodeForm extends Component { basePath, false ) + ) + : dispatchCrudUpdate( + resource, + record.id, + { ...record, ...values }, + record, + basePath, + false + ) ); }; @@ -168,17 +167,15 @@ class NodeForm extends Component { onClick={this.handleClick} {...sanitizeRestProps(props)} > - {Children.map( - children, - field => - field - ? cloneElement(field, { - basePath: field.props.basePath || basePath, - onDrop: this.handleDrop, - record: node.record, - resource, - }) - : null + {Children.map(children, field => + field + ? cloneElement(field, { + basePath: field.props.basePath || basePath, + onDrop: this.handleDrop, + record: node.record, + resource, + }) + : null )} {actions && cloneElement(actions, { diff --git a/packages/ra-tree-ui-materialui/src/NodeView.js b/packages/ra-tree-ui-materialui/src/NodeView.js index 0a3242958c..729ac79000 100644 --- a/packages/ra-tree-ui-materialui/src/NodeView.js +++ b/packages/ra-tree-ui-materialui/src/NodeView.js @@ -67,16 +67,14 @@ export class NodeView extends Component { onClick={this.handleClick} {...sanitizeRestProps(props)} > - {Children.map( - children, - field => - field - ? cloneElement(field, { - basePath: field.props.basePath || basePath, - record: node.record, - resource, - }) - : null + {Children.map(children, field => + field + ? cloneElement(field, { + basePath: field.props.basePath || basePath, + record: node.record, + resource, + }) + : null )} {actions && cloneElement(actions, { diff --git a/packages/ra-ui-materialui/src/auth/Login.js b/packages/ra-ui-materialui/src/auth/Login.js index 7d7e0104c9..c8f5f62615 100644 --- a/packages/ra-ui-materialui/src/auth/Login.js +++ b/packages/ra-ui-materialui/src/auth/Login.js @@ -94,7 +94,7 @@ class Login extends Component { if (lastTry) { this.backgroundImageLoaded = true; } - } + }; // Load background image asynchronously to speed up time to interactive lazyLoadBackgroundImage() { diff --git a/packages/ra-ui-materialui/src/button/ExportButton.js b/packages/ra-ui-materialui/src/button/ExportButton.js index dfe0520ff0..ac1826aacf 100644 --- a/packages/ra-ui-materialui/src/button/ExportButton.js +++ b/packages/ra-ui-materialui/src/button/ExportButton.js @@ -105,9 +105,9 @@ class ExportButton extends Component { }; static defaultProps = { - label: 'ra.action.export', - maxResults: 1000, - icon: , + label: 'ra.action.export', + maxResults: 1000, + icon: , }; handleClick = () => { diff --git a/packages/ra-ui-materialui/src/button/ListButton.js b/packages/ra-ui-materialui/src/button/ListButton.js index 05de5a8447..702e8c3cd8 100644 --- a/packages/ra-ui-materialui/src/button/ListButton.js +++ b/packages/ra-ui-materialui/src/button/ListButton.js @@ -5,7 +5,12 @@ import { Link } from 'react-router-dom'; import Button from './Button'; -const ListButton = ({ basePath = '', label = 'ra.action.list', icon, ...rest }) => ( +const ListButton = ({ + basePath = '', + label = 'ra.action.list', + icon, + ...rest +}) => ( diff --git a/packages/ra-ui-materialui/src/button/RefreshButton.js b/packages/ra-ui-materialui/src/button/RefreshButton.js index f3cd62f5d2..a75ce9e39f 100644 --- a/packages/ra-ui-materialui/src/button/RefreshButton.js +++ b/packages/ra-ui-materialui/src/button/RefreshButton.js @@ -19,7 +19,7 @@ class RefreshButton extends Component { }; handleClick = event => { - const { refreshView, onClick } = this.props; + const { refreshView, onClick } = this.props; event.preventDefault(); refreshView(); diff --git a/packages/ra-ui-materialui/src/button/RefreshIconButton.js b/packages/ra-ui-materialui/src/button/RefreshIconButton.js index 542008e562..c936bed37e 100644 --- a/packages/ra-ui-materialui/src/button/RefreshIconButton.js +++ b/packages/ra-ui-materialui/src/button/RefreshIconButton.js @@ -22,7 +22,7 @@ class RefreshButton extends Component { }; handleClick = event => { - const { refreshView, onClick } = this.props; + const { refreshView, onClick } = this.props; event.preventDefault(); refreshView(); diff --git a/packages/ra-ui-materialui/src/button/SaveButton.js b/packages/ra-ui-materialui/src/button/SaveButton.js index 8f03113100..fef32d9690 100644 --- a/packages/ra-ui-materialui/src/button/SaveButton.js +++ b/packages/ra-ui-materialui/src/button/SaveButton.js @@ -45,9 +45,9 @@ export class SaveButton extends Component { label: PropTypes.string, pristine: PropTypes.bool, redirect: PropTypes.oneOfType([ - PropTypes.string, - PropTypes.bool, - PropTypes.func, + PropTypes.string, + PropTypes.bool, + PropTypes.func, ]), saving: PropTypes.oneOfType([PropTypes.object, PropTypes.bool]), showNotification: PropTypes.func, diff --git a/packages/ra-ui-materialui/src/detail/SimpleShowLayout.js b/packages/ra-ui-materialui/src/detail/SimpleShowLayout.js index 2177dfb43a..4c38a151ea 100644 --- a/packages/ra-ui-materialui/src/detail/SimpleShowLayout.js +++ b/packages/ra-ui-materialui/src/detail/SimpleShowLayout.js @@ -63,39 +63,37 @@ export const SimpleShowLayout = ({ key={version} {...sanitizeRestProps(rest)} > - {Children.map( - children, - field => - field ? ( -
- {field.props.addLabel ? ( - - {field} - - ) : typeof field.type === 'string' ? ( - field - ) : ( - React.cloneElement(field, { - record, - resource, - basePath, - }) - )} -
- ) : null + {Children.map(children, field => + field ? ( +
+ {field.props.addLabel ? ( + + {field} + + ) : typeof field.type === 'string' ? ( + field + ) : ( + React.cloneElement(field, { + record, + resource, + basePath, + }) + )} +
+ ) : null )} ); diff --git a/packages/ra-ui-materialui/src/detail/TabbedShowLayout.js b/packages/ra-ui-materialui/src/detail/TabbedShowLayout.js index 22c72cccd4..c4b280cd2c 100644 --- a/packages/ra-ui-materialui/src/detail/TabbedShowLayout.js +++ b/packages/ra-ui-materialui/src/detail/TabbedShowLayout.js @@ -84,7 +84,11 @@ export class TabbedShowLayout extends Component { } = this.props; return ( -
+
{cloneElement( tabs, { @@ -93,7 +97,7 @@ export class TabbedShowLayout extends Component { value: location.pathname, match, }, - children, + children )} @@ -136,7 +140,7 @@ TabbedShowLayout.propTypes = { }; TabbedShowLayout.defaultProps = { - tabs: + tabs: , }; const enhance = compose( diff --git a/packages/ra-ui-materialui/src/detail/TabbedShowLayoutTabs.js b/packages/ra-ui-materialui/src/detail/TabbedShowLayoutTabs.js index 27d4b62f3d..834e925781 100644 --- a/packages/ra-ui-materialui/src/detail/TabbedShowLayoutTabs.js +++ b/packages/ra-ui-materialui/src/detail/TabbedShowLayoutTabs.js @@ -4,11 +4,11 @@ import Tabs from '@material-ui/core/Tabs'; const getTabFullPath = (tab, index, baseUrl) => `${baseUrl}${ - tab.props.path ? `/${tab.props.path}` : index > 0 ? `/${index}` : '' + tab.props.path ? `/${tab.props.path}` : index > 0 ? `/${index}` : '' }`; const TabbedShowLayoutTabs = ({ children, match, ...rest }) => ( - + {Children.map(children, (tab, index) => { if (!tab) return null; // Builds the full tab tab which is the concatenation of the last matched route in the diff --git a/packages/ra-ui-materialui/src/detail/editFieldTypes.js b/packages/ra-ui-materialui/src/detail/editFieldTypes.js index 50f5e30b72..49e5c765bf 100644 --- a/packages/ra-ui-materialui/src/detail/editFieldTypes.js +++ b/packages/ra-ui-materialui/src/detail/editFieldTypes.js @@ -26,7 +26,7 @@ ${children.map(child => ` ${child.getRepresentation()}`).join('\n')} ), representation: (props, children) => `${children .map(child => child.getRepresentation()) .join('\n')}`, @@ -55,7 +55,7 @@ ${children.map(child => ` ${child.getRepresentation()}`).join('\n')} component: ReferenceInput, representation: (props, children) => `${children.getRepresentation()}`, }, referenceChild: { @@ -66,7 +66,7 @@ ${children.map(child => ` ${child.getRepresentation()}`).join('\n')} component: ReferenceArrayInput, representation: props => ``, }, referenceArrayChild: { diff --git a/packages/ra-ui-materialui/src/field/BooleanField.js b/packages/ra-ui-materialui/src/field/BooleanField.js index c4a170212f..6e59ac0668 100644 --- a/packages/ra-ui-materialui/src/field/BooleanField.js +++ b/packages/ra-ui-materialui/src/field/BooleanField.js @@ -28,7 +28,7 @@ const styles = createStyles({ // Text won't wrap to a second line. whiteSpace: 'nowrap', - } + }, }); export const BooleanField = ({ @@ -42,14 +42,13 @@ export const BooleanField = ({ ...rest }) => { const value = get(record, source); - let ariaLabel = value - ? valueLabelTrue - : valueLabelFalse; + let ariaLabel = value ? valueLabelTrue : valueLabelFalse; if (!ariaLabel) { - ariaLabel = value === false - ? translate('ra.boolean.false') - : translate('ra.boolean.true'); + ariaLabel = + value === false + ? translate('ra.boolean.false') + : translate('ra.boolean.true'); } if (value === false) { @@ -112,7 +111,7 @@ BooleanField.defaultProps = { const PureBooleanField = compose( pure, withStyles(styles), - translate, + translate )(BooleanField); PureBooleanField.defaultProps = { diff --git a/packages/ra-ui-materialui/src/field/BooleanField.spec.js b/packages/ra-ui-materialui/src/field/BooleanField.spec.js index 9ceecaa1da..cdf7e2d856 100644 --- a/packages/ra-ui-materialui/src/field/BooleanField.spec.js +++ b/packages/ra-ui-materialui/src/field/BooleanField.spec.js @@ -6,39 +6,81 @@ import { BooleanField } from './BooleanField'; describe('', () => { it('should display tick and truthy text if value is true', () => { const wrapper = shallow( - + ); assert.ok(wrapper.first().is('WithStyles(Typography)')); assert.equal(wrapper.first().find('pure(Done)').length, 1); - assert.equal(wrapper.first().find('span').text(), 'ra.boolean.true'); + assert.equal( + wrapper + .first() + .find('span') + .text(), + 'ra.boolean.true' + ); }); it('should display tick and custom truthy text if value is true', () => { const wrapper = shallow( - + ); assert.ok(wrapper.first().is('WithStyles(Typography)')); assert.equal(wrapper.first().find('pure(Done)').length, 1); - assert.equal(wrapper.first().find('span').text(), 'Has been published'); + assert.equal( + wrapper + .first() + .find('span') + .text(), + 'Has been published' + ); }); it('should display cross and falsy text if value is false', () => { const wrapper = shallow( - + ); assert.ok(wrapper.first().is('WithStyles(Typography)')); assert.equal(wrapper.first().find('pure(Clear)').length, 1); - assert.equal(wrapper.first().find('span').text(), 'ra.boolean.false'); + assert.equal( + wrapper + .first() + .find('span') + .text(), + 'ra.boolean.false' + ); }); it('should display tick and custom falsy text if value is true', () => { const wrapper = shallow( - + ); assert.ok(wrapper.first().is('WithStyles(Typography)')); assert.equal(wrapper.first().find('pure(Clear)').length, 1); - assert.equal(wrapper.first().find('span').text(), 'Has not been published yet'); + assert.equal( + wrapper + .first() + .find('span') + .text(), + 'Has not been published yet' + ); }); it('should not display anything if value is null', () => { diff --git a/packages/ra-ui-materialui/src/field/DateField.js b/packages/ra-ui-materialui/src/field/DateField.js index de7ede512f..205b227654 100644 --- a/packages/ra-ui-materialui/src/field/DateField.js +++ b/packages/ra-ui-materialui/src/field/DateField.js @@ -59,8 +59,8 @@ export const DateField = ({ ? date.toLocaleString(locales, options) : date.toLocaleString() : toLocaleStringSupportsLocales - ? date.toLocaleDateString(locales, options) - : date.toLocaleDateString(); + ? date.toLocaleDateString(locales, options) + : date.toLocaleDateString(); return ( ', () => { it('should render using the render function', () => { const record = { foo: 'bar' }; const wrapper = render( - r.foo.substr(0, 2)} />, + r.foo.substr(0, 2)} /> ); assert.equal(wrapper.text(), 'ba'); }); @@ -19,8 +19,8 @@ describe('', () => { record={{ foo: true }} render={r => r.foo.substr(0, 2)} className="foo" - />, + /> ).prop('className'), - 'foo', + 'foo' )); }); diff --git a/packages/ra-ui-materialui/src/field/SelectField.js b/packages/ra-ui-materialui/src/field/SelectField.js index ffbcdb54f2..9ea2c2fd1a 100644 --- a/packages/ra-ui-materialui/src/field/SelectField.js +++ b/packages/ra-ui-materialui/src/field/SelectField.js @@ -84,8 +84,8 @@ export const SelectField = ({ const choiceName = React.isValidElement(optionText) // eslint-disable-line no-nested-ternary ? React.cloneElement(optionText, { record: choice }) : typeof optionText === 'function' - ? optionText(choice) - : choice[optionText]; + ? optionText(choice) + : choice[optionText]; return ( ( + renderContent = ({ children, hidden, basePath, record, resource }) => ( {React.Children.map( children, diff --git a/packages/ra-ui-materialui/src/form/SimpleForm.js b/packages/ra-ui-materialui/src/form/SimpleForm.js index 9ea13fe94e..8b03821974 100644 --- a/packages/ra-ui-materialui/src/form/SimpleForm.js +++ b/packages/ra-ui-materialui/src/form/SimpleForm.js @@ -89,8 +89,7 @@ export class SimpleForm extends Component { {toolbar && React.cloneElement(toolbar, { basePath, - handleSubmitWithRedirect: this - .handleSubmitWithRedirect, + handleSubmitWithRedirect: this.handleSubmitWithRedirect, handleSubmit: this.props.handleSubmit, invalid, pristine, diff --git a/packages/ra-ui-materialui/src/form/SimpleFormIterator.js b/packages/ra-ui-materialui/src/form/SimpleFormIterator.js index 4b3b89395f..e51fe8f7cb 100644 --- a/packages/ra-ui-materialui/src/form/SimpleFormIterator.js +++ b/packages/ra-ui-materialui/src/form/SimpleFormIterator.js @@ -69,8 +69,8 @@ export class SimpleFormIterator extends Component { this.nextId = props.fields.length ? props.fields.length : props.defaultValue - ? props.defaultValue.length - : 0; + ? props.defaultValue.length + : 0; // We check whether we have a defaultValue (which must be an array) before checking // the fields prop which will always be empty for a new record. @@ -108,8 +108,9 @@ export class SimpleFormIterator extends Component { const records = get(record, source); return fields ? (
    - {submitFailed && - error && {error}} + {submitFailed && error && ( + {error} + )} {fields.map((member, index) => ( `${baseUrl}${ - tab.props.path ? `/${tab.props.path}` : index > 0 ? `/${index}` : '' + tab.props.path ? `/${tab.props.path}` : index > 0 ? `/${index}` : '' }`; export class TabbedForm extends Component { @@ -136,7 +136,7 @@ export class TabbedForm extends Component { value: tabPath, className: tabsWithErrors.includes(tab.props.label) && - location.pathname !== tabPath + location.pathname !== tabPath ? classes.errorTabButton : null, }); @@ -186,8 +186,7 @@ export class TabbedForm extends Component { React.cloneElement(toolbar, { basePath, className: 'toolbar', - handleSubmitWithRedirect: this - .handleSubmitWithRedirect, + handleSubmitWithRedirect: this.handleSubmitWithRedirect, handleSubmit: this.props.handleSubmit, invalid, pristine, diff --git a/packages/ra-ui-materialui/src/form/Toolbar.js b/packages/ra-ui-materialui/src/form/Toolbar.js index 7b7846d517..8dd9018354 100644 --- a/packages/ra-ui-materialui/src/form/Toolbar.js +++ b/packages/ra-ui-materialui/src/form/Toolbar.js @@ -83,39 +83,36 @@ const Toolbar = ({ saving={saving} submitOnEnter={submitOnEnter} /> - {record && - typeof record.id !== 'undefined' && ( - - )} + {record && typeof record.id !== 'undefined' && ( + + )}
) : ( - Children.map( - children, - button => - button - ? React.cloneElement(button, { - basePath, - handleSubmit: valueOrDefault( - button.props.handleSubmit, - handleSubmit - ), - handleSubmitWithRedirect: valueOrDefault( - button.props.handleSubmitWithRedirect, - handleSubmitWithRedirect - ), - invalid, - pristine, - saving, - submitOnEnter: valueOrDefault( - button.props.submitOnEnter, - submitOnEnter - ), - }) - : null + Children.map(children, button => + button + ? React.cloneElement(button, { + basePath, + handleSubmit: valueOrDefault( + button.props.handleSubmit, + handleSubmit + ), + handleSubmitWithRedirect: valueOrDefault( + button.props.handleSubmitWithRedirect, + handleSubmitWithRedirect + ), + invalid, + pristine, + saving, + submitOnEnter: valueOrDefault( + button.props.submitOnEnter, + submitOnEnter + ), + }) + : null ) )} diff --git a/packages/ra-ui-materialui/src/input/AutocompleteArrayInput.js b/packages/ra-ui-materialui/src/input/AutocompleteArrayInput.js index 2d9e4d522e..613c6fe6c2 100644 --- a/packages/ra-ui-materialui/src/input/AutocompleteArrayInput.js +++ b/packages/ra-ui-materialui/src/input/AutocompleteArrayInput.js @@ -419,13 +419,16 @@ export class AutocompleteArrayInput extends React.Component { this.previousFilterValue = value; }; - shouldRenderSuggestions = (val) => { + shouldRenderSuggestions = val => { const { shouldRenderSuggestions } = this.props; - if (shouldRenderSuggestions !== undefined && typeof shouldRenderSuggestions === 'function') { - return shouldRenderSuggestions(val) + if ( + shouldRenderSuggestions !== undefined && + typeof shouldRenderSuggestions === 'function' + ) { + return shouldRenderSuggestions(val); } - - return true + + return true; }; render() { diff --git a/packages/ra-ui-materialui/src/input/AutocompleteArrayInput.spec.js b/packages/ra-ui-materialui/src/input/AutocompleteArrayInput.spec.js index a00b4b71e0..5b17186cba 100644 --- a/packages/ra-ui-materialui/src/input/AutocompleteArrayInput.spec.js +++ b/packages/ra-ui-materialui/src/input/AutocompleteArrayInput.spec.js @@ -175,15 +175,11 @@ describe('', () => { { context, childContextTypes } ); wrapper.find('input').simulate('focus'); - wrapper - .find('input') - .simulate('change', { target: { value: 'Ma' } }); + wrapper.find('input').simulate('change', { target: { value: 'Ma' } }); expect(wrapper.state('suggestions')).toHaveLength(1); expect(wrapper.find('ListItem')).toHaveLength(0); - wrapper - .find('input') - .simulate('change', { target: { value: 'Mal' } }); + wrapper.find('input').simulate('change', { target: { value: 'Mal' } }); expect(wrapper.state('suggestions')).toHaveLength(1); expect(wrapper.find('ListItem')).toHaveLength(1); }); diff --git a/packages/ra-ui-materialui/src/input/AutocompleteInput.js b/packages/ra-ui-materialui/src/input/AutocompleteInput.js index 17442c4c79..4320016f16 100644 --- a/packages/ra-ui-materialui/src/input/AutocompleteInput.js +++ b/packages/ra-ui-materialui/src/input/AutocompleteInput.js @@ -185,7 +185,7 @@ export class AutocompleteInput extends React.Component { const inputValue = this.getSuggestionValue(suggestion); if (input && input.onChange) { - input.onChange(inputValue) + input.onChange(inputValue); } if (method === 'enter') { diff --git a/packages/ra-ui-materialui/src/input/AutocompleteInput.spec.js b/packages/ra-ui-materialui/src/input/AutocompleteInput.spec.js index 675a532e0f..7bfb43d1e0 100644 --- a/packages/ra-ui-materialui/src/input/AutocompleteInput.spec.js +++ b/packages/ra-ui-materialui/src/input/AutocompleteInput.spec.js @@ -214,9 +214,7 @@ describe('', () => { { context, childContextTypes } ); wrapper.find('input').simulate('focus'); - wrapper - .find('input') - .simulate('change', { target: { value: 'foo' } }); + wrapper.find('input').simulate('change', { target: { value: 'foo' } }); expect(wrapper.state('searchText')).toBe('foo'); expect(wrapper.state('suggestions')).toHaveLength(1); expect(wrapper.find('ListItem')).toHaveLength(0); @@ -545,7 +543,7 @@ describe('', () => { options={{ suggestionsContainerProps: { disablePortal: true, - } + }, }} />, { context, childContextTypes } diff --git a/packages/ra-ui-materialui/src/input/CheckboxGroupInput.js b/packages/ra-ui-materialui/src/input/CheckboxGroupInput.js index ff9dc64a5e..7e7bd92ebb 100644 --- a/packages/ra-ui-materialui/src/input/CheckboxGroupInput.js +++ b/packages/ra-ui-materialui/src/input/CheckboxGroupInput.js @@ -122,8 +122,8 @@ export class CheckboxGroupInput extends Component { const choiceName = React.isValidElement(optionText) // eslint-disable-line no-nested-ternary ? React.cloneElement(optionText, { record: choice }) : typeof optionText === 'function' - ? optionText(choice) - : get(choice, optionText); + ? optionText(choice) + : get(choice, optionText); return ( {choices.map(this.renderCheckbox)} - {touched && - error && {error}} + {touched && error && ( + {error} + )} {helperText && {helperText}} ); diff --git a/packages/ra-ui-materialui/src/input/FileInput.js b/packages/ra-ui-materialui/src/input/FileInput.js index 0e3d582385..056cf7f36d 100644 --- a/packages/ra-ui-materialui/src/input/FileInput.js +++ b/packages/ra-ui-materialui/src/input/FileInput.js @@ -211,13 +211,9 @@ export class FileInput extends Component { ))}
)} - {meta && - meta.touched && - meta.error && ( - - {translate(meta.error)} - - )} + {meta && meta.touched && meta.error && ( + {translate(meta.error)} + )}
); diff --git a/packages/ra-ui-materialui/src/input/FileInput.spec.js b/packages/ra-ui-materialui/src/input/FileInput.spec.js index 718a9c50e4..2b8584553e 100644 --- a/packages/ra-ui-materialui/src/input/FileInput.spec.js +++ b/packages/ra-ui-materialui/src/input/FileInput.spec.js @@ -321,7 +321,9 @@ describe('', () => { ); - const inputPreview = wrapper.find('WithStyles(translate(FileInputPreview))'); + const inputPreview = wrapper.find( + 'WithStyles(translate(FileInputPreview))' + ); inputPreview.at(1).prop('onRemove')(); wrapper.update(); diff --git a/packages/ra-ui-materialui/src/input/ImageInput.spec.js b/packages/ra-ui-materialui/src/input/ImageInput.spec.js index 3805b515df..9d8cbe54e9 100644 --- a/packages/ra-ui-materialui/src/input/ImageInput.spec.js +++ b/packages/ra-ui-materialui/src/input/ImageInput.spec.js @@ -228,7 +228,9 @@ describe('', () => { ); - const inputPreview = wrapper.find('WithStyles(translate(FileInputPreview))'); // FileInputPreview is an muiThemable component + const inputPreview = wrapper.find( + 'WithStyles(translate(FileInputPreview))' + ); // FileInputPreview is an muiThemable component inputPreview.at(1).prop('onRemove')(); wrapper.update(); diff --git a/packages/ra-ui-materialui/src/input/RadioButtonGroupInput.js b/packages/ra-ui-materialui/src/input/RadioButtonGroupInput.js index 92d0feb2d6..7b05839ba5 100644 --- a/packages/ra-ui-materialui/src/input/RadioButtonGroupInput.js +++ b/packages/ra-ui-materialui/src/input/RadioButtonGroupInput.js @@ -92,8 +92,8 @@ export class RadioButtonGroupInput extends Component { const choiceName = React.isValidElement(optionText) // eslint-disable-line no-nested-ternary ? React.cloneElement(optionText, { record: choice }) : typeof optionText === 'function' - ? optionText(choice) - : get(choice, optionText); + ? optionText(choice) + : get(choice, optionText); return ( {choices.map(this.renderRadioButton)} - {touched && - error && {error}} + {touched && error && ( + {error} + )} {helperText && {helperText}} ); diff --git a/packages/ra-ui-materialui/src/input/ResettableTextField.js b/packages/ra-ui-materialui/src/input/ResettableTextField.js index 6d0ac87edc..bbbdbe21d0 100644 --- a/packages/ra-ui-materialui/src/input/ResettableTextField.js +++ b/packages/ra-ui-materialui/src/input/ResettableTextField.js @@ -88,35 +88,30 @@ class ResettableTextField extends Component { classes={restClasses} value={value} InputProps={{ - endAdornment: resettable && - value && ( - - + + - - - - ), + /> + + + ), ...InputProps, }} {...props} diff --git a/packages/ra-ui-materialui/src/input/SelectArrayInput.js b/packages/ra-ui-materialui/src/input/SelectArrayInput.js index 4af0ef85cf..119ed9933f 100644 --- a/packages/ra-ui-materialui/src/input/SelectArrayInput.js +++ b/packages/ra-ui-materialui/src/input/SelectArrayInput.js @@ -234,8 +234,9 @@ export class SelectArrayInput extends Component { > {choices.map(this.renderMenuItem)} - {touched && - error && {error}} + {touched && error && ( + {error} + )} {helperText && {helperText}} ); diff --git a/packages/ra-ui-materialui/src/input/SelectInput.js b/packages/ra-ui-materialui/src/input/SelectInput.js index b343951e85..ddcc1eecc5 100644 --- a/packages/ra-ui-materialui/src/input/SelectInput.js +++ b/packages/ra-ui-materialui/src/input/SelectInput.js @@ -109,15 +109,15 @@ const styles = theme => ({ * * * The object passed as `options` props is passed to the material-ui