fix: Admins should be able to add and remove themselves from collections
This commit is contained in:
@@ -1,19 +1,24 @@
|
||||
import * as React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useMenuState } from "reakit/Menu";
|
||||
import User from "~/models/User";
|
||||
import ContextMenu from "~/components/ContextMenu";
|
||||
import OverflowMenuButton from "~/components/ContextMenu/OverflowMenuButton";
|
||||
import Template from "~/components/ContextMenu/Template";
|
||||
import useCurrentUser from "~/hooks/useCurrentUser";
|
||||
|
||||
type Props = {
|
||||
user: User;
|
||||
onRemove: () => void;
|
||||
};
|
||||
|
||||
function MemberMenu({ onRemove }: Props) {
|
||||
function MemberMenu({ user, onRemove }: Props) {
|
||||
const { t } = useTranslation();
|
||||
const currentUser = useCurrentUser();
|
||||
const menu = useMenuState({
|
||||
modal: true,
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<OverflowMenuButton aria-label={t("Show menu")} {...menu} />
|
||||
@@ -23,7 +28,7 @@ function MemberMenu({ onRemove }: Props) {
|
||||
items={[
|
||||
{
|
||||
type: "button",
|
||||
title: t("Remove"),
|
||||
title: currentUser.id === user.id ? t("Leave") : t("Remove"),
|
||||
dangerous: true,
|
||||
onClick: onRemove,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user