diff --git a/apps/client/src/ee/page-permission/components/general-access-select.tsx b/apps/client/src/ee/page-permission/components/general-access-select.tsx index de2f78af..5b039c74 100644 --- a/apps/client/src/ee/page-permission/components/general-access-select.tsx +++ b/apps/client/src/ee/page-permission/components/general-access-select.tsx @@ -2,7 +2,7 @@ import { Group, Menu, Text, UnstyledButton } from "@mantine/core"; import { IconChevronDown, IconLock, - IconWorld, + IconShieldLock, IconCheck, } from "@tabler/icons-react"; import { useTranslation } from "react-i18next"; @@ -14,75 +14,75 @@ type GeneralAccessSelectProps = { value: AccessLevel; onChange: (value: AccessLevel) => void; disabled?: boolean; - isInherited?: boolean; + hasInheritedRestriction?: boolean; }; export function GeneralAccessSelect({ value, onChange, disabled, - isInherited, + hasInheritedRestriction, }: GeneralAccessSelectProps) { const { t } = useTranslation(); - const isRestricted = value === "restricted"; + 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: t("Open"), - description: t("Everyone in this space can access"), - icon: IconWorld, + 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: t("Only specific people can view or edit"), + description: hasInheritedRestriction + ? t("Add restrictions on top of inherited") + : t("Only specific people can access"), icon: IconLock, }, ]; - const currentOption = accessOptions.find((opt) => opt.value === value); - const Icon = currentOption?.icon || IconWorld; - - if (isInherited) { - return ( - -
- -
-
- - {currentOption?.label} - - - {currentOption?.description} - -
-
- ); - } - return ( - +
- +
- {currentOption?.label} + {currentLabel} {!disabled && } - {currentOption?.description} + {currentDescription}
diff --git a/apps/client/src/ee/page-permission/components/page-permission-tab.tsx b/apps/client/src/ee/page-permission/components/page-permission-tab.tsx index 50c24cbe..bb2ad776 100644 --- a/apps/client/src/ee/page-permission/components/page-permission-tab.tsx +++ b/apps/client/src/ee/page-permission/components/page-permission-tab.tsx @@ -1,8 +1,19 @@ import { useState } from "react"; -import { Button, Divider, Group, Loader, Select, Stack, Text } from "@mantine/core"; +import { + Box, + Button, + Divider, + Group, + Loader, + Paper, + Select, + Stack, + Text, + ThemeIcon, +} from "@mantine/core"; import { useTranslation } from "react-i18next"; import { Link, useParams } from "react-router-dom"; -import { IconArrowRight } from "@tabler/icons-react"; +import { IconArrowRight, IconLock, IconShieldLock } from "@tabler/icons-react"; import { MultiMemberSelect } from "@/features/space/components/multi-member-select"; import { IPageRestrictionInfo, @@ -39,18 +50,14 @@ export function PagePermissionTab({ const unrestrictMutation = useUnrestrictPageMutation(); const addPermissionMutation = useAddPagePermissionMutation(); - const isRestricted = - restrictionInfo.hasDirectRestriction || - restrictionInfo.hasInheritedRestriction; - const isInherited = - restrictionInfo.hasInheritedRestriction && - !restrictionInfo.hasDirectRestriction; + const hasInheritedRestriction = restrictionInfo.hasInheritedRestriction; + const hasDirectRestriction = restrictionInfo.hasDirectRestriction; const canManage = restrictionInfo.userAccess.canManage; - const handleAccessChange = async (value: "open" | "restricted") => { - if (value === "restricted" && !isRestricted) { + const handleDirectAccessChange = async (value: "open" | "restricted") => { + if (value === "restricted" && !hasDirectRestriction) { await restrictMutation.mutateAsync(pageId); - } else if (value === "open" && isRestricted) { + } else if (value === "open" && hasDirectRestriction) { await unrestrictMutation.mutateAsync(pageId); } }; @@ -81,72 +88,99 @@ export function PagePermissionTab({ }; return ( - - {isRestricted && canManage && !isInherited && ( - <> - -
- -
- ({ + label: t(r.label), + value: r.value, + }))} + value={role} + onChange={(value) => value && setRole(value)} + allowDeselect={false} + variant="filled" + w={120} + /> + +
+ )} + {isLoading ? ( @@ -155,7 +189,7 @@ export function PagePermissionTab({ )} diff --git a/apps/client/src/ee/page-permission/components/page-permission.module.css b/apps/client/src/ee/page-permission/components/page-permission.module.css index 545b9155..ee545f83 100644 --- a/apps/client/src/ee/page-permission/components/page-permission.module.css +++ b/apps/client/src/ee/page-permission/components/page-permission.module.css @@ -106,3 +106,14 @@ background-color: var(--mantine-color-dark-6); } } + +.inheritedSection { + @mixin light { + background-color: var(--mantine-color-orange-0); + border: 1px solid var(--mantine-color-orange-2); + } + @mixin dark { + background-color: rgba(255, 146, 43, 0.08); + border: 1px solid rgba(255, 146, 43, 0.2); + } +} diff --git a/apps/client/src/ee/page-permission/components/page-share-modal.tsx b/apps/client/src/ee/page-permission/components/page-share-modal.tsx index eb69fd47..929af6a5 100644 --- a/apps/client/src/ee/page-permission/components/page-share-modal.tsx +++ b/apps/client/src/ee/page-permission/components/page-share-modal.tsx @@ -14,7 +14,7 @@ import { useParams } from "react-router-dom"; import { extractPageSlugId } from "@/lib"; import { usePageQuery } from "@/features/page/queries/page-query"; import { usePageRestrictionInfoQuery } from "@/ee/page-permission/queries/page-permission-query"; -import { PagePermissionTab } from "./page-permission-tab"; +import { PagePermissionTab } from "@/ee/page-permission"; import { PublishTab } from "./publish-tab"; type PageShareModalProps = { @@ -67,8 +67,7 @@ export function PageShareModal({ readOnly }: PageShareModalProps) { opened={opened} onClose={close} title={t("Share")} - size="md" - centered + size={600} >