fix: Admins should be able to add and remove themselves from collections

This commit is contained in:
Tom Moor
2023-05-04 21:52:59 -04:00
parent 0504e91aa6
commit ac8946f0c5
7 changed files with 30 additions and 18 deletions

View File

@@ -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,
},