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

Fixes in docs #5075

Merged
merged 4 commits into from
Jul 23, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions docs/Admin.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ For more details on custom layouts, check [the Theming documentation](./Theming.

The `<Admin>` app uses [Redux](http://redux.js.org/) to manage state. The state has the following keys:

```jsx
```js
{
admin: { /*...*/ }, // used by react-admin
routing: { /*...*/ }, // used by connected-react-router
Expand Down Expand Up @@ -357,7 +357,7 @@ export default App;

Now the state will look like:

```jsx
```js
{
admin: { /*...*/ }, // used by react-admin
routing: { /*...*/ }, // used by connected-react-router
Expand Down
4 changes: 2 additions & 2 deletions docs/Caching.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ For instance, if the end-user displays a list of posts, then clicks on a post in

The application cache uses the semantics of the `dataProvider` verb. That means that requests for a list (`getList`) also populate the cache for individual records (`getOne`, `getMany`). That also means that write requests (`create`, `udpate`, `updateMany`, `delete`, `deleteMany`) invalidate the list cache - because after an update, for instance, the ordering of items can be changed.

So the application cache uses expiration caching together with a deeper knowledge of the data model, to allow longer expirations without the risk of displaying stale data. It especially fits admins for API backends with a small number of users (because with a large number of users, there is a high chance that a record kept in the client-side cache for a few minutes may be updated on the backend by another user). It also works with GraphQL APIs.
So the application cache uses expiration caching together with a deeper knowledge of the data model, to allow longer expirations without the risk of displaying stale data. It especially fits admins for API backends with a small number of users (because with a large number of users, there is a high chance a record kept in the client-side cache for a few minutes may be updated on the backend by another user). It also works with GraphQL APIs.
WiXSL marked this conversation as resolved.
Show resolved Hide resolved

To enable it, the `dataProvider` response must include a `validUntil` key, containing the date until which the record(s) is (are) valid.

Expand Down Expand Up @@ -121,7 +121,7 @@ It's your responsibility to determine the validity date based on the API respons

For instance, to have a `dataProvider` declare responses for `getOne`, `getMany`, and `getList` valid for 5 minutes, you can wrap it in the following proxy:

```jsx
```ts
// in src/dataProvider.js
import simpleRestProvider from 'ra-data-simple-rest';

Expand Down
21 changes: 12 additions & 9 deletions docs/CreateEdit.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,9 @@ const Aside = () => (

const PostEdit = props => (
<Edit aside={<Aside />} {...props}>
...
// ...
</Edit>
);
```
{% endraw %}

Expand Down Expand Up @@ -231,8 +232,9 @@ You can disable this behavior by setting `undoable={false}`. With that setting,
```jsx
const PostEdit = props => (
<Edit undoable={false} {...props}>
...
// ...
</Edit>
);
```

**Tip**: If you want a confirmation dialog for the Delete button but don't mind undoable Edits, then pass a [custom toolbar](#toolbar) to the form, as follows:
Expand Down Expand Up @@ -407,8 +409,9 @@ Once the `dataProvider` returns successfully after save, users see a generic not
```jsx
const PostEdit = props => (
<Edit successMessage="messages.post_saved" {...props}>
...
// ...
</Edit>
);
```

**Tip**: The message will be translated.
Expand Down Expand Up @@ -712,7 +715,7 @@ Here are all the props accepted by the `<TabbedForm>` component:
* [`validate`](#validation)
* [`submitOnEnter`](#submit-on-enter)
* [`redirect`](#redirection-after-submission)
* [`tabs`](#tabbed-form-tabs)
* [`tabs`](#tabbedformtabs)
* [`toolbar`](#toolbar)
* [`variant`](#variant)
* [`margin`](#margin)
Expand Down Expand Up @@ -1116,10 +1119,10 @@ You can also pass a custom route (e.g. "/home") or a function as `redirect` prop
// redirect to the related Author show page
const redirect = (basePath, id, data) => `/author/${data.author_id}/show`;

export const PostEdit = (props) => {
export const PostEdit = (props) => (
<Edit {...props}>
<SimpleForm redirect={redirect}>
...
// ...
</SimpleForm>
</Edit>
);
Expand Down Expand Up @@ -1173,7 +1176,7 @@ export const PostCreate = (props) => (
);
```

Another use case is to remove the `<DeleteButton>` from the toolbar in an edit view. In that case, create a custom toolbar containing only the `<SaveButton>` as a child;
Another use case is to remove the `<DeleteButton>` from the toolbar in an edit view. In that case, create a custom toolbar containing only the `<SaveButton>` as a child:

```jsx
import * as React from "react";
Expand All @@ -1188,7 +1191,7 @@ const PostEditToolbar = props => (
export const PostEdit = (props) => (
<Edit {...props}>
<SimpleForm toolbar={<PostEditToolbar />}>
...
// ...
</SimpleForm>
</Edit>
);
Expand Down Expand Up @@ -1248,7 +1251,7 @@ You can customize each row in a `<SimpleForm>` or in a `<TabbedForm>` by passing

You can find more about these props in [the Input documentation](./Inputs.md#common-input-props).

You can also [wrap inputs inside containers](#custom-row-container), or [create a custom Form component](#custom-form-component), alternative to `<SimpleForm>` or `<TabbedForm>`.
You can also [wrap inputs inside containers](#custom-row-container), or [create a custom Form component](#custom-form-component), alternative to `<SimpleForm>` or `<TabbedForm>`.

### Variant

Expand Down
7 changes: 4 additions & 3 deletions docs/DataProviders.md
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,10 @@ export default {
}
return resolve({ status, headers, body, json });
});
}),
...
}
});
},
// ...
};
```

## Example Implementation
Expand Down
8 changes: 4 additions & 4 deletions docs/List.md
Original file line number Diff line number Diff line change
Expand Up @@ -1776,7 +1776,7 @@ It's especially useful for `<ReferenceManyField>` or `<ReferenceArrayField>` com

## Using a Custom Iterator

A `<List>` can delegate to any iterator component - `<Datagrid>` is just one example. An iterator component can get the data to display from [the `useListContext` hook](#useListContext). The data comes in two constants:
A `<List>` can delegate to any iterator component - `<Datagrid>` is just one example. An iterator component can get the data to display from [the `useListContext` hook](#uselistcontext). The data comes in two constants:

- `ids` is an array of the ids currently displayed in the list
- `data` is an object of all the fetched data for this resource, indexed by id.
Expand Down Expand Up @@ -1883,17 +1883,17 @@ export const UserList = ({ permissions, ...props }) => {
<ShowButton />
</Datagrid>
)}
</List>;
</List>
)
}
};
```
{% endraw %}

**Tip**: Note how the `permissions` prop is passed down to the custom `filters` component.

## Pagination

The `<Pagination>` gest the following constants from [the `useListContext` hook](#useListContext):
The `<Pagination>` gest the following constants from [the `useListContext` hook](#uselistcontext):

* `page`: The current page number (integer). First page is `1`.
* `perPage`: The number of records per page.
Expand Down
4 changes: 2 additions & 2 deletions docs/Theming.md
Original file line number Diff line number Diff line change
Expand Up @@ -878,11 +878,11 @@ const App = () => (

### Changing the Icon

It is possible to use a completely [custom logout button](./Authentication.md#the-datagrid-component) or you can simply override some properties of the default button. If you want to change the icon, you can use the default `<Logout>` component and pass a different icon as the `icon` prop.
It is possible to use a completely [custom logout button](./Admin.md#logoutbutton) or you can simply override some properties of the default button. If you want to change the icon, you can use the default `<Logout>` component and pass a different icon as the `icon` prop.

```jsx
import { Admin, Logout } from 'react-admin';
import ExitToAppIcon from '@material-ui/icons/ExitToApp'
import ExitToAppIcon from '@material-ui/icons/ExitToApp';

const MyLogoutButton = props => <Logout {...props} icon={<ExitToAppIcon/>} />;

Expand Down
2 changes: 1 addition & 1 deletion docs/Translation.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ You will use translation features mostly via the `i18nProvider`, and a set of ho

**Tip**: We'll use a bit of custom vocabulary in this chapter:

- "i18n" is a shorter way to write "internationalization" (an "i" followed by 18 letters followed by n)
- "i18n" is a shorter way to write "internationalization" (an "i" followed by 18 letters followed by "n")
- "locale" is a concept similar to languages, but it also includes the concept of country. For instance, there are several English locales (like `en_us` and `en_gb`) because US and UK citizens don't use exactly the same language. For react-admin, the "locale" is just a key for your i18nProvider, so it can have any value you want.

## Introducing the `i18nProvider`
Expand Down