Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

refactor: group link options

Marc Seitz1078ca2e9572
diff --git a/components/links/link-sheet/index.tsx b/components/links/link-sheet/index.tsx
index e8e1c3a3..6af7b0e2 100644
--- a/components/links/link-sheet/index.tsx
+++ b/components/links/link-sheet/index.tsx
@@ -89,6 +89,8 @@ export const DEFAULT_LINK_PROPS = (
uploadFolderId: null,
uploadFolderName: "Home",
enableIndexFile: false,
+ permissions: {},
+ permissionGroupId: null,
});
export type DEFAULT_LINK_TYPE = {
@@ -129,6 +131,8 @@ export type DEFAULT_LINK_TYPE = {
uploadFolderId: string | null;
uploadFolderName: string;
enableIndexFile: boolean;
+ permissions?: any; // For dataroom links file permissions
+ permissionGroupId?: string | null;
};
export default function LinkSheet({
@@ -250,10 +254,8 @@ export default function LinkSheet({
enableAgreement: preset.enableAgreement || prev.enableAgreement,
agreementId: preset.agreementId || prev.agreementId,
enableScreenshotProtection:
- preset.enableScreenshotProtection ||
- prev.enableScreenshotProtection,
- enableNotification:
- !!preset.enableNotification,
+ preset.enableScreenshotProtection || prev.enableScreenshotProtection,
+ enableNotification: !!preset.enableNotification,
};
});
@@ -443,7 +445,7 @@ export default function LinkSheet({
return (
<Sheet open={isOpen} onOpenChange={(open: boolean) => setIsOpen(open)}>
- <SheetContent className="flex w-[90%] flex-col justify-between border-l border-gray-200 bg-background px-4 text-foreground dark:border-gray-800 dark:bg-gray-900 sm:w-[600px] sm:max-w-2xl md:px-5">
+ <SheetContent className="flex w-[90%] flex-col justify-between border-l border-gray-200 bg-background px-4 text-foreground dark:border-gray-800 dark:bg-gray-900 sm:w-[800px] sm:max-w-4xl md:px-5">
<SheetHeader className="text-start">
<SheetTitle>
{currentLink
diff --git a/components/links/link-sheet/link-options.tsx b/components/links/link-sheet/link-options.tsx
index 77b1db08..22e4ce55 100644
--- a/components/links/link-sheet/link-options.tsx
+++ b/components/links/link-sheet/link-options.tsx
@@ -3,9 +3,11 @@ import { useState } from "react";
import { PlanEnum } from "@/ee/stripe/constants";
import { LinkAudienceType, LinkType } from "@prisma/client";
import { LinkPreset } from "@prisma/client";
+import { ChevronDown } from "lucide-react";
import { usePlan } from "@/lib/swr/use-billing";
import useLimits from "@/lib/swr/use-limits";
+import { cn } from "@/lib/utils";
import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
import { DEFAULT_LINK_TYPE } from "@/components/links/link-sheet";
@@ -20,6 +22,11 @@ import FeedbackSection from "@/components/links/link-sheet/feedback-section";
import OGSection from "@/components/links/link-sheet/og-section";
import PasswordSection from "@/components/links/link-sheet/password-section";
import { ProBannerSection } from "@/components/links/link-sheet/pro-banner-section";
+import {
+ Collapsible,
+ CollapsibleContent,
+ CollapsibleTrigger,
+} from "@/components/ui/collapsible";
import AgreementSection from "./agreement-section";
import ConversationSection from "./conversation-section";
@@ -37,6 +44,36 @@ export type LinkUpgradeOptions = {
highlightItem?: string[];
};
+// Collapsible Section Component
+const CollapsibleSection = ({
+ title,
+ children,
+ defaultOpen = false,
+}: {
+ title: string;
+ children: React.ReactNode;
+ defaultOpen?: boolean;
+}) => {
+ const [isOpen, setIsOpen] = useState(defaultOpen);
+
+ return (
+ <Collapsible open={isOpen} onOpenChange={setIsOpen}>
+ <CollapsibleTrigger className="mb-5 flex w-full items-center justify-between rounded-t-md border-b border-border bg-muted/50 px-4 py-3 text-left text-sm font-medium transition-colors hover:bg-muted/70">
+ <span>{title}</span>
+ <ChevronDown
+ className={cn(
+ "h-4 w-4 transition-transform duration-200",
+ isOpen ? "rotate-180" : "",
+ )}
+ />
+ </CollapsibleTrigger>
+ <CollapsibleContent className="overflow-hidden data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down">
+ <div className="pt-2">{children}</div>
+ </CollapsibleContent>
+ </Collapsible>
+ );
+};
+
export const LinkOptions = ({
data,
setData,
@@ -87,41 +124,9 @@ export const LinkOptions = ({
return (
<div>
- <EmailProtectionSection {...{ data, setData }} />
+ {/* Basic Options - Always visible */}
<AllowNotificationSection {...{ data, setData }} />
- <AllowDownloadSection {...{ data, setData }} />
- <ExpirationSection {...{ data, setData }} presets={currentPreset} />
- {limits?.dataroomUpload &&
- linkType === LinkType.DATAROOM_LINK &&
- targetId ? (
- <UploadSection
- {...{ data, setData }}
- isAllowed={isTrial || isDatarooms || isDataroomsPlus}
- handleUpgradeStateChange={handleUpgradeStateChange}
- targetId={targetId}
- />
- ) : null}
- {linkType === LinkType.DATAROOM_LINK ? (
- <IndexFileSection
- {...{ data, setData }}
- isAllowed={isDataroomsPlus}
- handleUpgradeStateChange={handleUpgradeStateChange}
- />
- ) : null}
- <OGSection
- {...{ data, setData }}
- isAllowed={
- isTrial ||
- (isPro && allowAdvancedLinkControls) ||
- isBusiness ||
- isDatarooms ||
- isDataroomsPlus
- }
- handleUpgradeStateChange={handleUpgradeStateChange}
- editLink={editLink ?? false}
- presets={currentPreset}
- />
-
+ <EmailProtectionSection {...{ data, setData }} />
<EmailAuthenticationSection
{...{ data, setData }}
isAllowed={
@@ -133,36 +138,39 @@ export const LinkOptions = ({
}
handleUpgradeStateChange={handleUpgradeStateChange}
/>
+ <AllowDownloadSection {...{ data, setData }} />
+
{data.audienceType === LinkAudienceType.GENERAL ? (
- <AllowListSection
- {...{ data, setData }}
- isAllowed={
- isTrial ||
- (isPro && allowAdvancedLinkControls) ||
- isBusiness ||
- isDatarooms ||
- isDataroomsPlus
- }
- handleUpgradeStateChange={handleUpgradeStateChange}
- presets={currentPreset}
- />
- ) : null}
- {data.audienceType === LinkAudienceType.GENERAL ? (
- <DenyListSection
- {...{ data, setData }}
- isAllowed={
- isTrial ||
- (isPro && allowAdvancedLinkControls) ||
- isBusiness ||
- isDatarooms ||
- isDataroomsPlus
- }
- handleUpgradeStateChange={handleUpgradeStateChange}
- presets={currentPreset}
- />
+ <>
+ <AllowListSection
+ {...{ data, setData }}
+ isAllowed={
+ isTrial ||
+ (isPro && allowAdvancedLinkControls) ||
+ isBusiness ||
+ isDatarooms ||
+ isDataroomsPlus
+ }
+ handleUpgradeStateChange={handleUpgradeStateChange}
+ presets={currentPreset}
+ />
+ <DenyListSection
+ {...{ data, setData }}
+ isAllowed={
+ isTrial ||
+ (isPro && allowAdvancedLinkControls) ||
+ isBusiness ||
+ isDatarooms ||
+ isDataroomsPlus
+ }
+ handleUpgradeStateChange={handleUpgradeStateChange}
+ presets={currentPreset}
+ />
+ </>
) : null}
- <PasswordSection {...{ data, setData }} />
- <ScreenshotProtectionSection
+
+ {/* OG Section */}
+ <OGSection
{...{ data, setData }}
isAllowed={
isTrial ||
@@ -172,37 +180,16 @@ export const LinkOptions = ({
isDataroomsPlus
}
handleUpgradeStateChange={handleUpgradeStateChange}
- />
- <WatermarkSection
- {...{ data, setData }}
- isAllowed={
- isTrial || isDatarooms || isDataroomsPlus || allowWatermarkOnBusiness
- }
- handleUpgradeStateChange={handleUpgradeStateChange}
+ editLink={editLink ?? false}
presets={currentPreset}
/>
- <AgreementSection
- {...{ data, setData }}
- isAllowed={
- isTrial || isDatarooms || isDataroomsPlus || allowWatermarkOnBusiness
- }
- handleUpgradeStateChange={handleUpgradeStateChange}
- />
- {linkType === LinkType.DATAROOM_LINK &&
- limits?.conversationsInDataroom ? (
- <ConversationSection
- {...{ data, setData }}
- isAllowed={
- isDataroomsPlus ||
- ((isBusiness || isDatarooms) && limits?.conversationsInDataroom)
- }
- handleUpgradeStateChange={handleUpgradeStateChange}
- />
- ) : null}
- {linkType === LinkType.DOCUMENT_LINK ? (
- <>
- <FeedbackSection {...{ data, setData }} />
- <QuestionSection
+
+ {/* Security Section */}
+ <CollapsibleSection title="Security Controls" defaultOpen={true}>
+ <div>
+ <PasswordSection {...{ data, setData }} />
+ <ExpirationSection {...{ data, setData }} presets={currentPreset} />
+ <ScreenshotProtectionSection
{...{ data, setData }}
isAllowed={
isTrial ||
@@ -213,14 +200,89 @@ export const LinkOptions = ({
}
handleUpgradeStateChange={handleUpgradeStateChange}
/>
- </>
- ) : null}
- <CustomFieldsSection
- {...{ data, setData }}
- isAllowed={isTrial || isBusiness || isDatarooms || isDataroomsPlus}
- handleUpgradeStateChange={handleUpgradeStateChange}
- presets={currentPreset}
- />
+ <WatermarkSection
+ {...{ data, setData }}
+ isAllowed={
+ isTrial ||
+ isDatarooms ||
+ isDataroomsPlus ||
+ allowWatermarkOnBusiness
+ }
+ handleUpgradeStateChange={handleUpgradeStateChange}
+ presets={currentPreset}
+ />
+ <AgreementSection
+ {...{ data, setData }}
+ isAllowed={
+ isTrial ||
+ isDatarooms ||
+ isDataroomsPlus ||
+ allowWatermarkOnBusiness
+ }
+ handleUpgradeStateChange={handleUpgradeStateChange}
+ />
+ </div>
+ </CollapsibleSection>
+
+ {/* Advanced Section */}
+ <CollapsibleSection title="Advanced Controls" defaultOpen={true}>
+ <div>
+ {linkType === LinkType.DATAROOM_LINK && targetId ? (
+ <UploadSection
+ {...{ data, setData }}
+ isAllowed={isTrial || isDataroomsPlus}
+ handleUpgradeStateChange={handleUpgradeStateChange}
+ targetId={targetId}
+ />
+ ) : null}
+
+ {linkType === LinkType.DATAROOM_LINK ? (
+ <IndexFileSection
+ {...{ data, setData }}
+ isAllowed={isTrial || isDataroomsPlus}
+ handleUpgradeStateChange={handleUpgradeStateChange}
+ />
+ ) : null}
+
+ {linkType === LinkType.DATAROOM_LINK &&
+ limits?.conversationsInDataroom ? (
+ <ConversationSection
+ {...{ data, setData }}
+ isAllowed={
+ isDataroomsPlus ||
+ ((isBusiness || isDatarooms) && limits?.conversationsInDataroom)
+ }
+ handleUpgradeStateChange={handleUpgradeStateChange}
+ />
+ ) : null}
+
+ {linkType === LinkType.DOCUMENT_LINK ? (
+ <FeedbackSection {...{ data, setData }} />
+ ) : null}
+
+ {linkType === LinkType.DOCUMENT_LINK ? (
+ <QuestionSection
+ {...{ data, setData }}
+ isAllowed={
+ isTrial ||
+ (isPro && allowAdvancedLinkControls) ||
+ isBusiness ||
+ isDatarooms ||
+ isDataroomsPlus
+ }
+ handleUpgradeStateChange={handleUpgradeStateChange}
+ />
+ ) : null}
+
+ <CustomFieldsSection
+ {...{ data, setData }}
+ isAllowed={isTrial || isBusiness || isDatarooms || isDataroomsPlus}
+ handleUpgradeStateChange={handleUpgradeStateChange}
+ presets={currentPreset}
+ />
+ </div>
+ </CollapsibleSection>
+
{linkType === LinkType.DOCUMENT_LINK ? (
<ProBannerSection
{...{ data, setData }}
@@ -235,6 +297,7 @@ export const LinkOptions = ({
handleUpgradeStateChange={handleUpgradeStateChange}
/>
) : null}
+
<UpgradePlanModal
clickedPlan={upgradePlan}
open={openUpgradeModal}