mirror of
https://github.com/docmost/docmost.git
synced 2025-11-10 09:12:05 +10:00
(cloud) disable page sharing in trial mode
This commit is contained in:
@ -10,7 +10,7 @@ import {
|
|||||||
TextInput,
|
TextInput,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { IconExternalLink, IconWorld } from "@tabler/icons-react";
|
import { IconExternalLink, IconWorld, IconLock } from "@tabler/icons-react";
|
||||||
import React, { useEffect, useMemo, useState } from "react";
|
import React, { useEffect, useMemo, useState } from "react";
|
||||||
import {
|
import {
|
||||||
useCreateShareMutation,
|
useCreateShareMutation,
|
||||||
@ -18,23 +18,27 @@ import {
|
|||||||
useShareForPageQuery,
|
useShareForPageQuery,
|
||||||
useUpdateShareMutation,
|
useUpdateShareMutation,
|
||||||
} from "@/features/share/queries/share-query.ts";
|
} from "@/features/share/queries/share-query.ts";
|
||||||
import { Link, useParams } from "react-router-dom";
|
import { Link, useNavigate, useParams } from "react-router-dom";
|
||||||
import { extractPageSlugId, getPageIcon } from "@/lib";
|
import { extractPageSlugId, getPageIcon } from "@/lib";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import CopyTextButton from "@/components/common/copy.tsx";
|
import CopyTextButton from "@/components/common/copy.tsx";
|
||||||
import { getAppUrl } from "@/lib/config.ts";
|
import { getAppUrl, isCloud } from "@/lib/config.ts";
|
||||||
import { buildPageUrl } from "@/features/page/page.utils.ts";
|
import { buildPageUrl } from "@/features/page/page.utils.ts";
|
||||||
import classes from "@/features/share/components/share.module.css";
|
import classes from "@/features/share/components/share.module.css";
|
||||||
|
import useTrial from "@/ee/hooks/use-trial.tsx";
|
||||||
|
import { getCheckoutLink } from "@/ee/billing/services/billing-service.ts";
|
||||||
|
|
||||||
interface ShareModalProps {
|
interface ShareModalProps {
|
||||||
readOnly: boolean;
|
readOnly: boolean;
|
||||||
}
|
}
|
||||||
export default function ShareModal({ readOnly }: ShareModalProps) {
|
export default function ShareModal({ readOnly }: ShareModalProps) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const navigate = useNavigate();
|
||||||
const { pageSlug } = useParams();
|
const { pageSlug } = useParams();
|
||||||
const pageId = extractPageSlugId(pageSlug);
|
const pageId = extractPageSlugId(pageSlug);
|
||||||
const { data: share } = useShareForPageQuery(pageId);
|
const { data: share } = useShareForPageQuery(pageId);
|
||||||
const { spaceSlug } = useParams();
|
const { spaceSlug } = useParams();
|
||||||
|
const { isTrial } = useTrial();
|
||||||
const createShareMutation = useCreateShareMutation();
|
const createShareMutation = useCreateShareMutation();
|
||||||
const updateShareMutation = useUpdateShareMutation();
|
const updateShareMutation = useUpdateShareMutation();
|
||||||
const deleteShareMutation = useDeleteShareMutation();
|
const deleteShareMutation = useDeleteShareMutation();
|
||||||
@ -61,7 +65,7 @@ export default function ShareModal({ readOnly }: ShareModalProps) {
|
|||||||
createShareMutation.mutateAsync({
|
createShareMutation.mutateAsync({
|
||||||
pageId: pageId,
|
pageId: pageId,
|
||||||
includeSubPages: true,
|
includeSubPages: true,
|
||||||
searchIndexing: true,
|
searchIndexing: false,
|
||||||
});
|
});
|
||||||
setIsPagePublic(value);
|
setIsPagePublic(value);
|
||||||
} else {
|
} else {
|
||||||
@ -92,26 +96,29 @@ export default function ShareModal({ readOnly }: ShareModalProps) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const shareLink = useMemo(() => (
|
const shareLink = useMemo(
|
||||||
<Group my="sm" gap={4} wrap="nowrap">
|
() => (
|
||||||
<TextInput
|
<Group my="sm" gap={4} wrap="nowrap">
|
||||||
variant="filled"
|
<TextInput
|
||||||
value={publicLink}
|
variant="filled"
|
||||||
readOnly
|
value={publicLink}
|
||||||
rightSection={<CopyTextButton text={publicLink} />}
|
readOnly
|
||||||
style={{ width: "100%" }}
|
rightSection={<CopyTextButton text={publicLink} />}
|
||||||
/>
|
style={{ width: "100%" }}
|
||||||
<ActionIcon
|
/>
|
||||||
component="a"
|
<ActionIcon
|
||||||
variant="default"
|
component="a"
|
||||||
target="_blank"
|
variant="default"
|
||||||
href={publicLink}
|
target="_blank"
|
||||||
size="sm"
|
href={publicLink}
|
||||||
>
|
size="sm"
|
||||||
<IconExternalLink size={16} />
|
>
|
||||||
</ActionIcon>
|
<IconExternalLink size={16} />
|
||||||
</Group>
|
</ActionIcon>
|
||||||
), [publicLink]);
|
</Group>
|
||||||
|
),
|
||||||
|
[publicLink],
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Popover width={350} position="bottom" withArrow shadow="md">
|
<Popover width={350} position="bottom" withArrow shadow="md">
|
||||||
@ -135,7 +142,28 @@ export default function ShareModal({ readOnly }: ShareModalProps) {
|
|||||||
</Button>
|
</Button>
|
||||||
</Popover.Target>
|
</Popover.Target>
|
||||||
<Popover.Dropdown style={{ userSelect: "none" }}>
|
<Popover.Dropdown style={{ userSelect: "none" }}>
|
||||||
{isDescendantShared ? (
|
{isCloud() && isTrial ? (
|
||||||
|
<>
|
||||||
|
<Group justify="center" mb="sm">
|
||||||
|
<IconLock size={20} stroke={1.5} />
|
||||||
|
</Group>
|
||||||
|
<Text size="sm" ta="center" fw={500} mb="xs">
|
||||||
|
{t("Upgrade to share pages")}
|
||||||
|
</Text>
|
||||||
|
<Text size="sm" c="dimmed" ta="center" mb="sm">
|
||||||
|
{t(
|
||||||
|
"Page sharing is available on paid plans. Upgrade to share your pages publicly.",
|
||||||
|
)}
|
||||||
|
</Text>
|
||||||
|
<Button
|
||||||
|
size="xs"
|
||||||
|
onClick={() => navigate("/settings/billing")}
|
||||||
|
fullWidth
|
||||||
|
>
|
||||||
|
{t("Upgrade Plan")}
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
|
) : isDescendantShared ? (
|
||||||
<>
|
<>
|
||||||
<Text size="sm">{t("Inherits public sharing from")}</Text>
|
<Text size="sm">{t("Inherits public sharing from")}</Text>
|
||||||
<Anchor
|
<Anchor
|
||||||
|
|||||||
Submodule apps/server/src/ee updated: fd34d4183a...bcc077ae3b
Reference in New Issue
Block a user