mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 06:23:06 +08:00
turn off templates
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { ScrollArea, Text, Divider, Modal, Tooltip } from "@mantine/core";
|
import { ScrollArea, Text, Divider, Modal } from "@mantine/core";
|
||||||
import {
|
import {
|
||||||
IconHome,
|
IconHome,
|
||||||
IconClock,
|
IconClock,
|
||||||
@@ -7,13 +7,10 @@ import {
|
|||||||
IconLayoutGrid,
|
IconLayoutGrid,
|
||||||
IconSettings,
|
IconSettings,
|
||||||
IconUserPlus,
|
IconUserPlus,
|
||||||
IconSearch,
|
|
||||||
IconTemplate,
|
|
||||||
} from "@tabler/icons-react";
|
} from "@tabler/icons-react";
|
||||||
import { Link, useLocation } from "react-router-dom";
|
import { Link, useLocation } from "react-router-dom";
|
||||||
import classes from "./global-sidebar.module.css";
|
import classes from "./global-sidebar.module.css";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { searchSpotlight } from "@/features/search/constants";
|
|
||||||
import { useAtom } from "jotai";
|
import { useAtom } from "jotai";
|
||||||
import { mobileSidebarAtom } from "@/components/layouts/global/hooks/atoms/sidebar-atom";
|
import { mobileSidebarAtom } from "@/components/layouts/global/hooks/atoms/sidebar-atom";
|
||||||
import { useToggleSidebar } from "@/components/layouts/global/hooks/hooks/use-toggle-sidebar";
|
import { useToggleSidebar } from "@/components/layouts/global/hooks/hooks/use-toggle-sidebar";
|
||||||
@@ -23,15 +20,11 @@ import { useDisclosure } from "@mantine/hooks";
|
|||||||
import { WorkspaceInviteForm } from "@/features/workspace/components/members/components/workspace-invite-form";
|
import { WorkspaceInviteForm } from "@/features/workspace/components/members/components/workspace-invite-form";
|
||||||
import { CustomAvatar } from "@/components/ui/custom-avatar";
|
import { CustomAvatar } from "@/components/ui/custom-avatar";
|
||||||
import { AvatarIconType } from "@/features/attachments/types/attachment.types";
|
import { AvatarIconType } from "@/features/attachments/types/attachment.types";
|
||||||
import { entitlementAtom } from "@/ee/entitlement/entitlement-atom";
|
|
||||||
import { Feature } from "@/ee/features";
|
|
||||||
import { useUpgradeLabel } from "@/ee/hooks/use-upgrade-label";
|
|
||||||
|
|
||||||
const mainNavItems = [
|
const mainNavItems = [
|
||||||
{ label: "Home", icon: IconHome, path: "/home" },
|
{ label: "Home", icon: IconHome, path: "/home" },
|
||||||
{ label: "Favorites", icon: IconStar, path: "/favorites" },
|
{ label: "Favorites", icon: IconStar, path: "/favorites" },
|
||||||
{ label: "Spaces", icon: IconLayoutGrid, path: "/spaces" },
|
{ label: "Spaces", icon: IconLayoutGrid, path: "/spaces" },
|
||||||
{ label: "Templates", icon: IconTemplate, path: "/templates", feature: Feature.TEMPLATES },
|
|
||||||
];
|
];
|
||||||
|
|
||||||
export default function GlobalSidebar() {
|
export default function GlobalSidebar() {
|
||||||
@@ -40,10 +33,6 @@ export default function GlobalSidebar() {
|
|||||||
const [active, setActive] = useState(location.pathname);
|
const [active, setActive] = useState(location.pathname);
|
||||||
const [mobileSidebarOpened] = useAtom(mobileSidebarAtom);
|
const [mobileSidebarOpened] = useAtom(mobileSidebarAtom);
|
||||||
const toggleMobileSidebar = useToggleSidebar(mobileSidebarAtom);
|
const toggleMobileSidebar = useToggleSidebar(mobileSidebarAtom);
|
||||||
const [entitlements] = useAtom(entitlementAtom);
|
|
||||||
const upgradeLabel = useUpgradeLabel();
|
|
||||||
const hasFeature = (f: string) =>
|
|
||||||
entitlements?.features?.includes(f) ?? false;
|
|
||||||
const { data: favoriteSpacesData } = useFavoritesQuery("space");
|
const { data: favoriteSpacesData } = useFavoritesQuery("space");
|
||||||
const favoriteSpaces = favoriteSpacesData?.pages.flatMap((p) => p.items) ?? [];
|
const favoriteSpaces = favoriteSpacesData?.pages.flatMap((p) => p.items) ?? [];
|
||||||
const sortedFavoriteSpaces = [...favoriteSpaces]
|
const sortedFavoriteSpaces = [...favoriteSpaces]
|
||||||
@@ -69,51 +58,18 @@ export default function GlobalSidebar() {
|
|||||||
<div className={classes.navbar}>
|
<div className={classes.navbar}>
|
||||||
<ScrollArea w="100%" style={{ flex: 1 }}>
|
<ScrollArea w="100%" style={{ flex: 1 }}>
|
||||||
<div className={classes.section}>
|
<div className={classes.section}>
|
||||||
<a
|
{mainNavItems.map((item) => (
|
||||||
className={classes.link}
|
<Link
|
||||||
onClick={(e) => {
|
key={item.label}
|
||||||
e.preventDefault();
|
className={classes.link}
|
||||||
searchSpotlight.open();
|
data-active={active === item.path || undefined}
|
||||||
}}
|
to={item.path}
|
||||||
href="#"
|
onClick={handleNavClick}
|
||||||
>
|
>
|
||||||
<IconSearch className={classes.linkIcon} stroke={2} />
|
<item.icon className={classes.linkIcon} stroke={2} />
|
||||||
<span>{t("Search")}</span>
|
<span>{t(item.label)}</span>
|
||||||
</a>
|
</Link>
|
||||||
{mainNavItems.map((item) => {
|
))}
|
||||||
const isDisabled = item.feature && !hasFeature(item.feature);
|
|
||||||
|
|
||||||
const linkElement = (
|
|
||||||
<Link
|
|
||||||
key={item.label}
|
|
||||||
className={classes.link}
|
|
||||||
data-active={active === item.path || undefined}
|
|
||||||
data-disabled={isDisabled || undefined}
|
|
||||||
to={isDisabled ? "#" : item.path}
|
|
||||||
onClick={(e) => {
|
|
||||||
if (isDisabled) {
|
|
||||||
e.preventDefault();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
handleNavClick();
|
|
||||||
}}
|
|
||||||
style={isDisabled ? { opacity: 0.5, cursor: "not-allowed" } : undefined}
|
|
||||||
>
|
|
||||||
<item.icon className={classes.linkIcon} stroke={2} />
|
|
||||||
<span>{t(item.label)}</span>
|
|
||||||
</Link>
|
|
||||||
);
|
|
||||||
|
|
||||||
if (isDisabled) {
|
|
||||||
return (
|
|
||||||
<Tooltip key={item.label} label={upgradeLabel} position="right" withArrow>
|
|
||||||
{linkElement}
|
|
||||||
</Tooltip>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return linkElement;
|
|
||||||
})}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Divider my="xs" />
|
<Divider my="xs" />
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { useTranslation } from "react-i18next";
|
|||||||
import EnforceMfa from "@/ee/security/components/enforce-mfa.tsx";
|
import EnforceMfa from "@/ee/security/components/enforce-mfa.tsx";
|
||||||
import DisablePublicSharing from "@/ee/security/components/disable-public-sharing.tsx";
|
import DisablePublicSharing from "@/ee/security/components/disable-public-sharing.tsx";
|
||||||
import TrashRetention from "@/ee/security/components/trash-retention.tsx";
|
import TrashRetention from "@/ee/security/components/trash-retention.tsx";
|
||||||
import AllowMemberTemplates from "@/ee/security/components/allow-member-templates.tsx";
|
|
||||||
import { useHasFeature } from "@/ee/hooks/use-feature";
|
import { useHasFeature } from "@/ee/hooks/use-feature";
|
||||||
import { Feature } from "@/ee/features";
|
import { Feature } from "@/ee/features";
|
||||||
|
|
||||||
@@ -44,9 +44,6 @@ export default function Security() {
|
|||||||
<TrashRetention />
|
<TrashRetention />
|
||||||
<Divider my="lg" />
|
<Divider my="lg" />
|
||||||
|
|
||||||
<AllowMemberTemplates />
|
|
||||||
<Divider my="lg" />
|
|
||||||
|
|
||||||
<Title order={4} my="lg">
|
<Title order={4} my="lg">
|
||||||
Single sign-on (SSO)
|
Single sign-on (SSO)
|
||||||
</Title>
|
</Title>
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import {
|
|||||||
IconPlus,
|
IconPlus,
|
||||||
IconSearch,
|
IconSearch,
|
||||||
IconSettings,
|
IconSettings,
|
||||||
IconTemplate,
|
|
||||||
IconTrash,
|
IconTrash,
|
||||||
} from "@tabler/icons-react";
|
} from "@tabler/icons-react";
|
||||||
import {
|
import {
|
||||||
@@ -47,9 +46,6 @@ import ExportModal from "@/components/common/export-modal";
|
|||||||
import { mobileSidebarAtom } from "@/components/layouts/global/hooks/atoms/sidebar-atom.ts";
|
import { mobileSidebarAtom } from "@/components/layouts/global/hooks/atoms/sidebar-atom.ts";
|
||||||
import { useToggleSidebar } from "@/components/layouts/global/hooks/hooks/use-toggle-sidebar.ts";
|
import { useToggleSidebar } from "@/components/layouts/global/hooks/hooks/use-toggle-sidebar.ts";
|
||||||
import { searchSpotlight } from "@/features/search/constants";
|
import { searchSpotlight } from "@/features/search/constants";
|
||||||
import { entitlementAtom } from "@/ee/entitlement/entitlement-atom";
|
|
||||||
import { Feature } from "@/ee/features";
|
|
||||||
import { useUpgradeLabel } from "@/ee/hooks/use-upgrade-label";
|
|
||||||
|
|
||||||
export function SpaceSidebar() {
|
export function SpaceSidebar() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -59,9 +55,7 @@ export function SpaceSidebar() {
|
|||||||
useDisclosure(false);
|
useDisclosure(false);
|
||||||
const [mobileSidebarOpened] = useAtom(mobileSidebarAtom);
|
const [mobileSidebarOpened] = useAtom(mobileSidebarAtom);
|
||||||
const toggleMobileSidebar = useToggleSidebar(mobileSidebarAtom);
|
const toggleMobileSidebar = useToggleSidebar(mobileSidebarAtom);
|
||||||
const [entitlements] = useAtom(entitlementAtom);
|
|
||||||
const upgradeLabel = useUpgradeLabel();
|
|
||||||
const hasTemplates = entitlements?.features?.includes(Feature.TEMPLATES) ?? false;
|
|
||||||
|
|
||||||
const { spaceSlug } = useParams();
|
const { spaceSlug } = useParams();
|
||||||
const { data: space } = useGetSpaceBySlugQuery(spaceSlug);
|
const { data: space } = useGetSpaceBySlugQuery(spaceSlug);
|
||||||
@@ -144,44 +138,6 @@ export function SpaceSidebar() {
|
|||||||
</div>
|
</div>
|
||||||
</UnstyledButton>
|
</UnstyledButton>
|
||||||
|
|
||||||
{hasTemplates ? (
|
|
||||||
<UnstyledButton
|
|
||||||
component={Link}
|
|
||||||
to="/templates"
|
|
||||||
className={clsx(
|
|
||||||
classes.menu,
|
|
||||||
location.pathname.toLowerCase() === "/templates"
|
|
||||||
? classes.activeButton
|
|
||||||
: "",
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<div className={classes.menuItemInner}>
|
|
||||||
<IconTemplate
|
|
||||||
size={18}
|
|
||||||
className={classes.menuItemIcon}
|
|
||||||
stroke={2}
|
|
||||||
/>
|
|
||||||
<span>{t("Templates")}</span>
|
|
||||||
</div>
|
|
||||||
</UnstyledButton>
|
|
||||||
) : (
|
|
||||||
<Tooltip label={upgradeLabel} position="right" withArrow>
|
|
||||||
<UnstyledButton
|
|
||||||
className={classes.menu}
|
|
||||||
style={{ opacity: 0.5, cursor: "not-allowed" }}
|
|
||||||
>
|
|
||||||
<div className={classes.menuItemInner}>
|
|
||||||
<IconTemplate
|
|
||||||
size={18}
|
|
||||||
className={classes.menuItemIcon}
|
|
||||||
stroke={2}
|
|
||||||
/>
|
|
||||||
<span>{t("Templates")}</span>
|
|
||||||
</div>
|
|
||||||
</UnstyledButton>
|
|
||||||
</Tooltip>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{spaceAbility.can(
|
{spaceAbility.can(
|
||||||
SpaceCaslAction.Manage,
|
SpaceCaslAction.Manage,
|
||||||
SpaceCaslSubject.Page,
|
SpaceCaslSubject.Page,
|
||||||
|
|||||||
Reference in New Issue
Block a user