Skip to content

Commit beb8822

Browse files
authored
Merge pull request #1225 from marmelab/fix_for_demo_shop
[RFR] Fixes based on aor-demo migration
2 parents 89bc505 + 5646a62 commit beb8822

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1110
-374
lines changed

UPGRADE.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ module.exports = {
106106
107107
Material-ui's implementation of the autocomplete input has radically changed. React-admin maintains backwards compatibility, except for the `filter` prop, which no longer makes sense in the new impementation.
108108
109+
## `<Datagrid>` No Longer Accepts `options`, `headerOptions`, `bodyOptions`, and `rowOptions` props
110+
111+
Material-ui's implementation of the `<Table>` component has reduced dramatically. Therefore, all the advanced features of the datagrid are no longer available from react-admin.
112+
113+
If you need a fixed header, row hover, multi-row selection, or any other material-ui 0.x `<Table>` feature, you'll need to implement your own `<Datagrid>` alternative, e.g. using the library recommended by material-ui, [DevExtreme React Grid](https://devexpress.github.io/devextreme-reactive/react/grid/).
114+
109115
## `<DateInput>` Stores a Date String Instead Of a Date Object
110116
111117
The value of the `<DateInput>` used to be a `Date` object. It's now a `String`, i.e. a stringified date. If you used `format` and `parse` to convert a string to a `Date`, you can now remove these props:

docs/CreateEdit.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The Create and Edit views both display a form, initialized with an empty record
1313

1414
## The `<Create>` and `<Edit>` components
1515

16-
The `<Create>` and `<Edit>` components render the page title and actions, and fetch the record from the REST API. They are not responsible for rendering the actual form - that's the job of their child component (usually `<SimpleForm>`), to which they pass the `record` as prop.
16+
The `<Create>` and `<Edit>` components render the page title and actions, and fetch the record from the data provider. They are not responsible for rendering the actual form - that's the job of their child component (usually `<SimpleForm>`), to which they pass the `record` as prop.
1717

1818
Here are all the props accepted by the `<Create>` and `<Edit>` components:
1919

@@ -114,18 +114,17 @@ export const PostEdit = (props) => (
114114
You can replace the list of default actions by your own element using the `actions` prop:
115115

116116
```jsx
117-
import { CardActions } from 'material-ui/Card';
118117
import Button from 'material-ui/Button';
119-
import { ListButton, ShowButton, DeleteButton, RefreshButton } from 'react-admin';
120-
121-
const cardActionStyle = {
122-
zIndex: 2,
123-
display: 'inline-block',
124-
float: 'right',
125-
};
126-
127-
const PostEditActions = ({ basePath, data, refresh }) => (
128-
<CardActions style={cardActionStyle}>
118+
import {
119+
CardActions,
120+
ListButton,
121+
ShowButton,
122+
DeleteButton,
123+
RefreshButton,
124+
} from 'react-admin';
125+
126+
const PostEditActions = ({ basePath, data }) => (
127+
<CardActions>
129128
<ShowButton basePath={basePath} record={data} />
130129
<ListButton basePath={basePath} />
131130
<DeleteButton basePath={basePath} record={data} />

docs/List.md

Lines changed: 9 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,19 @@ The title can be either a string, or an element of your own.
8282
You can replace the list of default actions by your own element using the `actions` prop:
8383

8484
```jsx
85-
import { CardActions } from 'material-ui/Card';
8685
import Button from 'material-ui/Button';
8786
import NavigationRefresh from 'material-ui-icons/Refresh';
88-
import { CreateButton, RefreshButton } from 'react-admin';
89-
90-
const cardActionStyle = {
91-
zIndex: 2,
92-
display: 'inline-block',
93-
float: 'right',
94-
};
87+
import { CardActions, CreateButton, RefreshButton } from 'react-admin';
9588

9689
const PostActions = ({ resource, filters, displayedFilters, filterValues, basePath, showFilter }) => (
97-
<CardActions style={cardActionStyle}>
98-
{filters && React.cloneElement(filters, { resource, showFilter, displayedFilters, filterValues, context: 'button' }) }
90+
<CardActions>
91+
{filters && React.cloneElement(filters, {
92+
resource,
93+
showFilter,
94+
displayedFilters,
95+
filterValues,
96+
context: 'button',
97+
}) }
9998
<CreateButton basePath={basePath} />
10099
<RefreshButton />
101100
{/* Add your custom actions */}
@@ -255,10 +254,6 @@ Here are all the props accepted by the component:
255254

256255
* [`styles`](#custom-grid-style)
257256
* [`rowStyle`](#row-style-function)
258-
* [`options`](#options)
259-
* [`headerOptions`](#options)
260-
* [`bodyOptions`](#options)
261-
* [`rowOptions`](#options)
262257

263258
It renders as many columns as it receives `<Field>` children.
264259

@@ -350,40 +345,6 @@ export const PostList = (props) => (
350345
);
351346
```
352347

353-
### `options`, `headerOptions`, `bodyOptions`, and `rowOptions`
354-
355-
React-admin relies on [material-ui's `<Table>` component](http://www.material-ui.com/#/components/table) for rendering the datagrid. The `options`, `headerOptions`, `bodyOptions`, and `rowOptions` props allow your to override the props of `<Table>`, `<TableHeader>`, `<TableBody>`, and `<TableRow>`.
356-
357-
For instance, to get a fixed header on the table, override the `<Table>` props with `options`:
358-
359-
{% raw %}
360-
```jsx
361-
export const PostList = (props) => (
362-
<List {...props}>
363-
<Datagrid options={{ fixedHeader: true, height: 400 }}>
364-
...
365-
</Datagrid>
366-
</List>
367-
);
368-
```
369-
{% endraw %}
370-
371-
To enable striped rows and row hover, override the `<TableBody>` props with `bodyOptions`:
372-
373-
{% raw %}
374-
```jsx
375-
export const PostList = (props) => (
376-
<List {...props}>
377-
<Datagrid bodyOptions={{ stripedRows: true, showRowHover: true }}>
378-
...
379-
</Datagrid>
380-
</List>
381-
);
382-
```
383-
{% endraw %}
384-
385-
For a list of all the possible props that you can override via these options, please refer to [the material-ui `<Table>` component documentation](http://www.material-ui.com/#/components/table).
386-
387348
## The `<SimpleList>` component
388349

389350
For mobile devices, a `<Datagrid>` is often unusable - there is simply not enough space to display several columns. The convention in that case is to use a simple list, with only one column per row. The `<SimpleList>` component serves that purpose, leveraging [material-ui's `<List>` and `<ListItem>` components](http://www.material-ui.com/#/components/list). You can use it as `<List>` or `<ReferenceManyField>` child:

packages/react-admin/src/actions/accumulateActions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { crudGetMany } from './dataActions';
22

3-
export const CRUD_GET_MANY_ACCUMULATE = 'AOR/CRUD_GET_MANY_ACCUMULATE';
3+
export const CRUD_GET_MANY_ACCUMULATE = 'RA/CRUD_GET_MANY_ACCUMULATE';
44

55
export const crudGetManyAccumulate = (resource, ids) => ({
66
type: CRUD_GET_MANY_ACCUMULATE,

packages/react-admin/src/actions/authActions.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
export const USER_LOGIN = 'AOR/USER_LOGIN';
2-
export const USER_LOGIN_LOADING = 'AOR/USER_LOGIN_LOADING';
3-
export const USER_LOGIN_FAILURE = 'AOR/USER_LOGIN_FAILURE';
4-
export const USER_LOGIN_SUCCESS = 'AOR/USER_LOGIN_SUCCESS';
1+
export const USER_LOGIN = 'RA/USER_LOGIN';
2+
export const USER_LOGIN_LOADING = 'RA/USER_LOGIN_LOADING';
3+
export const USER_LOGIN_FAILURE = 'RA/USER_LOGIN_FAILURE';
4+
export const USER_LOGIN_SUCCESS = 'RA/USER_LOGIN_SUCCESS';
55

66
export const userLogin = (payload, pathName) => ({
77
type: USER_LOGIN,
88
payload,
99
meta: { auth: true, pathName },
1010
});
1111

12-
export const USER_CHECK = 'AOR/USER_CHECK';
12+
export const USER_CHECK = 'RA/USER_CHECK';
1313

1414
export const userCheck = (payload, pathName) => ({
1515
type: USER_CHECK,
1616
payload,
1717
meta: { auth: true, pathName },
1818
});
1919

20-
export const USER_LOGOUT = 'AOR/USER_LOGOUT';
20+
export const USER_LOGOUT = 'RA/USER_LOGOUT';
2121

2222
export const userLogout = () => ({
2323
type: USER_LOGOUT,

packages/react-admin/src/actions/dataActions.js

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import {
88
GET_MANY_REFERENCE,
99
} from '../dataFetchActions';
1010

11-
export const CRUD_GET_LIST = 'AOR/CRUD_GET_LIST';
12-
export const CRUD_GET_LIST_LOADING = 'AOR/CRUD_GET_LIST_LOADING';
13-
export const CRUD_GET_LIST_FAILURE = 'AOR/CRUD_GET_LIST_FAILURE';
14-
export const CRUD_GET_LIST_SUCCESS = 'AOR/CRUD_GET_LIST_SUCCESS';
11+
export const CRUD_GET_LIST = 'RA/CRUD_GET_LIST';
12+
export const CRUD_GET_LIST_LOADING = 'RA/CRUD_GET_LIST_LOADING';
13+
export const CRUD_GET_LIST_FAILURE = 'RA/CRUD_GET_LIST_FAILURE';
14+
export const CRUD_GET_LIST_SUCCESS = 'RA/CRUD_GET_LIST_SUCCESS';
1515

1616
export const crudGetList = (
1717
resource,
@@ -25,32 +25,32 @@ export const crudGetList = (
2525
meta: { resource, fetch: GET_LIST, cancelPrevious },
2626
});
2727

28-
export const CRUD_GET_ONE = 'AOR/CRUD_GET_ONE';
29-
export const CRUD_GET_ONE_LOADING = 'AOR/CRUD_GET_ONE_LOADING';
30-
export const CRUD_GET_ONE_FAILURE = 'AOR/CRUD_GET_ONE_FAILURE';
31-
export const CRUD_GET_ONE_SUCCESS = 'AOR/CRUD_GET_ONE_SUCCESS';
28+
export const CRUD_GET_ONE = 'RA/CRUD_GET_ONE';
29+
export const CRUD_GET_ONE_LOADING = 'RA/CRUD_GET_ONE_LOADING';
30+
export const CRUD_GET_ONE_FAILURE = 'RA/CRUD_GET_ONE_FAILURE';
31+
export const CRUD_GET_ONE_SUCCESS = 'RA/CRUD_GET_ONE_SUCCESS';
3232

3333
export const crudGetOne = (resource, id, basePath, cancelPrevious = true) => ({
3434
type: CRUD_GET_ONE,
3535
payload: { id, basePath },
3636
meta: { resource, fetch: GET_ONE, cancelPrevious },
3737
});
3838

39-
export const CRUD_CREATE = 'AOR/CRUD_CREATE';
40-
export const CRUD_CREATE_LOADING = 'AOR/CRUD_CREATE_LOADING';
41-
export const CRUD_CREATE_FAILURE = 'AOR/CRUD_CREATE_FAILURE';
42-
export const CRUD_CREATE_SUCCESS = 'AOR/CRUD_CREATE_SUCCESS';
39+
export const CRUD_CREATE = 'RA/CRUD_CREATE';
40+
export const CRUD_CREATE_LOADING = 'RA/CRUD_CREATE_LOADING';
41+
export const CRUD_CREATE_FAILURE = 'RA/CRUD_CREATE_FAILURE';
42+
export const CRUD_CREATE_SUCCESS = 'RA/CRUD_CREATE_SUCCESS';
4343

4444
export const crudCreate = (resource, data, basePath, redirectTo = 'edit') => ({
4545
type: CRUD_CREATE,
4646
payload: { data, basePath, redirectTo },
4747
meta: { resource, fetch: CREATE, cancelPrevious: false },
4848
});
4949

50-
export const CRUD_UPDATE = 'AOR/CRUD_UPDATE';
51-
export const CRUD_UPDATE_LOADING = 'AOR/CRUD_UPDATE_LOADING';
52-
export const CRUD_UPDATE_FAILURE = 'AOR/CRUD_UPDATE_FAILURE';
53-
export const CRUD_UPDATE_SUCCESS = 'AOR/CRUD_UPDATE_SUCCESS';
50+
export const CRUD_UPDATE = 'RA/CRUD_UPDATE';
51+
export const CRUD_UPDATE_LOADING = 'RA/CRUD_UPDATE_LOADING';
52+
export const CRUD_UPDATE_FAILURE = 'RA/CRUD_UPDATE_FAILURE';
53+
export const CRUD_UPDATE_SUCCESS = 'RA/CRUD_UPDATE_SUCCESS';
5454

5555
export const crudUpdate = (
5656
resource,
@@ -65,10 +65,10 @@ export const crudUpdate = (
6565
meta: { resource, fetch: UPDATE, cancelPrevious: false },
6666
});
6767

68-
export const CRUD_DELETE = 'AOR/CRUD_DELETE';
69-
export const CRUD_DELETE_LOADING = 'AOR/CRUD_DELETE_LOADING';
70-
export const CRUD_DELETE_FAILURE = 'AOR/CRUD_DELETE_FAILURE';
71-
export const CRUD_DELETE_SUCCESS = 'AOR/CRUD_DELETE_SUCCESS';
68+
export const CRUD_DELETE = 'RA/CRUD_DELETE';
69+
export const CRUD_DELETE_LOADING = 'RA/CRUD_DELETE_LOADING';
70+
export const CRUD_DELETE_FAILURE = 'RA/CRUD_DELETE_FAILURE';
71+
export const CRUD_DELETE_SUCCESS = 'RA/CRUD_DELETE_SUCCESS';
7272

7373
export const crudDelete = (
7474
resource,
@@ -82,10 +82,10 @@ export const crudDelete = (
8282
meta: { resource, fetch: DELETE, cancelPrevious: false },
8383
});
8484

85-
export const CRUD_GET_MANY = 'AOR/CRUD_GET_MANY';
86-
export const CRUD_GET_MANY_LOADING = 'AOR/CRUD_GET_MANY_LOADING';
87-
export const CRUD_GET_MANY_FAILURE = 'AOR/CRUD_GET_MANY_FAILURE';
88-
export const CRUD_GET_MANY_SUCCESS = 'AOR/CRUD_GET_MANY_SUCCESS';
85+
export const CRUD_GET_MANY = 'RA/CRUD_GET_MANY';
86+
export const CRUD_GET_MANY_LOADING = 'RA/CRUD_GET_MANY_LOADING';
87+
export const CRUD_GET_MANY_FAILURE = 'RA/CRUD_GET_MANY_FAILURE';
88+
export const CRUD_GET_MANY_SUCCESS = 'RA/CRUD_GET_MANY_SUCCESS';
8989

9090
// Reference related actions
9191

@@ -95,10 +95,10 @@ export const crudGetMany = (resource, ids) => ({
9595
meta: { resource, fetch: GET_MANY, cancelPrevious: false },
9696
});
9797

98-
export const CRUD_GET_MATCHING = 'AOR/CRUD_GET_MATCHING';
99-
export const CRUD_GET_MATCHING_LOADING = 'AOR/CRUD_GET_MATCHING_LOADING';
100-
export const CRUD_GET_MATCHING_FAILURE = 'AOR/CRUD_GET_MATCHING_FAILURE';
101-
export const CRUD_GET_MATCHING_SUCCESS = 'AOR/CRUD_GET_MATCHING_SUCCESS';
98+
export const CRUD_GET_MATCHING = 'RA/CRUD_GET_MATCHING';
99+
export const CRUD_GET_MATCHING_LOADING = 'RA/CRUD_GET_MATCHING_LOADING';
100+
export const CRUD_GET_MATCHING_FAILURE = 'RA/CRUD_GET_MATCHING_FAILURE';
101+
export const CRUD_GET_MATCHING_SUCCESS = 'RA/CRUD_GET_MATCHING_SUCCESS';
102102

103103
export const crudGetMatching = (
104104
reference,
@@ -117,13 +117,13 @@ export const crudGetMatching = (
117117
},
118118
});
119119

120-
export const CRUD_GET_MANY_REFERENCE = 'AOR/CRUD_GET_MANY_REFERENCE';
120+
export const CRUD_GET_MANY_REFERENCE = 'RA/CRUD_GET_MANY_REFERENCE';
121121
export const CRUD_GET_MANY_REFERENCE_LOADING =
122-
'AOR/CRUD_GET_MANY_REFERENCE_LOADING';
122+
'RA/CRUD_GET_MANY_REFERENCE_LOADING';
123123
export const CRUD_GET_MANY_REFERENCE_FAILURE =
124-
'AOR/CRUD_GET_MANY_REFERENCE_FAILURE';
124+
'RA/CRUD_GET_MANY_REFERENCE_FAILURE';
125125
export const CRUD_GET_MANY_REFERENCE_SUCCESS =
126-
'AOR/CRUD_GET_MANY_REFERENCE_SUCCESS';
126+
'RA/CRUD_GET_MANY_REFERENCE_SUCCESS';
127127

128128
export const crudGetManyReference = (
129129
reference,
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const FETCH_START = 'AOR/FETCH_START';
2-
export const FETCH_END = 'AOR/FETCH_END';
3-
export const FETCH_ERROR = 'AOR/FETCH_ERROR';
4-
export const FETCH_CANCEL = 'AOR/FETCH_CANCEL';
1+
export const FETCH_START = 'RA/FETCH_START';
2+
export const FETCH_END = 'RA/FETCH_END';
3+
export const FETCH_ERROR = 'RA/FETCH_ERROR';
4+
export const FETCH_CANCEL = 'RA/FETCH_CANCEL';

packages/react-admin/src/actions/filterActions.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
export const CRUD_SHOW_FILTER = 'AOR/CRUD_SHOW_FILTER';
2-
export const CRUD_HIDE_FILTER = 'AOR/CRUD_HIDE_FILTER';
3-
export const CRUD_SET_FILTER = 'AOR/CRUD_SET_FILTER';
1+
export const CRUD_SHOW_FILTER = 'RA/CRUD_SHOW_FILTER';
2+
export const CRUD_HIDE_FILTER = 'RA/CRUD_HIDE_FILTER';
3+
export const CRUD_SET_FILTER = 'RA/CRUD_SET_FILTER';
44

55
export const showFilter = (resource, field) => ({
66
type: CRUD_SHOW_FILTER,

packages/react-admin/src/actions/formActions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const INITIALIZE_FORM = 'AOR/INITIALIZE_FORM';
1+
export const INITIALIZE_FORM = 'RA/INITIALIZE_FORM';
22

33
export const initializeForm = initialValues => ({
44
type: INITIALIZE_FORM,

packages/react-admin/src/actions/listActions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const CRUD_CHANGE_LIST_PARAMS = 'AOR/CRUD_CHANGE_LIST_PARAMS';
1+
export const CRUD_CHANGE_LIST_PARAMS = 'RA/CRUD_CHANGE_LIST_PARAMS';
22

33
export const changeListParams = (resource, params) => ({
44
type: CRUD_CHANGE_LIST_PARAMS,

0 commit comments

Comments
 (0)