Skip to content

Commit 9d18109

Browse files
committed
Merge branch 'next' into useMutationWithMutationMode
1 parent 53a26b1 commit 9d18109

File tree

171 files changed

+5225
-1383
lines changed

Some content is hidden

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

171 files changed

+5225
-1383
lines changed

CHANGELOG.md

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

3+
## 5.10.2
4+
5+
* Add warning when using `queryOptions` to add a `meta` in `<Edit>` and `<EditBase>` ([#10882](https://github.com/marmelab/react-admin/pull/10882)) ([Madeorsk](https://github.com/Madeorsk))
6+
* Fix error when authProvider check methods are not async ([#10890](https://github.com/marmelab/react-admin/pull/10890)) ([fzaninotto](https://github.com/fzaninotto))
7+
* Fix `ChipField` consider zero to be empty ([#10877](https://github.com/marmelab/react-admin/pull/10877)) ([djhi](https://github.com/djhi))
8+
* [Doc] Add Apisix OIDC auth provider ([#10888](https://github.com/marmelab/react-admin/pull/10888)) ([fzaninotto](https://github.com/fzaninotto))
9+
* [Doc] Add details about Datagrid to DataTable migration ([#10884](https://github.com/marmelab/react-admin/pull/10884)) ([Madeorsk](https://github.com/Madeorsk))
10+
11+
## 5.10.1
12+
13+
* Fix `<ColumnsButton>` cannot be used with keyboard ([#10869](https://github.com/marmelab/react-admin/pull/10869)) ([djhi](https://github.com/djhi))
14+
* Fix unused imports ([#10866](https://github.com/marmelab/react-admin/pull/10866)) ([Madeorsk](https://github.com/Madeorsk))
15+
* Fix `<ReferenceArrayInput>` does not accept `alwaysOn` prop ([#10863](https://github.com/marmelab/react-admin/pull/10863)) ([djhi](https://github.com/djhi))
16+
* Fix `DateInput` JSDoc formatting and example ([#10855](https://github.com/marmelab/react-admin/pull/10855)) ([ogroppo](https://github.com/ogroppo))
17+
* Fix B&W theme label is invisible for inputs with `standard` variant ([#10854](https://github.com/marmelab/react-admin/pull/10854)) ([djhi](https://github.com/djhi))
18+
* Fix Show and Edit controllers can trigger a redirect loop with react-router v7 if getOne rejects ([#10850](https://github.com/marmelab/react-admin/pull/10850)) ([slax57](https://github.com/slax57))
19+
* [Demo] Migrate from `fetch-mock` to `msw` ([#10844](https://github.com/marmelab/react-admin/pull/10844)) ([erwanMarmelab](https://github.com/erwanMarmelab))
20+
* Bump linkifyjs from 4.1.1 to 4.3.2 ([#10868](https://github.com/marmelab/react-admin/pull/10868)) ([dependabot[bot]](https://github.com/apps/dependabot))
21+
322
## 5.10.0
423

524
* Add filter input to `<ColumnsButton>` when there are many columns ([#10848](https://github.com/marmelab/react-admin/pull/10848)) ([slax57](https://github.com/slax57))

context7.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"$schema": "https://context7.com/schema/context7.json",
3+
"projectTitle": "React-admin",
4+
"description": "A frontend Framework for building single-page applications running in the browser on top of REST/GraphQL APIs, using TypeScript, React, react-router, react-hook-form, react-query, and Material Design.",
5+
"folders": ["docs"],
6+
"excludeFolders": ["src"],
7+
"excludeFiles": ["*.html","*.js","*.css"],
8+
"previousVersions": [
9+
{
10+
"tag": "v4.16.0",
11+
"title": "version 4.16"
12+
},
13+
{
14+
"tag": "v3.19.0",
15+
"title": "version 3.19"
16+
},
17+
{
18+
"tag": "v2.9.0",
19+
"title": "version 2.9"
20+
}
21+
]
22+
}

docs/AuthProviderList.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ title: "Supported Auth Provider Backends"
88
It's very common that your auth logic is so specific that you'll need to write your own `authProvider`. However, the community has built a few open-source Auth Providers that may fit your need:
99

1010
<div class="providers-list" markdown="1">
11+
- ![Apisix logo](./img/backend-logos/apisix.svg "Apisix logo")**[Apache Apisix OIDC](https://apisix.apache.org/)**: [@arte/ra-apisix-oidc](https://www.npmjs.com/package/@arte/ra-apisix-oidc)
1112
- ![Appwrite Logo](./img/backend-logos/appwrite.svg "Appwrite Logo")**[Appwrite](https://appwrite.io/)**: [marmelab/ra-appwrite](https://github.com/marmelab/ra-appwrite)
1213
- ![auth0 Logo](./img/backend-logos/auth0.svg "auth0 Logo")**[Auth0 by Okta](https://auth0.com/)**: [marmelab/ra-auth-auth0](https://github.com/marmelab/ra-auth-auth0/blob/main/packages/ra-auth-auth0/Readme.md)
1314
- ![amplify Logo](./img/backend-logos/amplify.svg "amplify Logo")**[AWS Amplify](https://docs.amplify.aws)**: [MrHertal/react-admin-amplify](https://github.com/MrHertal/react-admin-amplify)

docs/DataTable.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,3 +1871,23 @@ npx jscodeshift ./path/to/src/ \
18711871
--parser=tsx \
18721872
--transform=./node_modules/ra-core/codemods/replace-Datagrid-DataTable.ts
18731873
```
1874+
1875+
Here is what the codemod will transform for you:
1876+
1877+
- Replace `<Datagrid>` with `<DataTable>`.
1878+
- Replace `rowStyle` with `rowSx`.
1879+
- Remove the `optimized` prop (which isn't necessary anymore)
1880+
- Rename the keys in `sx` prop from `"& .RaDatagrid-xxxx"` to `"& .RaDataTable-xxxx"`.
1881+
- Replace simple `<TextField>` with `<DataTable.Col>`.
1882+
- Replace simple `<NumberField>` with `<DataTable.NumberCol>`.
1883+
- Wrap all other fields in `<DataTable.Col>`, keeping `source` and `label` properties in `<DataTable.Col>`.
1884+
- Replace `Datagrid` imports by `DataTable`, and remove unused `TextField` and `NumberField` imports if they are now all replaced.
1885+
1886+
However, the codemod will **not**:
1887+
1888+
- Replace `<DatagridConfigurable>` with `<DataTable>` (column selection is now natively supported by `<DataTable>`).
1889+
- Remove the `sortBy` and `sortable` props on fields (sorting is now managed by `<DataTable.Col source>`)
1890+
- Move the `sortByOrder` prop from the field to `<DataTable.Col>`
1891+
- Replace a `<FunctionField>` child with `<DataTable.Col render>`
1892+
- Replace `<Datagrid>` from `@react-admin/ra-rbac` (and all its children). Refer to [Access Control section](#access-control) to use `<DataTable>` with `<CanAccess>`.
1893+
- Move the column styles from `<Datagrid sx>` to the individual `<DataTable.Col sx>`

docs/Edit.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,8 @@ const PostEdit = () => (
414414

415415
{% endraw %}
416416

417+
**Warning**: If you set `mutationOptions` meta without [redirecting](#redirect), make sure that [`queryOptions`](#queryoptions) meta is the same, or you will have data update issues.
418+
417419
You can also use `mutationOptions` to override success or error side effects, by setting the `mutationOptions` prop. Refer to the [useMutation documentation](https://tanstack.com/query/v5/docs/react/reference/useMutation) in the react-query website for a list of the possible options.
418420

419421
Let's see an example with the success side effect. By default, when the save action succeeds, react-admin shows a notification, and redirects to the list page. You can override this behavior and pass custom success side effects by providing a `mutationOptions` prop with an `onSuccess` key:
@@ -542,7 +544,7 @@ The default `onError` function is:
542544

543545
## `offline`
544546

545-
By default, `<EditBase>` renders nothing when there is no connectivity and the record hasn't been cached yet. You can provide your own component via the `offline` prop:
547+
By default, `<Edit>` renders the `<Offline>` component when there is no connectivity and the record hasn't been cached yet. You can provide your own component via the `offline` prop:
546548

547549
```jsx
548550
import { Edit } from 'react-admin';
@@ -594,6 +596,8 @@ export const PostEdit = () => (
594596

595597
{% endraw %}
596598

599+
**Warning**: If you set `queryOptions` meta without [redirecting](#redirect), make sure that [`mutationOptions`](#mutationoptions) meta is the same, or you will have data update issues.
600+
597601
You can also use `queryOptions` to force a refetch on reconnect:
598602

599603
{% raw %}
@@ -629,7 +633,9 @@ const PostEdit = () => (
629633
);
630634
```
631635

632-
Note that the `redirect` prop is ignored if you set [the `mutationOptions` prop](#mutationoptions). See that prop for how to set a different redirection path in that case.
636+
Note that the `redirect` prop is ignored if you set an `onSuccess` callback of [the `mutationOptions` prop](#mutationoptions). See that prop for how to set a different redirection path in that case.
637+
638+
**Warning**: If you set [`queryOptions`](#queryoptions) meta without redirecting, make sure that [`mutationOptions`](#mutationoptions) meta is the same, or you will have data update issues.
633639

634640
## `render`
635641

docs/InfiniteList.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ The props are the same as [the `<List>` component](./List.md):
7272
| `filters` | Optional | `ReactElement` | - | The filters to display in the toolbar. |
7373
| `filter` | Optional | `object` | - | The permanent filter values. |
7474
| `filter DefaultValues` | Optional | `object` | - | The default filter values. |
75+
| `offline` | Optional | `ReactNode` | `<Offline>` | The component to render when there is no connectivity and there is no data in the cache |
7576
| `pagination` | Optional | `ReactElement` | `<Infinite Pagination>` | The pagination component to use. |
7677
| `perPage` | Optional | `number` | `10` | The number of records to fetch per page. |
7778
| `queryOptions` | Optional | `object` | - | The options to pass to the `useQuery` hook. |
@@ -85,6 +86,49 @@ Check the [`<List>` component](./List.md) for details about each prop.
8586

8687
Additional props are passed down to the root component (a MUI `<Card>` by default).
8788

89+
## `offline`
90+
91+
By default, `<InfiniteList>` renders the `<Offline>` component when there is no connectivity and there are no records in the cache yet for the current parameters (page, sort, etc.). You can provide your own component via the `offline` prop:
92+
93+
```jsx
94+
import { InfiniteList, InfinitePagination } from 'react-admin';
95+
import { Alert } from '@mui/material';
96+
97+
const offline = <Alert severity="warning">No network. Could not load the posts.</Alert>;
98+
// The offline component may be displayed at the bottom of the page if the network connectivity is lost
99+
// when loading new pages. Make sure you pass your custom offline component here too
100+
const pagination = <InfinitePagination offline={offline} />;
101+
102+
export const PostList = () => (
103+
<InfiniteList offline={offline} pagination={pagination}>
104+
...
105+
</InfiniteList>
106+
);
107+
```
108+
109+
**Tip**: If the record is in the Tanstack Query cache but you want to warn the user that they may see an outdated version, you can use the `<IsOffline>` component:
110+
111+
```jsx
112+
import { InfiniteList, InfinitePagination, IsOffline } from 'react-admin';
113+
import { Alert } from '@mui/material';
114+
115+
const offline = <Alert severity="warning">No network. Could not load the posts.</Alert>;
116+
// The offline component may be displayed at the bottom of the page if the network connectivity is lost
117+
// when loading new pages. Make sure you pass your custom offline component here too
118+
const pagination = <InfinitePagination offline={offline} />;
119+
120+
export const PostList = () => (
121+
<InfiniteList offline={offline} pagination={pagination}>
122+
<IsOffline>
123+
<Alert severity="warning">
124+
You are offline, the data may be outdated
125+
</Alert>
126+
</IsOffline>
127+
...
128+
</InfiniteList>
129+
);
130+
```
131+
88132
## `pagination`
89133

90134
You can replace the default "load on scroll" pagination (triggered by a component named `<InfinitePagination>`) by a custom pagination component. To get the pagination state and callbacks, you'll need to read the `InfinitePaginationContext`.

docs/List.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ You can find more advanced examples of `<List>` usage in the [demos](./Demos.md)
6969
| `filters` | Optional | `ReactElement` | - | The filters to display in the toolbar. |
7070
| `filter` | Optional | `object` | - | The permanent filter values. |
7171
| `filter DefaultValues` | Optional | `object` | - | The default filter values. |
72+
| `offline` | Optional | `ReactNode` | `<Offline>` | The component to render when there is no connectivity and there is no data in the cache |
7273
| `pagination` | Optional | `ReactElement` | `<Pagination>` | The pagination component to use. |
7374
| `perPage` | Optional | `number` | `10` | The number of records to fetch per page. |
7475
| `queryOptions` | Optional | `object` | - | The options to pass to the `useQuery` hook. |
@@ -774,6 +775,43 @@ export const PostList = () => (
774775
const filterSentToDataProvider = { ...filterDefaultValues, ...filterChosenByUser, ...filter };
775776
```
776777

778+
## `offline`
779+
780+
By default, `<List>` renders the `<Offline>` component when there is no connectivity and there are no records in the cache yet for the current parameters (page, sort, etc.). You can provide your own component via the `offline` prop:
781+
782+
```jsx
783+
import { List } from 'react-admin';
784+
import { Alert } from '@mui/material';
785+
786+
const offline = <Alert severity="warning">No network. Could not load the posts.</Alert>;
787+
788+
export const PostList = () => (
789+
<List offline={offline}>
790+
...
791+
</List>
792+
);
793+
```
794+
795+
**Tip**: If the record is in the Tanstack Query cache but you want to warn the user that they may see an outdated version, you can use the `<IsOffline>` component:
796+
797+
```jsx
798+
import { List, IsOffline } from 'react-admin';
799+
import { Alert } from '@mui/material';
800+
801+
const offline = <Alert severity="warning">No network. Could not load the posts.</Alert>;
802+
803+
export const PostList = () => (
804+
<List offline={offline}>
805+
<IsOffline>
806+
<Alert severity="warning">
807+
You are offline, the data may be outdated
808+
</Alert>
809+
</IsOffline>
810+
...
811+
</List>
812+
);
813+
```
814+
777815
## `pagination`
778816

779817
By default, the `<List>` view displays a set of pagination controls at the bottom of the list.

docs/ListBase.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,13 @@ The `<ListBase>` component accepts the following props:
8787
* [`exporter`](./List.md#exporter)
8888
* [`filter`](./List.md#filter-permanent-filter)
8989
* [`filterDefaultValues`](./List.md#filterdefaultvalues)
90+
* [`offline`](./List.md#offline)
9091
* [`perPage`](./List.md#perpage)
9192
* [`queryOptions`](./List.md#queryoptions)
9293
* `render`
9394
* [`resource`](./List.md#resource)
9495
* [`sort`](./List.md#sort)
96+
* [`storeKey`](./List.md#storeKey)
9597
9698
In addition, `<ListBase>` renders its children components inside a `ListContext`. Check [the `<List children>` documentation](./List.md#children) for usage examples.
9799

0 commit comments

Comments
 (0)