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

[Doc] Add example showing how to add <Inspector> to a custom layout #9458

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
50 changes: 50 additions & 0 deletions docs/Configurable.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,53 @@ const MyAppBar = () => (
</AppBar>
);
```

## `<Inspector>`

The `<Inspector>` component exists within the layouts provided by react-admin. If you are using a custom layout then you should add the `<Inspector>` component within your layout
rossb220 marked this conversation as resolved.
Show resolved Hide resolved

{% raw %}
```jsx
// in src/MyLayout.js
import * as React from 'react';
import { Box } from '@mui/material';
import { AppBar, Menu, Sidebar, InspectorButton } from 'react-admin';
rossb220 marked this conversation as resolved.
Show resolved Hide resolved

const MyLayout = ({ children, dashboard }) => (
<Box
display="flex"
flexDirection="column"
zIndex={1}
minHeight="100vh"
backgroundColor="theme.palette.background.default"
position="relative"
>
<Box
display="flex"
flexDirection="column"
overflowX="auto"
>
<AppBar />
<Box display="flex" flexGrow={1}>
<Sidebar>
<Menu hasDashboard={!!dashboard} />
</Sidebar>
<Box
display="flex"
flexDirection="column"
flexGrow={2}
p={3}
marginTop="4em"
paddingLeft={5}
>
{children}
</Box>
</Box>
</Box>
<InspectorButton />
rossb220 marked this conversation as resolved.
Show resolved Hide resolved
</Box>
);

export default MyLayout;
```
{% endraw %}
24 changes: 23 additions & 1 deletion docs/WrapperField.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ title: "The WrapperField Component"

# `<WrapperField>`

This component simply renders its children. Why would you want to use such a dumb component? To combine several fields in a single cell (in a `<Datagrid>`) or in a single row (in a `<SimpleShowLayout>`).
This component simply renders its children. Why would you want to use such a dumb component? To combine several fields in a single cell (in a `<Datagrid>`) or in a single row (in a `<SimpleShowLayout>`) or
a group of form fields (in a `<SimpleFormConfigurable>`)
rossb220 marked this conversation as resolved.
Show resolved Hide resolved

`<WrapperField>` allows to define the `label` and sort field for a combination of fields:

Expand All @@ -25,4 +26,25 @@ const BookList = () => (
);
```

```jsx
import {Edit, WrapperField, TextInput} from 'react-admin';
import {SimpleFormConfigurable} from "./SimpleFormConfigurable";
import { Stack } from '@mui/material';

const CustomForm = () => (
<Edit>
<SimpleFormConfigurable>
<TextInput source="title"/>
<WrapperField source="author">
<Stack>
<TextInput source="author_first_name"/>
<TextInput source="author_last_name"/>
</Stack>
</WrapperField>
</SimpleFormConfigurable>
</Edit>
);
rossb220 marked this conversation as resolved.
Show resolved Hide resolved
```


**Tip**: If you just want to combine two fields in a string, check [the `<FunctionField>` component](./FunctionField.md) instead.