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

[RFR] Fixes based on aor-demo migration #1225

Merged
merged 16 commits into from
Dec 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ module.exports = {

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.

## `<Datagrid>` No Longer Accepts `options`, `headerOptions`, `bodyOptions`, and `rowOptions` props

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.

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/).

## `<DateInput>` Stores a Date String Instead Of a Date Object

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:
Expand Down
23 changes: 11 additions & 12 deletions docs/CreateEdit.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The Create and Edit views both display a form, initialized with an empty record

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

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.
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.

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

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

```jsx
import { CardActions } from 'material-ui/Card';
import Button from 'material-ui/Button';
import { ListButton, ShowButton, DeleteButton, RefreshButton } from 'react-admin';

const cardActionStyle = {
zIndex: 2,
display: 'inline-block',
float: 'right',
};

const PostEditActions = ({ basePath, data, refresh }) => (
<CardActions style={cardActionStyle}>
import {
CardActions,
ListButton,
ShowButton,
DeleteButton,
RefreshButton,
} from 'react-admin';

const PostEditActions = ({ basePath, data }) => (
<CardActions>
<ShowButton basePath={basePath} record={data} />
<ListButton basePath={basePath} />
<DeleteButton basePath={basePath} record={data} />
Expand Down
57 changes: 9 additions & 48 deletions docs/List.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,19 @@ The title can be either a string, or an element of your own.
You can replace the list of default actions by your own element using the `actions` prop:

```jsx
import { CardActions } from 'material-ui/Card';
import Button from 'material-ui/Button';
import NavigationRefresh from 'material-ui-icons/Refresh';
import { CreateButton, RefreshButton } from 'react-admin';

const cardActionStyle = {
zIndex: 2,
display: 'inline-block',
float: 'right',
};
import { CardActions, CreateButton, RefreshButton } from 'react-admin';

