Create UserEditActions on user page (#222)

* Create `UserEditActions` on user page

* Fix crash with crashes `undefined`
This commit is contained in:
Dirk Klimpel 2023-01-16 12:52:00 +01:00 committed by GitHub
parent e787b0a940
commit e23e9ccd82
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -259,20 +259,31 @@ export function generateRandomUser() {
};
}
const UserEditToolbar = props => {
const UserEditToolbar = props => (
<Toolbar {...props}>
<SaveButton submitOnEnter={true} disabled={props.pristine} />
</Toolbar>
);
const UserEditActions = ({ data }) => {
const translate = useTranslate();
var userStatus = "";
if (data) {
userStatus = data.deactivated;
}
return (
<Toolbar {...props}>
<SaveButton submitOnEnter={true} disabled={props.pristine} />
<TopToolbar>
{!userStatus && <ServerNoticeButton record={data} />}
<DeleteButton
record={data}
label="resources.users.action.erase"
confirmTitle={translate("resources.users.helper.erase", {
smart_count: 1,
})}
mutationMode="pessimistic"
/>
<ServerNoticeButton />
</Toolbar>
</TopToolbar>
);
};
@ -334,7 +345,7 @@ export const UserEdit = props => {
const classes = useStyles();
const translate = useTranslate();
return (
<Edit {...props} title={<UserTitle />}>
<Edit {...props} title={<UserTitle />} actions={<UserEditActions />}>
<TabbedForm toolbar={<UserEditToolbar />}>
<FormTab
label={translate("resources.users.name", { smart_count: 1 })}