Fix for empty user default tab after creation (#628)

This commit is contained in:
Dirk Klimpel 2024-10-08 09:20:55 +02:00 committed by GitHub
parent dbcb4f92dc
commit 9fc005032c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -47,6 +47,7 @@ import {
TopToolbar, TopToolbar,
NumberField, NumberField,
useListContext, useListContext,
Identifier,
} from "react-admin"; } from "react-admin";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
@ -112,7 +113,10 @@ export const UserList = (props: ListProps) => (
actions={<UserListActions />} actions={<UserListActions />}
pagination={<UserPagination />} pagination={<UserPagination />}
> >
<Datagrid rowClick="edit" bulkActionButtons={<UserBulkActionButtons />}> <Datagrid
rowClick={(id: Identifier, resource: string) => `/${resource}/${id}`}
bulkActionButtons={<UserBulkActionButtons />}
>
<AvatarField source="avatar_src" sx={{ height: "40px", width: "40px" }} sortBy="avatar_url" /> <AvatarField source="avatar_src" sx={{ height: "40px", width: "40px" }} sortBy="avatar_url" />
<TextField source="id" sortBy="name" /> <TextField source="id" sortBy="name" />
<TextField source="displayname" /> <TextField source="displayname" />
@ -153,7 +157,12 @@ const UserEditActions = () => {
}; };
export const UserCreate = (props: CreateProps) => ( export const UserCreate = (props: CreateProps) => (
<Create {...props}> <Create
{...props}
redirect={(resource: string | undefined, id: Identifier | undefined) => {
return `${resource}/${id}`;
}}
>
<SimpleForm> <SimpleForm>
<TextInput source="id" autoComplete="off" validate={validateUser} /> <TextInput source="id" autoComplete="off" validate={validateUser} />
<TextInput source="displayname" validate={maxLength(256)} /> <TextInput source="displayname" validate={maxLength(256)} />