Skip to content

Commit 1b98ce6

Browse files
committed
Merge branch 'master' into next
2 parents 7cf9c0d + 75f9601 commit 1b98ce6

File tree

107 files changed

+6655
-327
lines changed

Some content is hidden

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

107 files changed

+6655
-327
lines changed

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
# Changelog
22

3+
## 5.12.2
4+
5+
* Fix middlewares might not be applied in `optimistic` and `undoable` modes when they are unregistered before the actual mutation is called ([#11007](https://github.com/marmelab/react-admin/pull/11007)) ([djhi](https://github.com/djhi))
6+
* Fix `<AutocompleteArrayInput>` does not apply `ChipProps` nor `slotProps.chip` in `renderTags` ([#11003](https://github.com/marmelab/react-admin/pull/11003)) ([djhi](https://github.com/djhi))
7+
* Fix `<SaveButton>` form dirty status check ([#10997](https://github.com/marmelab/react-admin/pull/10997)) ([djhi](https://github.com/djhi))
8+
* [Doc] Add missing Enterprise ribbon to some `ra-core-ee` modules ([#11001](https://github.com/marmelab/react-admin/pull/11001)) ([jonathanarnault](https://github.com/jonathanarnault))
9+
* [Doc] Mention Soft Delete in Buttons documentation ([#11000](https://github.com/marmelab/react-admin/pull/11000)) ([djhi](https://github.com/djhi))
10+
* [Doc] Add `<FormDataConsumer>` and `useSourceContext` headless documentation ([#10991](https://github.com/marmelab/react-admin/pull/10991)) ([jonathanarnault](https://github.com/jonathanarnault))
11+
* [Doc] Improve AuthProvider documentation ([#10989](https://github.com/marmelab/react-admin/pull/10989)) ([slax57](https://github.com/slax57))
12+
* [chore] Bump vite from 6.3.6 to 6.4.1 ([#10999](https://github.com/marmelab/react-admin/pull/10999)) ([dependabot[bot]](https://github.com/apps/dependabot))
13+
14+
## 5.12.1
15+
16+
* Fix `<ColumnsSelector>` reset button is not translatable ([#10984](https://github.com/marmelab/react-admin/pull/10984)) ([yarkovaleksei](https://github.com/yarkovaleksei))
17+
* [Doc] Update `useRedirect` JSDoc to add absolute URL example ([#10987](https://github.com/marmelab/react-admin/pull/10987)) ([COil](https://github.com/COil))
18+
* [Doc] Update Soft Delete documentation ([#10986](https://github.com/marmelab/react-admin/pull/10986)) ([djhi](https://github.com/djhi))
19+
* [Doc] Mention Scheduler in All Features ([#10985](https://github.com/marmelab/react-admin/pull/10985)) ([slax57](https://github.com/slax57))
20+
* [Doc] Fix Soft Delete documentation links ([#10980](https://github.com/marmelab/react-admin/pull/10980)) ([djhi](https://github.com/djhi))
21+
* [Doc] Add documentation about ra-relationship core components ([#10979](https://github.com/marmelab/react-admin/pull/10979)) ([jonathanarnault](https://github.com/jonathanarnault))
22+
* [Doc] Add documentation for headless enterprise features in ra-core documentation ([#10973](https://github.com/marmelab/react-admin/pull/10973)) ([djhi](https://github.com/djhi))
23+
* [Doc] Add `<ReferenceInputBase>` and `<ReferenceArrayInputBase>` documentation in headless doc site ([#10965](https://github.com/marmelab/react-admin/pull/10965)) ([djhi](https://github.com/djhi))
24+
* [TypeScript] Fix `useShowController` result type ([#10992](https://github.com/marmelab/react-admin/pull/10992)) ([slax57](https://github.com/slax57))
25+
* Bump astro from 5.13.7 to 5.14.3 ([#10988](https://github.com/marmelab/react-admin/pull/10988)) ([dependabot[bot]](https://github.com/apps/dependabot))
26+
327
## 5.12.0
428

529
* Add `error`, `loading`, `empty` and `offline` props to `<ListBase>`, `<WithListContext>`, `<EditBase>`, and `<ShowBase>` to set fallback components for non-success states. ([#10880](https://github.com/marmelab/react-admin/pull/10880)) ([erwanMarmelab](https://github.com/erwanMarmelab))

docs/AuthProviderWriting.md

Lines changed: 111 additions & 65 deletions
Large diffs are not rendered by default.

docs/Authentication.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,27 @@ export const authProvider = {
428428
};
429429
```
430430
431-
You can choose when to redirect users to the third-party authentication service, such as directly in the `AuthProvider.checkAuth()` method or when they click a button on a [custom login page](#customizing-the-login-component).
431+
![Auth0 login flow diagram](./img/authProvider-OAuth-flow.png)
432+
{% comment %}
433+
Diagram source:
434+
```mermaid
435+
sequenceDiagram
436+
autonumber
437+
participant U as User
438+
participant RA as React Admin<br/>(authProvider)
439+
participant A as Auth0 website
440+
U->>RA: Access /posts
441+
Note over RA: checkAuth()<br/>Auth0Client.isAuthenticated()
442+
RA->>A: Auth0Client.loginWithRedirect()
443+
Note over A: Login using Auth0 form
444+
A->>RA: Redirects to /auth-callback<br/>(with token)
445+
Note over RA: handleCallback()<br/>Auth0Client.handleRedirectCallback()
446+
RA->>U: Redirects to /posts
447+
```
448+
Edited with https://mermaid.live/edit
449+
{% endcomment %}
450+
451+
**Tip:** You can choose when to redirect users to the third-party authentication service, such as directly in the `AuthProvider.checkAuth()` method or when they click a button on a [custom login page](#customizing-the-login-component).
432452
433453
## Handling Refresh Tokens
434454

docs/Breadcrumb.md

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,149 @@ const MyBreadcrumbCustomHome = () => (
567567

568568
**Tip:** It's a good practice to include a visually hidden placeholder ('Dashboard' in this example) for screen readers when using an icon as label.
569569

570+
## `<Breadcrumb.ListItem>`
571+
572+
A version of the `<Breadcrumb.Item>` dedicated to list views. It accepts all [`<Breadcrumb.Item>` props](#breadcrumbitem).
573+
574+
It is convenient for building custom breadcrumbs.
575+
576+
```tsx
577+
const MyBreadcrumb = () => (
578+
<Breadcrumb>
579+
<Breadcrumb.ListItem resource="posts">
580+
<Breadcrumb.EditItem resource="posts" />
581+
<Breadcrumb.ShowItem resource="posts" />
582+
<Breadcrumb.CreateItem resource="posts" />
583+
</Breadcrumb.ListItem>
584+
</Breadcrumb>
585+
);
586+
```
587+
588+
## `<Breadcrumb.CreateItem>`
589+
590+
A version of the `<Breadcrumb.Item>` dedicated to create views. It accepts all [`<Breadcrumb.Item>` props](#breadcrumbitem).
591+
592+
It is convenient for building custom breadcrumbs.
593+
594+
```tsx
595+
const MyBreadcrumb = () => (
596+
<Breadcrumb>
597+
<Breadcrumb.ListItem resource="posts">
598+
<Breadcrumb.EditItem resource="posts" />
599+
<Breadcrumb.ShowItem resource="posts" />
600+
<Breadcrumb.CreateItem resource="posts" />
601+
</Breadcrumb.ListItem>
602+
</Breadcrumb>
603+
);
604+
```
605+
606+
## `<Breadcrumb.EditItem>`
607+
608+
A version of the `<Breadcrumb.Item>` dedicated to edit views. It is convenient for building custom breadcrumbs.
609+
610+
It accepts all [`<Breadcrumb.Item>` props](#breadcrumbitem) and an optional `meta` prop that allows you to provide a [`meta`](https://marmelab.com/react-admin/Actions.html#meta-parameter) parameter matching the one set in the `<Edit>` component:
611+
612+
```tsx
613+
const MyBreadcrumb = () => (
614+
<Breadcrumb>
615+
<Breadcrumb.ListItem resource="posts">
616+
<Breadcrumb.EditItem resource="posts" meta={ { test: true } } />
617+
<Breadcrumb.ShowItem resource="posts" />
618+
<Breadcrumb.CreateItem resource="posts" />
619+
</Breadcrumb.ListItem>
620+
</Breadcrumb>
621+
);
622+
623+
const PostEdit = () => (
624+
<Edit queryOptions={ { meta: { test: true } } }>
625+
// ...
626+
</Edit>
627+
);
628+
```
629+
630+
**Tip**: If your `<Edit>` component has a `meta` parameter but manually calls [`useDefineAppLocation`](./useDefineAppLocation.md) and provides it with the record, you don't need to set the `meta` prop on the `<Breadcrumb.EditItem>` as it will read the record from the `AppLocationContext`:
631+
632+
```tsx
633+
const MyBreadcrumb = () => (
634+
<Breadcrumb>
635+
<Breadcrumb.ListItem resource="posts">
636+
{/* meta are not provided here */}
637+
<Breadcrumb.EditItem resource="posts" />
638+
<Breadcrumb.ShowItem resource="posts" />
639+
<Breadcrumb.CreateItem resource="posts" />
640+
</Breadcrumb.ListItem>
641+
</Breadcrumb>
642+
);
643+
644+
const PostEdit = () => (
645+
{/* meta are provided here */}
646+
<Edit queryOptions={ { meta: { test: true } } }>
647+
// ...
648+
</Edit>
649+
);
650+
651+
const PostAppLocation = () => {
652+
const record = useRecordContext();
653+
// Pass the current record in the app location
654+
useDefineAppLocation('posts.edit', { record });
655+
return null;
656+
}
657+
```
658+
659+
## `<Breadcrumb.ShowItem>`
660+
661+
A version of the `<Breadcrumb.Item>` dedicated to show views. It is convenient for building custom breadcrumbs.
662+
663+
It accepts all [`<Breadcrumb.Item>` props](#breadcrumbitem) and an optional `meta` prop that allows you to provide a [`meta`](https://marmelab.com/react-admin/Actions.html#meta-parameter) parameter matching the one set in the `<Show>` component:
664+
665+
```tsx
666+
const MyBreadcrumb = () => (
667+
<Breadcrumb>
668+
<Breadcrumb.ListItem resource="posts">
669+
<Breadcrumb.EditItem resource="posts" />
670+
<Breadcrumb.ShowItem resource="posts" meta={ { test: true } } />
671+
<Breadcrumb.CreateItem resource="posts" />
672+
</Breadcrumb.ListItem>
673+
</Breadcrumb>
674+
);
675+
676+
677+
const PostShow = () => (
678+
<Show queryOptions={ { meta: { test: true } } }>
679+
// ...
680+
</Show>
681+
);
682+
```
683+
684+
**Tip**: If your `<Show>` component has a `meta` parameter but manually calls [`useDefineAppLocation`](./useDefineAppLocation.md) and provides it with the record, you don't need to set the `meta` prop on the `<Breadcrumb.ShowItem>` as it will read the record from the `AppLocationContext`:
685+
686+
```tsx
687+
const MyBreadcrumb = () => (
688+
<Breadcrumb>
689+
<Breadcrumb.ListItem resource="posts">
690+
<Breadcrumb.EditItem resource="posts" />
691+
{/* meta are not provided here */}
692+
<Breadcrumb.ShowItem resource="posts" />
693+
<Breadcrumb.CreateItem resource="posts" />
694+
</Breadcrumb.ListItem>
695+
</Breadcrumb>
696+
);
697+
698+
const PostShow = () => (
699+
{/* meta are provided here */}
700+
<Show queryOptions={ { meta: { test: true } } }>
701+
// ...
702+
</Show>
703+
);
704+
705+
const PostAppLocation = () => {
706+
const record = useRecordContext();
707+
// Pass the current record in the app location
708+
useDefineAppLocation('posts.show', { record });
709+
return null;
710+
}
711+
```
712+
570713
## Admins With A Dashboard
571714

572715
If the app has a home page defined via the [`<Admin dashboard>`](./Admin.md#dashboard) prop, the Breadcrumb will automatically detect it and set the root of the Breadcrumb to this page.

docs/Buttons.md

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,20 @@ Alternately, pass a `successMessage` prop:
112112
<BulkDeleteButton successMessage="Posts deleted successfully" />
113113
```
114114

115+
### Access Control
116+
117+
If your `authProvider` implements [Access Control](./Permissions.md#access-control), `<BulkDeleteButton>` will only render if the user has the "delete" access to the related resource.
118+
119+
`<BulkDeleteButton>` will call `authProvider.canAccess()` using the following parameters:
120+
121+
```txt
122+
{ action: "delete", resource: [current resource] }
123+
```
124+
125+
### Soft Delete
126+
127+
Should you need to only archive records, the soft delete feature from the [Enterprise Edition add-on](https://react-admin-ee.marmelab.com/documentation/ra-soft-delete) provides the [`<BulkSoftDeleteButton />`](./BulkSoftDeleteButton.md), a drop-in replacement for `<BulkDeleteButton>`.
128+
115129
## `<BulkExportButton>`
116130

117131
Same as `<ExportButton>`, except it only exports the selected rows instead of the entire list. To be used inside [the `<DataTable bulkActionButtons>` prop](./DataTable.md#bulkactionbuttons).
@@ -1022,6 +1036,10 @@ If your `authProvider` implements [Access Control](./Permissions.md#access-contr
10221036
{ action: "delete", resource: [current resource], record: [current record] }
10231037
```
10241038

1039+
### Soft Delete
1040+
1041+
Should you need to only archive records, the soft delete feature from the [Enterprise Edition add-on](https://react-admin-ee.marmelab.com/documentation/ra-soft-delete) provides the [`<SoftDeleteButton />`](./SoftDeleteButton.md), a drop-in replacement for `<DeleteButton>`.
1042+
10251043
## `<DeleteWithConfirmButton>`
10261044

10271045
Delete the current record after a confirm dialog has been accepted. To be used inside a `<Toolbar/>` component.
@@ -1063,15 +1081,15 @@ const MyEdit = () => (
10631081
<Edit>
10641082
<SimpleForm toolbar={<EditToolbar />}>
10651083
...
1066-
</SimpleForm>
1067-
</Edit>
1084+
</SimpleForm>
1085+
</Edit>
10681086
);
10691087
```
10701088
{% endraw %}
10711089

10721090
## `<EditButton>`
10731091

1074-
Opens the Edit view of the current record.
1092+
Opens the Edit view of the current record.
10751093

10761094
![Edit button](./img/edit-button.png)
10771095

@@ -1397,7 +1415,7 @@ By default, react-admin's `<DataTable>` displays a `<SelectAllButton>` in its `b
13971415
import { List, DataTable, BulkActionsToolbar, SelectAllButton, BulkDeleteButton } from 'react-admin';
13981416

13991417
const PostSelectAllButton = () => (
1400-
<SelectAllButton
1418+
<SelectAllButton
14011419
label="Select all records"
14021420
queryOptions={{ meta: { foo: 'bar' } }}
14031421
/>
@@ -1636,11 +1654,11 @@ const PostEditActions = () => (
16361654

16371655
The mutation mode determines when the side effects (redirection, notifications, etc.) are executed:
16381656

1639-
- `pessimistic`: The mutation is passed to the dataProvider first. When the dataProvider returns successfully, the mutation is applied locally, and the side effects are executed.
1640-
- `optimistic`: The mutation is applied locally and the side effects are executed immediately. Then the mutation is passed to the dataProvider. If the dataProvider returns successfully, nothing happens (as the mutation was already applied locally). If the dataProvider returns in error, the page is refreshed and an error notification is shown.
1657+
- `pessimistic`: The mutation is passed to the dataProvider first. When the dataProvider returns successfully, the mutation is applied locally, and the side effects are executed.
1658+
- `optimistic`: The mutation is applied locally and the side effects are executed immediately. Then the mutation is passed to the dataProvider. If the dataProvider returns successfully, nothing happens (as the mutation was already applied locally). If the dataProvider returns in error, the page is refreshed and an error notification is shown.
16411659
- `undoable` (default): The mutation is applied locally and the side effects are executed immediately. Then a notification is shown with an undo button. If the user clicks on undo, the mutation is never sent to the dataProvider, and the page is refreshed. Otherwise, after a 5 seconds delay, the mutation is passed to the dataProvider. If the dataProvider returns successfully, nothing happens (as the mutation was already applied locally). If the dataProvider returns in error, the page is refreshed and an error notification is shown.
16421660

1643-
By default, the `<UpdateButton>` uses the `undoable` mutation mode. This is part of the "optimistic rendering" strategy of react-admin ; it makes user interactions more reactive.
1661+
By default, the `<UpdateButton>` uses the `undoable` mutation mode. This is part of the "optimistic rendering" strategy of react-admin ; it makes user interactions more reactive.
16441662

16451663
You can change this default by setting the `mutationMode` prop. For instance, to remove the ability to undo the changes, use the `optimistic` mode:
16461664

@@ -1671,7 +1689,7 @@ const PostEditActions = () => (
16711689
{% endraw %}
16721690

16731691

1674-
**Tip**: When using any other mode than `undoable`, the `<UpdateButton>` displays a confirmation dialog before calling the dataProvider.
1692+
**Tip**: When using any other mode than `undoable`, the `<UpdateButton>` displays a confirmation dialog before calling the dataProvider.
16751693

16761694
### `confirmTitle`
16771695

@@ -1777,7 +1795,7 @@ The default `onSuccess` function is:
17771795
}
17781796
```
17791797

1780-
**Tip**: When you use `mutationMode="pessimistic"`, the `onSuccess` function receives the response from the `dataProvider.update()` call, which is the edited record (see [the dataProvider documentation for details](./DataProviderWriting.md#update)). You can use that response in the success side effects:
1798+
**Tip**: When you use `mutationMode="pessimistic"`, the `onSuccess` function receives the response from the `dataProvider.update()` call, which is the edited record (see [the dataProvider documentation for details](./DataProviderWriting.md#update)). You can use that response in the success side effects:
17811799

17821800
{% raw %}
17831801
```jsx

0 commit comments

Comments
 (0)