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] Fix Enterprise Edition modues syntax following 4.0 release #7795

Merged
merged 1 commit into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion docs/AccordionForm.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ You can also use the `<AccordionSection>` component as a child of `<SimpleForm>`

![Accordion section](https://marmelab.com/ra-enterprise/modules/assets/ra-accordion-section-overview.gif)

Check [the `ra-form-layout` documentation](https://marmelab.com/ra-enterprise/modules/ra-form-layout) for more details.
Check [the `ra-form-layout` documentation](https://marmelab.com/ra-enterprise/modules/ra-form-layout##accordionform) for more details.
5 changes: 2 additions & 3 deletions docs/Calendar.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ The user interface offers everything you expect:

## Usage

Use `<Calendar>` as a child of `<List>`:
Use `<Calendar>` as a child of `<List>` to render a list of events in a calendar:

```jsx
import { Calendar, getFilterValuesFromInterval } from '@react-admin/ra-calendar';
Expand All @@ -46,7 +46,6 @@ const EventList = () => (
The `ra-calendar` module also offers a full replacement for the `<List>` component, complete with show and edit views for events, called `<CompleteCalendar>`:

```jsx
import React from 'react';
import {
Admin,
Resource,
Expand All @@ -68,7 +67,7 @@ const EventList = () => (
</CompleteCalendar>
);

export const Basic = () => (
export const App = () => (
<Admin dataProvider={dataProvider}>
<Resource name="events" list={EventList} />
</Admin>
Expand Down
18 changes: 12 additions & 6 deletions docs/CreateDialog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@ This [Enterprise Edition](https://marmelab.com/ra-enterprise)<img class="icon" s
![CreateDialog](https://marmelab.com/ra-enterprise/modules/assets/edit-dialog.gif)

```jsx
import * as React from 'react';
import { List, Datagrid, SimpleForm, TextField, TextInput, DateInput, required } from 'react-admin';
import {
List,
Datagrid,
SimpleForm,
TextInput,
DateInput,
DateField,
required,
} from 'react-admin';
import { CreateDialog } from '@react-admin/ra-form-layout';

const CustomerList = () => (
Expand All @@ -21,17 +28,16 @@ const CustomerList = () => (
...
</Datagrid>
</List>
<CreateDialog {...props}>
<CreateDialog>
<SimpleForm>
<TextField source="id" />
<TextInput source="first_name" validate={required()} />
<TextInput source="last_name" validate={required()} />
<DateInput source="date_of_birth" label="born" validate={required()} />
<DateInput source="date_of_birth" />
</SimpleForm>
</CreateDialog>
</>
);
```

Check [the `ra-form-layout` documentation](https://marmelab.com/ra-enterprise/modules/ra-form-layout) for more details.
Check [the `ra-form-layout` documentation](https://marmelab.com/ra-enterprise/modules/ra-form-layout#createdialog-editdialog--showdialog) for more details.

21 changes: 14 additions & 7 deletions docs/EditDialog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@ This [Enterprise Edition](https://marmelab.com/ra-enterprise)<img class="icon" s
![EditDialog](https://marmelab.com/ra-enterprise/modules/assets/edit-dialog.gif)

```jsx
import * as React from 'react';
import { List, Datagrid, SimpleForm, TextField, TextInput, DateInput, required } from 'react-admin';
import { EditDialog, CreateDialog } from '@react-admin/ra-form-layout';
import {
List,
Datagrid,
SimpleForm,
TextField,
TextInput,
DateInput,
DateField,
required,
} from 'react-admin';
import { EditDialog } from '@react-admin/ra-form-layout';

const CustomerList = () => (
<>
Expand All @@ -21,17 +29,16 @@ const CustomerList = () => (
...
</Datagrid>
</List>
<EditDialog {...props}>
<EditDialog>
<SimpleForm>
<TextField source="id" />
<TextInput source="first_name" validate={required()} />
<TextInput source="last_name" validate={required()} />
<DateInput source="date_of_birth" label="born" validate={required()} />
<DateInput source="date_of_birth" />
</SimpleForm>
</EditDialog>
</>
);
```

Check [the `ra-form-layout` documentation](https://marmelab.com/ra-enterprise/modules/ra-form-layout) for more details.
Check [the `ra-form-layout` documentation](https://marmelab.com/ra-enterprise/modules/ra-form-layout#createdialog-editdialog--showdialog) for more details.

7 changes: 3 additions & 4 deletions docs/EditableDatagrid.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ This [Enterprise Edition](https://marmelab.com/ra-enterprise)<img class="icon" s
`<EditableDatagrid>` is a drop-in replacement for `<Datagrid>`. It expects 2 additional props: `createForm` and `editForm`, the components to be displayed when a user creates or edits a row. The `<RowForm>` component allows to create such forms using react-admin Input components.

```jsx
import * as React from 'react';
import {
List,
TextField,
Expand All @@ -36,7 +35,7 @@ const professionChoices = [
const ArtistList = () => (
<List hasCreate empty={false}>
<EditableDatagrid
undoable
mutationMode="undoable"
createForm={<ArtistForm />}
editForm={<ArtistForm />}
>
Expand All @@ -53,8 +52,8 @@ const ArtistList = () => (
</List>
);

const ArtistForm = props => (
<RowForm {...props}>
const ArtistForm = () => (
<RowForm>
<TextField source="id" />
<TextInput source="firstname" validate={required()} />
<TextInput source="name" validate={required()} />
Expand Down
14 changes: 6 additions & 8 deletions docs/ReferenceManyToManyField.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,22 @@ This [Enterprise Edition](https://marmelab.com/ra-enterprise)<img class="icon" s
For instance, here is how to fetch the authors related to a book record by matching `book.id` to `book_authors.book_id`, then matching `book_authors.author_id` to `authors.id`, and then display the author last_name for each, in a `<ChipField>`:

```jsx
import * as React from 'react';
import {
import {
Show,
SimpleShowLayout,
TextField,
DateField,
SingleFieldList,
ChipField,
EditButton,
} from 'react-admin';
import { ReferenceManyToManyField } from '@react-admin/ra-many-to-many';
import { ReferenceManyToManyField } from '@react-admin/ra-relationships';

export const BookShow = props => (
<Show {...props}>
export const BookShow = () => (
<Show>
<SimpleShowLayout>
<TextField source="title" />
<DateField source="publication_date" />
<ReferenceManyToManyField
<ReferenceManyToManyField
reference="authors"
through="book_authors"
using="book_id,author_id"
Expand Down Expand Up @@ -55,4 +53,4 @@ This example uses the following schema:
└──────────────────┘ └──────────────┘ └───────────────┘
```

Check [the `ra-relationships` documentation](https://marmelab.com/ra-enterprise/modules/ra-relationships) for more details.
Check [the `ra-relationships` documentation](https://marmelab.com/ra-enterprise/modules/ra-relationships#referencemanytomanyfield) for more details.
53 changes: 20 additions & 33 deletions docs/ReferenceManyToManyInput.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,21 @@ In this example, `artists.id` matches `performances.artist_id`, and `performance
└────────────┘ └──────────────┘ └────────┘
```

The form displays the events name in a `<SelectArrayInput>`:
The form displays the events name in a [`<SelectArrayInput>`](./SelectArrayInput.md):

```jsx
import * as React from 'react';
import { Edit, SelectArrayInput, SimpleForm, TextInput } from 'react-admin';
import { ReferenceManyToManyInput, useReferenceManyToManyUpdate } from '@react-admin/ra-many-to-many';

/**
* Decorate <SimpleForm> to override the default save function.
* This is necessary to save changes in the associative table
* only on submission.
*/
const ArtistEditForm = props => {
const save = useReferenceManyToManyUpdate({
record: props.record,
redirect: props.redirect || 'list',
reference: 'events',
resource: props.resource,
source: 'id',
through: 'performances',
undoable: props.undoable,
using: 'artist_id,event_id',
});

return <SimpleForm {...props} save={save} />;
};

const ArtistEdit = () => (
import {
Edit,
SelectArrayInput,
SimpleForm,
TextInput,
required,
} from 'react-admin';
import { ReferenceManyToManyInput } from '@react-admin/ra-relationships';

export const ArtistEdit = () => (
<Edit>
<ArtistEditForm>
<SimpleForm>
<TextInput disabled source="id" />
<TextInput source="first_name" />
<TextInput source="last_name" />
Expand All @@ -57,16 +42,18 @@ const ArtistEdit = () => (
reference="events"
through="performances"
using="artist_id,event_id"
fullWidth
label="Performances"
>
<SelectArrayInput optionText="name" />
<SelectArrayInput
label="Performances"
// Validation must be set on this component
validate={required()}
optionText="name"
fullWidth
/>
</ReferenceManyToManyInput>
</ArtistEditForm>
</SimpleForm>
</Edit>
);

export default ArtistEdit;
```

Check [the `ra-relationships` documentation](https://marmelab.com/ra-enterprise/modules/ra-relationships#referencemanytomanyinput) for more details.
47 changes: 25 additions & 22 deletions docs/TreeWithDetails.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,49 +15,52 @@ This component allows users to browse, edit, and rearrange trees.

```jsx
// in src/category.js
import * as React from 'react';
import { Admin, Resource, TextInput } from 'react-admin';
import { CreateNode, EditNode, SimpleForm, TreeWithDetails } from '@react-admin/ra-tree';
import {
Admin,
Resource,
Create,
Edit,
SimpleForm,
TextInput,
} from 'react-admin';
import {
CreateNode,
EditNode,
EditNodeToolbar,
TreeWithDetails,
} from '@react-admin/ra-tree';

// a Create view for a tree uses <CreateNode> instead of the standard <Create>
const CategoriesCreate = props => (
<CreateNode {...props}>
const CategoriesCreate = () => (
<CreateNode>
<SimpleForm>
<TextInput source="name" />
</SimpleForm>
</CreateNode>
);

// an Edit view for a tree uses <EditNode> instead of the standard <Edit>
const CategoriesEdit = props => (
<EditNode {...props}>
<SimpleForm>
const CategoriesEdit = () => (
<EditNode>
<SimpleForm toolbar={<EditNodeToolbar />}>
<TextInput source="title" />
</SimpleForm>
</EditNode>
)
);

// a List view for a tree uses <TreeWithDetails>
export const CategoriesList = props => (
<TreeWithDetails
create={CategoriesCreate}
edit={CategoriesEdit}
{...props}
/>
export const CategoriesList = () => (
<TreeWithDetails create={CategoriesCreate} edit={CategoriesEdit} />
);

// in src/App.js
import { CategoriesList } from './category';

const App = () => (
<Admin
dataProvider={dataProvider}
i18nProvider={i18nProvider}
locale="en"
>
<Admin dataProvider={dataProvider}>
<Resource list={CategoriesList} />
</Admin>
)
);
```

Check [the `ra-tree` documentation](https://marmelab.com/ra-enterprise/modules/ra-tree) for more details.
Check [the `ra-tree` documentation](https://marmelab.com/ra-enterprise/modules/ra-tree#treewithdetails-component) for more details.
3 changes: 1 addition & 2 deletions docs/WizardForm.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ This [Enterprise Edition](https://marmelab.com/ra-enterprise)<img class="icon" s
![WizardForm](https://marmelab.com/ra-enterprise/modules/assets/ra-wizard-form-overview.gif)

```jsx
import * as React from 'react';
import { Create, TextInput, required } from 'react-admin';
import { WizardForm, WizardFormStep } from '@react-admin/ra-form-layout';

Expand All @@ -31,4 +30,4 @@ const PostCreate = () => (
);
```

Check [the `ra-form-layout` documentation](https://marmelab.com/ra-enterprise/modules/ra-form-layout) for more details.
Check [the `ra-form-layout` documentation](https://marmelab.com/ra-enterprise/modules/ra-form-layout#wizardform) for more details.