import { Group, Menu, Text, UnstyledButton } from "@mantine/core"; import { IconChevronDown, IconLock, IconShieldLock, IconCheck, } from "@tabler/icons-react"; import { useTranslation } from "react-i18next"; import classes from "./page-permission.module.css"; type AccessLevel = "open" | "restricted"; type GeneralAccessSelectProps = { value: AccessLevel; onChange: (value: AccessLevel) => void; disabled?: boolean; hasInheritedRestriction?: boolean; }; export function GeneralAccessSelect({ value, onChange, disabled, hasInheritedRestriction, }: GeneralAccessSelectProps) { const { t } = useTranslation(); const isDirectlyRestricted = value === "restricted"; const showInheritedState = hasInheritedRestriction && !isDirectlyRestricted; const currentLabel = showInheritedState ? t("Restricted by parent") : isDirectlyRestricted ? t("Restricted") : t("Open"); const currentDescription = showInheritedState ? t("Inherits restrictions from ancestor page") : isDirectlyRestricted ? t("Only specific people can access") : t("Everyone in this space can access"); const CurrentIcon = showInheritedState ? IconShieldLock : isDirectlyRestricted ? IconLock : IconShieldLock; const accessOptions = [ { value: "open" as const, label: hasInheritedRestriction ? t("Restricted by parent") : t("Open"), description: hasInheritedRestriction ? t("Use only inherited restrictions") : t("Everyone in this space can access"), icon: IconShieldLock, }, { value: "restricted" as const, label: t("Restricted"), description: hasInheritedRestriction ? t("Add restrictions on top of inherited") : t("Only specific people can access"), icon: IconLock, }, ]; return (
); }