feat: Add 'delete user' option for admins
This commit is contained in:
@@ -12,7 +12,10 @@ import {
|
||||
UserChangeToViewerDialog,
|
||||
UserSuspendDialog,
|
||||
UserChangeNameDialog,
|
||||
} from "~/components/UserRoleDialogs";
|
||||
} from "~/components/UserDialogs";
|
||||
import { actionToMenuItem } from "~/actions";
|
||||
import { deleteUserActionFactory } from "~/actions/definitions/users";
|
||||
import useActionContext from "~/hooks/useActionContext";
|
||||
import usePolicy from "~/hooks/usePolicy";
|
||||
import useStores from "~/hooks/useStores";
|
||||
import useToasts from "~/hooks/useToasts";
|
||||
@@ -29,6 +32,9 @@ function UserMenu({ user }: Props) {
|
||||
});
|
||||
const can = usePolicy(user.id);
|
||||
const { showToast } = useToasts();
|
||||
const context = useActionContext({
|
||||
isContextMenu: true,
|
||||
});
|
||||
|
||||
const handlePromote = React.useCallback(
|
||||
(ev: React.SyntheticEvent) => {
|
||||
@@ -99,7 +105,7 @@ function UserMenu({ user }: Props) {
|
||||
(ev: React.SyntheticEvent) => {
|
||||
ev.preventDefault();
|
||||
dialogs.openModal({
|
||||
title: t("Suspend account"),
|
||||
title: t("Suspend user"),
|
||||
isCentered: true,
|
||||
content: (
|
||||
<UserSuspendDialog user={user} onSubmit={dialogs.closeAllModals} />
|
||||
@@ -199,11 +205,14 @@ function UserMenu({ user }: Props) {
|
||||
},
|
||||
{
|
||||
type: "button",
|
||||
title: `${t("Suspend account")}…`,
|
||||
dangerous: true,
|
||||
title: `${t("Suspend user")}…`,
|
||||
onClick: handleSuspend,
|
||||
visible: !user.isInvited && !user.isSuspended,
|
||||
},
|
||||
{
|
||||
type: "separator",
|
||||
},
|
||||
actionToMenuItem(deleteUserActionFactory(user.id), context),
|
||||
]}
|
||||
/>
|
||||
</ContextMenu>
|
||||
|
||||
Reference in New Issue
Block a user