Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[List, Edit, Create, Show] Wrap view components into styles HOC instead of wrapping main components #3161

Merged
merged 6 commits into from
Apr 25, 2019
8 changes: 4 additions & 4 deletions packages/ra-ui-materialui/src/detail/Create.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const sanitizeRestProps = ({
...rest
}) => rest;

export const CreateView = ({
export const CreateView = withStyles(styles)(({
actions,
aside,
basePath,
Expand Down Expand Up @@ -95,7 +95,7 @@ export const CreateView = ({
save,
})}
</div>
);
));

CreateView.propTypes = {
actions: PropTypes.element,
Expand Down Expand Up @@ -159,7 +159,7 @@ CreateView.defaultProps = {
* );
* export default App;
*/
export const Create = props => (
const Create = props => (
<CreateController {...props}>
{controllerProps => <CreateView {...props} {...controllerProps} />}
</CreateController>
Expand All @@ -180,4 +180,4 @@ Create.propTypes = {
hasList: PropTypes.bool,
};

export default withStyles(styles)(Create);
export default Create;
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/detail/Create.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { render } from 'enzyme';
import { TestContext } from 'ra-core';

import { Create } from './Create';
import Create from './Create';

describe('<Create />', () => {
const defaultCreateProps = {
Expand Down
8 changes: 4 additions & 4 deletions packages/ra-ui-materialui/src/detail/Edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const sanitizeRestProps = ({
...rest
}) => rest;

export const EditView = ({
export const EditView = withStyles(styles)(({
actions,
aside,
basePath,
Expand Down Expand Up @@ -122,7 +122,7 @@ export const EditView = ({
})}
</div>
);
};
});

EditView.propTypes = {
actions: PropTypes.element,
Expand Down Expand Up @@ -188,7 +188,7 @@ EditView.defaultProps = {
* );
* export default App;
*/
export const Edit = props => (
const Edit = props => (
<EditController {...props}>
{controllerProps => <EditView {...props} {...controllerProps} />}
</EditController>
Expand All @@ -209,4 +209,4 @@ Edit.propTypes = {
title: PropTypes.any,
};

export default withStyles(styles)(Edit);
export default Edit;
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/detail/Edit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { render } from 'enzyme';
import { TestContext } from 'ra-core';

import { Edit } from './Edit';
import Edit from './Edit';

describe('<Edit />', () => {
const defaultEditProps = {
Expand Down
8 changes: 4 additions & 4 deletions packages/ra-ui-materialui/src/detail/Show.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const sanitizeRestProps = ({
...rest
}) => rest;

export const ShowView = ({
export const ShowView = withStyles(styles)(({
actions,
aside,
basePath,
Expand Down Expand Up @@ -107,7 +107,7 @@ export const ShowView = ({
})}
</div>
);
};
});

ShowView.propTypes = {
actions: PropTypes.element,
Expand Down Expand Up @@ -172,7 +172,7 @@ ShowView.defaultProps = {
* );
* export default App;
*/
export const Show = props => (
const Show = props => (
<ShowController {...props}>
{controllerProps => <ShowView {...props} {...controllerProps} />}
</ShowController>
Expand All @@ -193,4 +193,4 @@ Show.propTypes = {
title: PropTypes.any,
};

export default withStyles(styles)(Show);
export default Show;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not make much sense to have both a named and a default export for the same object. Remove the named export (you will have to change the import in Show.spec.js, too).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/detail/Show.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { render } from 'enzyme';
import { TestContext } from 'ra-core';

import { Show } from './Show';
import Show from './Show';

describe('<Show />', () => {
const defaultShowProps = {
Expand Down
8 changes: 4 additions & 4 deletions packages/ra-ui-materialui/src/list/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const sanitizeRestProps = ({
...rest
}) => rest;

export const ListView = ({
export const ListView = withStyles(styles)(({
// component props
actions,
aside,
Expand Down Expand Up @@ -156,7 +156,7 @@ export const ListView = ({
{aside && cloneElement(aside, controllerProps)}
</div>
);
};
});

ListView.propTypes = {
actions: PropTypes.element,
Expand Down Expand Up @@ -250,7 +250,7 @@ ListView.defaultProps = {
* </List>
* );
*/
export const List = props => (
const List = props => (
<ListController {...props}>
{controllerProps => <ListView {...props} {...controllerProps} />}
</ListController>
Expand Down Expand Up @@ -294,4 +294,4 @@ List.defaultProps = {
theme: defaultTheme,
};

export default withStyles(styles)(List);
export default List;
6 changes: 3 additions & 3 deletions packages/ra-ui-materialui/src/list/List.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import { shallow, render } from 'enzyme';
import { TestContext } from 'ra-core';

import { List, ListView } from './List';
import List, { ListView } from './List';

describe('<List />', () => {
const defaultProps = {
Expand All @@ -27,7 +27,7 @@ describe('<List />', () => {
<ListView {...defaultProps}>
<Datagrid />
</ListView>
);
).dive();
assert.equal(wrapper.find('WithStyles(Card)').length, 1);
});

Expand All @@ -43,7 +43,7 @@ describe('<List />', () => {
>
<Datagrid />
</ListView>
);
).dive();
expect(
wrapper.find('translate(WithStyles(BulkActionsToolbar))')
).toHaveLength(1);
Expand Down