Skip to content

Commit c74a0a4

Browse files
committed
Fix for 5.6.0
1 parent b48ef9f commit c74a0a4

Some content is hidden

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

47 files changed

+1255
-99
lines changed

AppTheme.md

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,11 @@ const App = () => (
106106

107107
## Built-In Themes
108108

109-
React-admin comes with 4 built-in themes, each one having a light and a dark variant. You can use them as a starting point for your custom theme, or use them as-is.
109+
React-admin comes with 5 built-in themes, each one having a light and a dark variant. You can use them as a starting point for your custom theme, or use them as-is.
110110

111-
| :---: | :---: |
112-
|    [Default](#default) [![Default light theme](./img/defaultLightTheme1.jpg)]((#default)) |    [Nano](#nano) [![Nano light theme](./img/nanoLightTheme1.jpg)](#nano) |
113-
|    [Radiant](#radiant) [![Radiant light theme](./img/radiantLightTheme1.jpg)](#radiant) |    [House](#house) [![House light theme](./img/houseLightTheme1.jpg)](#house) |
111+
|    [Default](#default) [![Default light theme](./img/defaultLightTheme1.jpg)]((#default)) |    [B&W](#bw) [![B&W light theme](./img/bwLightTheme1.jpg)](#bw) |
112+
|    [Nano](#nano) [![Nano light theme](./img/nanoLightTheme1.jpg)](#nano) |    [Radiant](#radiant) [![Radiant light theme](./img/radiantLightTheme1.jpg)](#radiant) |
113+
|    [House](#house) [![House light theme](./img/houseLightTheme1.jpg)](#house) |
114114

115115
### Default
116116

@@ -123,6 +123,37 @@ The default theme is a good fit for every application, and works equally well on
123123

124124
You don't need to configure anything to use the default theme - it comes out of the box with react-admin.
125125

126+
### B&W
127+
128+
A high-contrast theme with a black and white palette, ideal for visually impaired users. Its modern-looking style, reminiscent of shadcn, is suitable for desktop apps.
129+
130+
[![B&W light theme](./img/bwLightTheme1.jpg)](./img/bwLightTheme1.jpg)
131+
[![B&W light theme](./img/bwLightTheme2.jpg)](./img/bwLightTheme2.jpg)
132+
[![B&W dark theme](./img/bwDarkTheme1.jpg)](./img/bwDarkTheme1.jpg)
133+
[![B&W dark theme](./img/bwDarkTheme2.jpg)](./img/bwDarkTheme2.jpg)
134+
135+
To use the B&W theme, import the `bwLightTheme` and `bwDarkTheme` objects, and pass them to the `<Admin>` component:
136+
137+
```jsx
138+
import { Admin, bwLightTheme, bwDarkTheme } from 'react-admin';
139+
140+
export const App = () => (
141+
<Admin
142+
dataProvider={dataProvider}
143+
theme={bwLightTheme}
144+
darkTheme={bwDarkTheme}
145+
>
146+
// ...
147+
</Admin>
148+
);
149+
```
150+
151+
You must also import the Geist font in your `index.html` file:
152+
153+
```html
154+
<link href="https://fonts.googleapis.com/css2?family=Geist:wght@100..900&display=swap" rel="stylesheet">
155+
```
156+
126157
### Nano
127158

128159
A dense theme with minimal chrome, ideal for complex apps. It uses a small font size, reduced spacing, text buttons, standard variant inputs, pale colors. Only fit for desktop apps.

ArrayInput.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Check [the `<SimpleFormIterator>` documentation](./SimpleFormIterator.md) for de
8484

8585
## Props
8686

87-
`<ArrayInput>` accepts the [common input props](./Inputs.md#common-input-props) (except `format` and `parse`).
87+
`<ArrayInput>` accepts the [common input props](./Inputs.md#common-input-props) (except `disabled`, `readOnly`, `format` and `parse`).
8888

8989
## Global validation
9090

@@ -109,3 +109,27 @@ You need to return an errors object shaped like this:
109109
```
110110

111111
**Tip:** You can find a sample `validate` function that handles arrays in the [Form Validation documentation](./Validation.md#global-validation).
112+
113+
## Disabling The Input
114+
115+
`<ArrayInput>` does not support the `disabled` and `readOnly` props.
116+
117+
If you need to disable the input, set the `<SimpleFormIterator disabled>` prop, and make the child inputs `readOnly`:
118+
119+
```jsx
120+
const OrderEdit = () => (
121+
<Edit>
122+
<SimpleForm>
123+
<TextInput source="customer" />
124+
<DateInput source="date" />
125+
<ArrayInput source="items">
126+
<SimpleFormIterator inline disabled>
127+
<TextInput source="name" readOnly/>
128+
<NumberInput source="price" readOnly />
129+
<NumberInput source="quantity" readOnly />
130+
</SimpleFormIterator>
131+
</ArrayInput>
132+
</SimpleForm>
133+
</Edit>
134+
);
135+
```

Authentication.md

Lines changed: 69 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@ const App = () => (
2929
);
3030
```
3131

32+
An `authProvider` is an object that handles authentication and authorization logic, similar to a `dataProvider`. It exposes methods that react-admin calls when needed, and you can also call these methods manually through specialized hooks.
33+
3234
Once an admin has an `authProvider`, react-admin will restrict CRUD pages (the `list`, `edit`, `create`, and `show` components of your `Resources`) to authenticated users and redirect anonymous users to the `/login` page, displaying a login form for a username and password.
3335

34-
## Anatomy Of An `authProvider`
36+
![Login form](./img/login-form.png)
3537

36-
An `authProvider` is an object that handles authentication and authorization logic, similar to a `dataProvider`. It exposes methods that react-admin calls when needed, and you can also call these methods manually through specialized hooks. The `authProvider` methods must return a Promise.
38+
React-admin offers several built-in `authProvider` implementations for popular authentication services like **Google Identity**, **Microsoft Entra ID**, **AWS Cognito**, **Auth0**, **Keycloak**, and others. Refer to the [List of Available Auth Providers](./AuthProviderList.md) to find one that suits your requirements.
3739

38-
A typical `authProvider` has the following methods:
40+
If you need to implement a custom authentication strategy, the [Building Your Own Auth Provider](./AuthProviderWriting.md) offers a step-by-step guide. It boils down to implementing a few methods that react-admin calls when needed:
3941

4042
```js
4143
const authProvider = {
@@ -54,8 +56,6 @@ const authProvider = {
5456
};
5557
```
5658

57-
You can use an existing Auth Provider from the [List of Available Auth Providers](./AuthProviderList.md) or write your own by following the [Building Your Own Auth Provider](./AuthProviderWriting.md) instructions.
58-
5959
## Sending Credentials To The API
6060

6161
The `authProvider` handles authentication logic, but the `dataProvider` must include the user credentials in requests to the API.
@@ -229,23 +229,74 @@ const App = () => (
229229

230230
## Customizing The Login Component
231231

232-
Using an `authProvider` is enough to secure your app if authentication relies on a username and password. But for cases like using an email instead of a username, Single-Sign-On (SSO), or two-factor authentication, you can implement your own `LoginPage` component to be displayed under the `/login` route.
232+
Using an `authProvider` is enough to secure your app if authentication relies on a username and password. But for cases like using an email instead of a username, Single-Sign-On (SSO), or two-factor authentication, you can use a custom login page by setting the [`<Admin loginPage>`](./Admin.md#loginpage) prop.
233233

234-
Pass this component to the [`<Admin loginPage>`](./Admin.md#loginpage) prop:
234+
For example, to use an email field instead of a username field, use the `LoginWithEmail` component:
235235

236-
```jsx
237-
// in src/App.js
238-
import { Admin } from 'react-admin';
239-
240-
import MyLoginPage from './MyLoginPage';
236+
```tsx
237+
import { Admin, LoginWithEmail } from 'react-admin';
238+
import authProvider from './authProvider';
241239

242240
const App = () => (
243-
<Admin loginPage={MyLoginPage} authProvider={authProvider}>
244-
...
241+
<Admin loginPage={LoginWithEmail} authProvider={authProvider}>
242+
...
245243
</Admin>
246244
);
247245
```
248246

247+
![Login with email](./img/LoginWithEmail.jpg)
248+
249+
The default login page component is the `Login` component, which delegates the rendering of the login form to its child, usually a `LoginForm` component. This means you can create a custom login page by adding your own content to the `Login` component.
250+
251+
For instance, to add a "forgot password" link to the login page:
252+
253+
```jsx
254+
import { Box, Link } from '@mui/material';
255+
import { Link as RouterLink } from 'react-router-dom';
256+
import { Login, LoginForm } from 'react-admin';
257+
258+
const MyLogin = () => (
259+
<Login>
260+
<LoginForm />
261+
<Box textAlign="center" mb={1}>
262+
<Link component={RouterLink} to="/forgot-password">
263+
Forgot password?
264+
</Link>
265+
</Box>
266+
</Login>
267+
);
268+
```
269+
270+
![Login with content](./img/LoginWithContent.jpg)
271+
272+
You can also customize the login form fields, by setting the `LoginForm` children:
273+
274+
```jsx
275+
import { Link as RouterLink } from 'react-router-dom';
276+
import { Login, LoginForm, TextInput, PasswordInput, required } from 'react-admin';
277+
278+
const MyLogin = () => (
279+
<Login>
280+
<LoginForm>
281+
<TextInput
282+
autoFocus
283+
source="email"
284+
label="Email"
285+
autoComplete="email"
286+
type="email"
287+
validate={required()}
288+
/>
289+
<PasswordInput
290+
source="password"
291+
label="Password"
292+
autoComplete="current-password"
293+
validate={required()}
294+
/>
295+
</LoginForm>
296+
</Login>
297+
);
298+
```
299+
249300
By default, the login page displays a gradient background. To change it, use the default Login component and pass an image URL as the `backgroundImage` prop.
250301
251302
```jsx
@@ -257,7 +308,9 @@ const MyLoginPage = () => (
257308
);
258309
```
259310
260-
To build a Login page from scratch, use the [`useLogin` hook](./useLogin.md).
311+
![Custom login page](./img/LoginCustomBackground.jpg)
312+
313+
You can also build your login page from scratch, leveraging the [`useLogin` hook](./useLogin.md) to handle the login form submission.
261314
262315
```jsx
263316
// in src/MyLoginPage.js
@@ -415,7 +468,7 @@ export const dataProvider = addRefreshAuthToDataProvider(baseDataProvider, refre
415468
416469
## Authorization
417470
418-
Access control and permissions allow you to restrict certain pages to specific users. React-admin provides powerful primitives for implementing authorization logic. For detailed guidance, check out the [Authorization](./Permissions.md) documentation.
471+
Access control and permissions allow you to restrict certain pages and features to specific users. React-admin provides powerful primitives for implementing authorization logic. For detailed guidance, check out the [Authorization](./Permissions.md) documentation.
419472
420473
<video controls autoplay muted loop>
421474
<source src="./img/AccessControl.mp4" type="video/mp4"/>

CanAccess.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export const LogsPage = () => (
5858
);
5959
```
6060

61-
Use the [`<CustomRoutes>`](./CustomRoutes.md) component to add custom routes to your admin.
61+
Use the [`<CustomRoutes>`](./CustomRoutes.md) component to add custom routes to your admin.
6262

6363
```tsx
6464
import { Admin, CustomRoutes, Authenticated, CanAccess, AccessDenied, Layout } from 'react-admin';
@@ -98,3 +98,22 @@ export const MyMenu = () => (
9898

9999
**Note**: You don't need to use `<Authenticated>` on custom pages if your admin uses [`requireAuth`](./Admin.md#requireauth).
100100

101+
## Access Denied Message
102+
103+
By default, `<CanAccess>` renders nothing when the user doesn't have access to the resource.
104+
105+
On custom pages, it's preferable to show an error message instead. Set the `accessDenied` prop to render a custom component in case of access denial:
106+
107+
```tsx
108+
import { Authenticated, CanAccess, AccessDenied } from 'react-admin';
109+
110+
export const LogsPage = () => (
111+
<Authenticated>
112+
<CanAccess resource="logs" action="read" accessDenied={<AccessDenied />}>
113+
...
114+
</CanAccess>
115+
</Authenticated>
116+
);
117+
```
118+
119+
![Access Denied](./img/accessDenied.png)

ContainerLayout.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ const MyLayout = ({ children }) => (
8585

8686
## `menu`
8787

88-
By default, `<ContainerLayout>` renders one menu item per resource in the admin. To reorder the menu, omit resources, or add custom pages, pass a custom menu element to the `menu` prop. This element should be [a `<HorizontalMenu>` component](#horizontalmenu) with `<HorizontalMenu.Item>` children. Each child should have a `value` corresponding to the [application location](https://react-admin-ee.marmelab.com/documentation/ra-navigation#concepts) of the target, and can have a `to` prop corresponding to the target location if different from the app location.
88+
By default, `<ContainerLayout>` renders one menu item per resource in the admin. To reorder the menu, omit resources, or add custom pages, pass a custom menu element to the `menu` prop.
89+
This element should be [a `<HorizontalMenu>` component](#horizontalmenu) with `<HorizontalMenu.DashboardItem>` or `<HorizontalMenu.Item>` children.
90+
Each child should have a `value` corresponding to the [application location](https://react-admin-ee.marmelab.com/documentation/ra-navigation#concepts) of the target, and can have a `to` prop corresponding to the target location if different from the app location.
8991

9092
```jsx
9193
import {
@@ -104,10 +106,14 @@ import {
104106

105107
const Menu = () => (
106108
<HorizontalMenu>
107-
<HorizontalMenu.Item label="Dashboard" to="/" value="" />
109+
<HorizontalMenu.DashboardItem label="Dashboard" value="" />
108110
<HorizontalMenu.Item label="Songs" to="/songs" value="songs" />
109111
<HorizontalMenu.Item label="Artists" to="/artists" value="artists" />
110112
<HorizontalMenu.Item label="Custom" to="/custom" value="custom" />
113+
<HorizontalMenu.Item label="Business" value="business">
114+
<HorizontalMenu.Item label="Sales" value="sales" >
115+
<HorizontalMenu.Item label="Customers" value="customers" >
116+
</HorizontalMenu.Item>
111117
</HorizontalMenu>
112118
);
113119

@@ -225,7 +231,6 @@ export const MyLayout = ({ children }) => (
225231
```
226232
{% endraw %}
227233

228-
## `<HorizontalMenu>`
229234

230235
This component renders a horizontal menu, to be used in the AppBar of the [`<ContainerLayout>`](#containerLayout).
231236

Features.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ React-admin supports **one-to-many**, **many-to-one**, **one-to-one**, and **man
242242
- [`<ReferenceManyToManyInput>`](./ReferenceManyToManyInput.md)
243243
- [`<ReferenceOneInput>`](./ReferenceOneInput.md)
244244

245-
Reference components are a tremendous development accelerator for complex frontend features. They also liberate the backend developers from the burden of implementing complex joins.
245+
Reference components are a tremendous development accelerator for complex frontend features. They also liberate the backend developers from the burden of implementing complex joins.
246246

247247
To learn more about relationships, check out this tutorial: [Handling Relationships in React Admin](https://marmelab.com/blog/2025/02/06/handling-relationships-in-react-admin.html).
248248

@@ -833,6 +833,13 @@ You can also use the [`<SmartRichTextInput>`](./SmartRichTextInput.md) component
833833
Your browser does not support the video tag.
834834
</video>
835835

836+
One last example is [`<FormFillerButton>`](./FormFillerButton.md), which lets user fill the current form based on an image.
837+
838+
<video controls autoplay playsinline muted loop>
839+
<source src="https://react-admin-ee.marmelab.com/assets/FormFillerButton.mp4" type="video/mp4"/>
840+
Your browser does not support the video tag.
841+
</video>
842+
836843
## Fast
837844

838845
React-admin takes advantage of the Single-Page-Application architecture, implementing various performance optimizations that make react-admin apps incredibly fast by default.

0 commit comments

Comments
 (0)