const PostActions = ({ resource, filters, displayedFilters, filterValues, basePath, showFilter }) => (
<CardActions style={cardActionStyle}>
{filters && React.cloneElement(filters, { resource, showFilter, displayedFilters, filterValues, context: 'button' }) }
<CardActions>
{filters && React.cloneElement(filters, {
resource,
showFilter,
displayedFilters,
filterValues,
context: 'button',
}) }
<CreateButton basePath={basePath} />
<RefreshButton />
{/* Add your custom actions */}
Expand Down Expand Up @@ -255,10 +254,6 @@ Here are all the props accepted by the component:

* [`styles`](#custom-grid-style)
* [`rowStyle`](#row-style-function)
* [`options`](#options)
* [`headerOptions`](#options)
* [`bodyOptions`](#options)
* [`rowOptions`](#options)

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

Expand Down Expand Up @@ -350,40 +345,6 @@ export const PostList = (props) => (
);
```

### `options`, `headerOptions`, `bodyOptions`, and `rowOptions`

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>`.

For instance, to get a fixed header on the table, override the `<Table>` props with `options`:

{% raw %}
```jsx
export const PostList = (props) => (
<List {...props}>
<Datagrid options={{ fixedHeader: true, height: 400 }}>
...
</Datagrid>
</List>
);
```
{% endraw %}

To enable striped rows and row hover, override the `<TableBody>` props with `bodyOptions`:

{% raw %}
```jsx
export const PostList = (props) => (
<List {...props}>
<Datagrid bodyOptions={{ stripedRows: true, showRowHover: true }}>
...
</Datagrid>
</List>
);
```
{% endraw %}

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).

## The `<SimpleList>` component

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:
Expand Down
2 changes: 1 addition & 1 deletion packages/react-admin/src/actions/accumulateActions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { crudGetMany } from './dataActions';

export const CRUD_GET_MANY_ACCUMULATE = 'AOR/CRUD_GET_MANY_ACCUMULATE';
export const CRUD_GET_MANY_ACCUMULATE = 'RA/CRUD_GET_MANY_ACCUMULATE';

export const crudGetManyAccumulate = (resource, ids) => ({
type: CRUD_GET_MANY_ACCUMULATE,
Expand Down
12 changes: 6 additions & 6 deletions packages/react-admin/src/actions/authActions.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
export const USER_LOGIN = 'AOR/USER_LOGIN';
export const USER_LOGIN_LOADING = 'AOR/USER_LOGIN_LOADING';
export const USER_LOGIN_FAILURE = 'AOR/USER_LOGIN_FAILURE';
export const USER_LOGIN_SUCCESS = 'AOR/USER_LOGIN_SUCCESS';
export const USER_LOGIN = 'RA/USER_LOGIN';
export const USER_LOGIN_LOADING = 'RA/USER_LOGIN_LOADING';
export const USER_LOGIN_FAILURE = 'RA/USER_LOGIN_FAILURE';
export const USER_LOGIN_SUCCESS = 'RA/USER_LOGIN_SUCCESS';

export const userLogin = (payload, pathName) => ({
type: USER_LOGIN,
payload,
meta: { auth: true, pathName },
});

export const USER_CHECK = 'AOR/USER_CHECK';
export const USER_CHECK = 'RA/USER_CHECK';

export const userCheck = (payload, pathName) => ({
type: USER_CHECK,
payload,
meta: { auth: true, pathName },
});

export const USER_LOGOUT = 'AOR/USER_LOGOUT';
export const USER_LOGOUT = 'RA/USER_LOGOUT';

export const userLogout = () => ({
type: USER_LOGOUT,
Expand Down
64 changes: 32 additions & 32 deletions packages/react-admin/src/actions/dataActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import {
GET_MANY_REFERENCE,
} from '../dataFetchActions';

export const CRUD_GET_LIST = 'AOR/CRUD_GET_LIST';
export const CRUD_GET_LIST_LOADING = 'AOR/CRUD_GET_LIST_LOADING';
export const CRUD_GET_LIST_FAILURE = 'AOR/CRUD_GET_LIST_FAILURE';
export const CRUD_GET_LIST_SUCCESS = 'AOR/CRUD_GET_LIST_SUCCESS';
export const CRUD_GET_LIST = 'RA/CRUD_GET_LIST';
export const CRUD_GET_LIST_LOADING = 'RA/CRUD_GET_LIST_LOADING';
export const CRUD_GET_LIST_FAILURE = 'RA/CRUD_GET_LIST_FAILURE';
export const CRUD_GET_LIST_SUCCESS = 'RA/CRUD_GET_LIST_SUCCESS';

export const crudGetList = (
resource,
Expand All @@ -25,32 +25,32 @@ export const crudGetList = (
meta: { resource, fetch: GET_LIST, cancelPrevious },
});

export const CRUD_GET_ONE = 'AOR/CRUD_GET_ONE';
export const CRUD_GET_ONE_LOADING = 'AOR/CRUD_GET_ONE_LOADING';
export const CRUD_GET_ONE_FAILURE = 'AOR/CRUD_GET_ONE_FAILURE';
export const CRUD_GET_ONE_SUCCESS = 'AOR/CRUD_GET_ONE_SUCCESS';
export const CRUD_GET_ONE = 'RA/CRUD_GET_ONE';
export const CRUD_GET_ONE_LOADING = 'RA/CRUD_GET_ONE_LOADING';
export const CRUD_GET_ONE_FAILURE = 'RA/CRUD_GET_ONE_FAILURE';
export const CRUD_GET_ONE_SUCCESS = 'RA/CRUD_GET_ONE_SUCCESS';

export const crudGetOne = (resource, id, basePath, cancelPrevious = true) => ({
type: CRUD_GET_ONE,
payload: { id, basePath },
meta: { resource, fetch: GET_ONE, cancelPrevious },
});

export const CRUD_CREATE = 'AOR/CRUD_CREATE';
export const CRUD_CREATE_LOADING = 'AOR/CRUD_CREATE_LOADING';
export const CRUD_CREATE_FAILURE = 'AOR/CRUD_CREATE_FAILURE';
export const CRUD_CREATE_SUCCESS = 'AOR/CRUD_CREATE_SUCCESS';
export const CRUD_CREATE = 'RA/CRUD_CREATE';
export const CRUD_CREATE_LOADING = 'RA/CRUD_CREATE_LOADING';
export const CRUD_CREATE_FAILURE = 'RA/CRUD_CREATE_FAILURE';
export const CRUD_CREATE_SUCCESS = 'RA/CRUD_CREATE_SUCCESS';

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

export const CRUD_UPDATE = 'AOR/CRUD_UPDATE';
export const CRUD_UPDATE_LOADING = 'AOR/CRUD_UPDATE_LOADING';
export const CRUD_UPDATE_FAILURE = 'AOR/CRUD_UPDATE_FAILURE';
export const CRUD_UPDATE_SUCCESS = 'AOR/CRUD_UPDATE_SUCCESS';
export const CRUD_UPDATE = 'RA/CRUD_UPDATE';
export const CRUD_UPDATE_LOADING = 'RA/CRUD_UPDATE_LOADING';
export const CRUD_UPDATE_FAILURE = 'RA/CRUD_UPDATE_FAILURE';
export const CRUD_UPDATE_SUCCESS = 'RA/CRUD_UPDATE_SUCCESS';

export const crudUpdate = (
resource,
Expand All @@ -65,10 +65,10 @@ export const crudUpdate = (
meta: { resource, fetch: UPDATE, cancelPrevious: false },
});

export const CRUD_DELETE = 'AOR/CRUD_DELETE';
export const CRUD_DELETE_LOADING = 'AOR/CRUD_DELETE_LOADING';
export const CRUD_DELETE_FAILURE = 'AOR/CRUD_DELETE_FAILURE';
export const CRUD_DELETE_SUCCESS = 'AOR/CRUD_DELETE_SUCCESS';
export const CRUD_DELETE = 'RA/CRUD_DELETE';
export const CRUD_DELETE_LOADING = 'RA/CRUD_DELETE_LOADING';
export const CRUD_DELETE_FAILURE = 'RA/CRUD_DELETE_FAILURE';
export const CRUD_DELETE_SUCCESS = 'RA/CRUD_DELETE_SUCCESS';

export const crudDelete = (
resource,
Expand All @@ -82,10 +82,10 @@ export const crudDelete = (
meta: { resource, fetch: DELETE, cancelPrevious: false },
});

export const CRUD_GET_MANY = 'AOR/CRUD_GET_MANY';
export const CRUD_GET_MANY_LOADING = 'AOR/CRUD_GET_MANY_LOADING';
export const CRUD_GET_MANY_FAILURE = 'AOR/CRUD_GET_MANY_FAILURE';
export const CRUD_GET_MANY_SUCCESS = 'AOR/CRUD_GET_MANY_SUCCESS';
export const CRUD_GET_MANY = 'RA/CRUD_GET_MANY';
export const CRUD_GET_MANY_LOADING = 'RA/CRUD_GET_MANY_LOADING';
export const CRUD_GET_MANY_FAILURE = 'RA/CRUD_GET_MANY_FAILURE';
export const CRUD_GET_MANY_SUCCESS = 'RA/CRUD_GET_MANY_SUCCESS';

// Reference related actions

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

export const CRUD_GET_MATCHING = 'AOR/CRUD_GET_MATCHING';
export const CRUD_GET_MATCHING_LOADING = 'AOR/CRUD_GET_MATCHING_LOADING';
export const CRUD_GET_MATCHING_FAILURE = 'AOR/CRUD_GET_MATCHING_FAILURE';
export const CRUD_GET_MATCHING_SUCCESS = 'AOR/CRUD_GET_MATCHING_SUCCESS';
export const CRUD_GET_MATCHING = 'RA/CRUD_GET_MATCHING';
export const CRUD_GET_MATCHING_LOADING = 'RA/CRUD_GET_MATCHING_LOADING';
export const CRUD_GET_MATCHING_FAILURE = 'RA/CRUD_GET_MATCHING_FAILURE';
export const CRUD_GET_MATCHING_SUCCESS = 'RA/CRUD_GET_MATCHING_SUCCESS';

export const crudGetMatching = (
reference,
Expand All @@ -117,13 +117,13 @@ export const crudGetMatching = (
},
});

export const CRUD_GET_MANY_REFERENCE = 'AOR/CRUD_GET_MANY_REFERENCE';
export const CRUD_GET_MANY_REFERENCE = 'RA/CRUD_GET_MANY_REFERENCE';
export const CRUD_GET_MANY_REFERENCE_LOADING =
'AOR/CRUD_GET_MANY_REFERENCE_LOADING';
'RA/CRUD_GET_MANY_REFERENCE_LOADING';
export const CRUD_GET_MANY_REFERENCE_FAILURE =
'AOR/CRUD_GET_MANY_REFERENCE_FAILURE';
'RA/CRUD_GET_MANY_REFERENCE_FAILURE';
export const CRUD_GET_MANY_REFERENCE_SUCCESS =
'AOR/CRUD_GET_MANY_REFERENCE_SUCCESS';
'RA/CRUD_GET_MANY_REFERENCE_SUCCESS';

export const crudGetManyReference = (
reference,
Expand Down
8 changes: 4 additions & 4 deletions packages/react-admin/src/actions/fetchActions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const FETCH_START = 'AOR/FETCH_START';
export const FETCH_END = 'AOR/FETCH_END';
export const FETCH_ERROR = 'AOR/FETCH_ERROR';
export const FETCH_CANCEL = 'AOR/FETCH_CANCEL';
export const FETCH_START = 'RA/FETCH_START';
export const FETCH_END = 'RA/FETCH_END';
export const FETCH_ERROR = 'RA/FETCH_ERROR';
export const FETCH_CANCEL = 'RA/FETCH_CANCEL';
6 changes: 3 additions & 3 deletions packages/react-admin/src/actions/filterActions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const CRUD_SHOW_FILTER = 'AOR/CRUD_SHOW_FILTER';
export const CRUD_HIDE_FILTER = 'AOR/CRUD_HIDE_FILTER';
export const CRUD_SET_FILTER = 'AOR/CRUD_SET_FILTER';
export const CRUD_SHOW_FILTER = 'RA/CRUD_SHOW_FILTER';
export const CRUD_HIDE_FILTER = 'RA/CRUD_HIDE_FILTER';
export const CRUD_SET_FILTER = 'RA/CRUD_SET_FILTER';

export const showFilter = (resource, field) => ({
type: CRUD_SHOW_FILTER,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-admin/src/actions/formActions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const INITIALIZE_FORM = 'AOR/INITIALIZE_FORM';
export const INITIALIZE_FORM = 'RA/INITIALIZE_FORM';

export const initializeForm = initialValues => ({
type: INITIALIZE_FORM,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-admin/src/actions/listActions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const CRUD_CHANGE_LIST_PARAMS = 'AOR/CRUD_CHANGE_LIST_PARAMS';
export const CRUD_CHANGE_LIST_PARAMS = 'RA/CRUD_CHANGE_LIST_PARAMS';

export const changeListParams = (resource, params) => ({
type: CRUD_CHANGE_LIST_PARAMS,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-admin/src/actions/localeActions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const CHANGE_LOCALE = 'AOR/CHANGE_LOCALE';
export const CHANGE_LOCALE = 'RA/CHANGE_LOCALE';

export const changeLocale = locale => ({
type: CHANGE_LOCALE,
Expand Down
4 changes: 2 additions & 2 deletions packages/react-admin/src/actions/notificationActions.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export const SHOW_NOTIFICATION = 'AOR/SHOW_NOTIFICATION';
export const SHOW_NOTIFICATION = 'RA/SHOW_NOTIFICATION';

export const showNotification = (text, type = 'info', autoHideDuration) => ({
type: SHOW_NOTIFICATION,
payload: { text, type, autoHideDuration },
});

export const HIDE_NOTIFICATION = 'AOR/HIDE_NOTIFICATION';
export const HIDE_NOTIFICATION = 'RA/HIDE_NOTIFICATION';

export const hideNotification = () => ({
type: HIDE_NOTIFICATION,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-admin/src/actions/resourcesActions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const DECLARE_RESOURCES = 'AOR/DECLARE_RESOURCES';
export const DECLARE_RESOURCES = 'RA/DECLARE_RESOURCES';

export const declareResources = resources => ({
type: DECLARE_RESOURCES,
Expand Down
6 changes: 3 additions & 3 deletions packages/react-admin/src/actions/uiActions.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
export const TOGGLE_SIDEBAR = 'AOR/TOGGLE_SIDEBAR';
export const TOGGLE_SIDEBAR = 'RA/TOGGLE_SIDEBAR';

export const toggleSidebar = () => ({
type: TOGGLE_SIDEBAR,
});

export const SET_SIDEBAR_VISIBILITY = 'AOR/SET_SIDEBAR_VISIBILITY';
export const SET_SIDEBAR_VISIBILITY = 'RA/SET_SIDEBAR_VISIBILITY';

export const setSidebarVisibility = isOpen => ({
type: SET_SIDEBAR_VISIBILITY,
payload: isOpen,
});

export const REFRESH_VIEW = 'AOR/REFRESH_VIEW';
export const REFRESH_VIEW = 'RA/REFRESH_VIEW';

export const refreshView = () => ({
type: REFRESH_VIEW,
Expand Down
Loading