Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
fix: disabled to create links & duplicate documents due to free version limit (#855)
JeevaRamanathan8b75c1004457
diff --git a/components/documents/document-card.tsx b/components/documents/document-card.tsxindex 2076a400..68d2e0ac 100644--- a/components/documents/document-card.tsx+++ b/components/documents/document-card.tsx@@ -5,7 +5,6 @@ import { useRouter } from "next/router";import { useEffect, useRef, useState } from "react";import { TeamContextType } from "@/context/team-context";-import { useLimits } from "@/ee/limits/swr-handler";import {BetweenHorizontalStartIcon,FolderInputIcon,@@ -33,6 +32,7 @@ import {import { usePlan } from "@/lib/swr/use-billing";import useDatarooms from "@/lib/swr/use-datarooms";+import useLimits from "@/lib/swr/use-limits";import { DocumentWithLinksAndLinkCountAndViewCount } from "@/lib/types";import { cn, nFormatter, timeAgo } from "@/lib/utils";import { fileIcon } from "@/lib/utils/get-file-icon";@@ -86,6 +86,7 @@ export default function DocumentsCard({isDatarooms || (isBusiness && numDatarooms < limitDatarooms);const dropdownRef = useRef<HTMLDivElement | null>(null);+ const { canAddDocuments } = useLimits();/** current folder name */const currentFolderPath = router.query.name as string[] | undefined;@@ -330,7 +331,10 @@ export default function DocumentsCard({<FolderInputIcon className="mr-2 h-4 w-4" />Move to folder</DropdownMenuItem>- <DropdownMenuItem onClick={(e) => handleDuplicateDocument(e)}>+ <DropdownMenuItem+ onClick={(e) => handleDuplicateDocument(e)}+ disabled={!canAddDocuments}+ ><Layers2Icon className="mr-2 h-4 w-4" />Duplicate document</DropdownMenuItem>@@ -375,7 +379,7 @@ export default function DocumentsCard({documentName={prismaDocument.name}/>) : null}-+{trialModalOpen ? (<DataroomTrialModalopenModal={trialModalOpen}diff --git a/components/links/links-table.tsx b/components/links/links-table.tsxindex 052230a2..3f4131a5 100644--- a/components/links/links-table.tsx+++ b/components/links/links-table.tsx@@ -7,7 +7,8 @@ import { DocumentVersion } from "@prisma/client";import { BoxesIcon, EyeIcon, LinkIcon, Settings2Icon } from "lucide-react";import { toast } from "sonner";import { mutate } from "swr";-+import useLimits from "@/lib/swr/use-limits";+import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";import { Button } from "@/components/ui/button";import {Collapsible,@@ -60,6 +61,8 @@ export default function LinksTable({const { plan } = usePlan();const teamInfo = useTeam();+ const { canAddLinks } = useLimits();+const [isLoading, setIsLoading] = useState<boolean>(false);const [isLinkSheetVisible, setIsLinkSheetVisible] = useState<boolean>(false);const [selectedLink, setSelectedLink] = useState<DEFAULT_LINK_TYPE>(@@ -171,6 +174,24 @@ export default function LinksTable({setIsLoading(false);};+ const AddLinkButton = () => {+ if (!canAddLinks) {+ return (+ <UpgradePlanModal clickedPlan="Pro" trigger={"limit_add_link"}>+ <Button>+ Upgrade to Create Link+ </Button>+ </UpgradePlanModal>+ );+ } else {+ return (+ <Button onClick={() => setIsLinkSheetVisible(true)}>+ Create link to share+ </Button>+ );+ }+ };+const handleArchiveLink = async (linkId: string,targetId: string,@@ -391,6 +412,7 @@ export default function LinksTable({Edit Link</DropdownMenuItem><DropdownMenuItem+ disabled={!canAddLinks}onClick={() => handleDuplicateLink(link)}>Duplicate Link@@ -434,9 +456,7 @@ export default function LinksTable({</div></div><p>No links found for this {targetType.toLowerCase()}</p>- <Button onClick={() => setIsLinkSheetVisible(true)}>- Create link to share- </Button>+ <AddLinkButton/></div></TableCell></TableRow>