Skip to content

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

feat: modal update

Iuliia Shnaie03809c6ca96
diff --git a/components/layouts/mobile-dataroom-more-menu.tsx b/components/layouts/mobile-dataroom-more-menu.tsx
index b3ce0f33..95b5a932 100644
--- a/components/layouts/mobile-dataroom-more-menu.tsx
+++ b/components/layouts/mobile-dataroom-more-menu.tsx
@@ -191,7 +191,7 @@ export function MobileDataroomMoreMenu({
>
<span className="flex items-center gap-2">
<LinkIcon className="h-4 w-4 shrink-0" />
- Links
+ Access links
</span>
</Link>
<Link
diff --git a/components/links/link-sheet/access-preview-message.ts b/components/links/link-sheet/access-preview-message.ts
new file mode 100644
index 00000000..d827c918
--- /dev/null
+++ b/components/links/link-sheet/access-preview-message.ts
@@ -0,0 +1,24 @@
+/**
+ * Shared contract for the postMessage channel between the access-screen editor
+ * (`access-screen-preview.tsx`) and the preview iframe page
+ * (`pages/custom_fields_ppreview_demo.tsx`). Kept dependency-free so neither
+ * side pulls the other's bundle in.
+ */
+export const ACCESS_PREVIEW_MESSAGE = "papermark:access-preview" as const;
+export const ACCESS_PREVIEW_READY = "papermark:access-preview-ready" as const;
+
+export type AccessPreviewField = {
+ type: string;
+ identifier: string;
+ label: string;
+ placeholder?: string | null;
+ required?: boolean;
+};
+
+export type AccessPreviewPayload = {
+ requireEmail: boolean;
+ requirePassword: boolean;
+ requireAgreement: boolean;
+ welcomeMessage: string;
+ fields: AccessPreviewField[];
+};
diff --git a/components/links/link-sheet/access-screen-preview.tsx b/components/links/link-sheet/access-screen-preview.tsx
new file mode 100644
index 00000000..9916a9f5
--- /dev/null
+++ b/components/links/link-sheet/access-screen-preview.tsx
@@ -0,0 +1,164 @@
+import { useEffect, useMemo, useRef, useState } from "react";
+
+import {
+ ACCESS_PREVIEW_MESSAGE,
+ ACCESS_PREVIEW_READY,
+ type AccessPreviewPayload,
+} from "./access-preview-message";
+import { CustomFieldData } from "./custom-fields-panel";
+
+export default function AccessScreenPreview({
+ fields = [],
+ requireEmail = true,
+ requirePassword = false,
+ requireAgreement = false,
+ welcomeMessage,
+ height = 450,
+}: {
+ fields?: CustomFieldData[];
+ requireEmail?: boolean;
+ requirePassword?: boolean;
+ requireAgreement?: boolean;
+ welcomeMessage?: string | null;
+ height?: number;
+}) {
+ const payload = useMemo<AccessPreviewPayload>(
+ () => ({
+ requireEmail,
+ requirePassword,
+ requireAgreement,
+ welcomeMessage: welcomeMessage || "",
+ fields: fields.map((field, index) => ({
+ type: field.type || "SHORT_TEXT",
+ identifier: field.identifier || `field-${index}`,
+ label: field.label?.trim() || "Field label",
+ placeholder: field.placeholder,
+ required: field.required,
+ })),
+ }),
+ [fields, requireEmail, requirePassword, requireAgreement, welcomeMessage],
+ );
+
+ // The iframe is mounted once with the initial state baked into the URL (so
+ // the first paint is already correct). Every later edit is streamed in over
+ // postMessage instead of reloading the route — no reload means no flash.
+ const [initialSrc] = useState(() => {
+ const params = new URLSearchParams({
+ requireEmail: String(payload.requireEmail),
+ requirePassword: String(payload.requirePassword),
+ requireAgreement: String(payload.requireAgreement),
+ welcomeMessage: payload.welcomeMessage,
+ fields: JSON.stringify(payload.fields),
+ });
+ return `/custom_fields_ppreview_demo?${params.toString()}`;
+ });
+
+ const iframeRef = useRef<HTMLIFrameElement>(null);
+ const readyRef = useRef(false);
+ // Always post the freshest payload without re-subscribing the listener.
+ const payloadRef = useRef(payload);
+ payloadRef.current = payload;
+
+ useEffect(() => {
+ const post = () => {
+ iframeRef.current?.contentWindow?.postMessage(
+ { type: ACCESS_PREVIEW_MESSAGE, payload: payloadRef.current },
+ window.location.origin,
+ );
+ };
+
+ const onMessage = (event: MessageEvent) => {
+ if (event.origin !== window.location.origin) return;
+ if (event.data?.type !== ACCESS_PREVIEW_READY) return;
+ readyRef.current = true;
+ post();
+ };
+
+ window.addEventListener("message", onMessage);
+ return () => window.removeEventListener("message", onMessage);
+ }, []);
+
+ // Stream subsequent edits once the preview has announced it is listening.
+ useEffect(() => {
+ if (!readyRef.current) return;
+ iframeRef.current?.contentWindow?.postMessage(
+ { type: ACCESS_PREVIEW_MESSAGE, payload },
+ window.location.origin,
+ );
+ }, [payload]);
+
+ return (
+ <div className="flex h-full flex-col">
+ <p className="mb-3 text-sm font-medium text-foreground">Preview</p>
+ <div className="flex justify-center">
+ <div
+ className="relative w-full max-w-[698px] rounded-lg bg-gray-200 p-1 shadow-lg"
+ style={{ height }}
+ >
+ <div className="relative flex h-full flex-col overflow-hidden rounded-lg bg-gray-100">
+ {/* Browser chrome */}
+ <div className="mx-auto flex h-7 shrink-0 items-center justify-center">
+ <div className="pointer-events-none absolute left-3">
+ <div className="flex flex-row flex-nowrap justify-start">
+ <div className="pointer-events-auto">
+ <div className="mr-1 inline-block size-2 rounded-full bg-gray-300"></div>
+ </div>
+ <div className="pointer-events-auto">
+ <div className="mr-1 inline-block size-2 rounded-full bg-gray-300"></div>
+ </div>
+ <div className="pointer-events-auto">
+ <div className="mr-1 inline-block size-2 rounded-full bg-gray-300"></div>
+ </div>
+ </div>
+ </div>
+ <div className="flex items-center justify-center rounded-xl bg-white p-1 px-2 opacity-70">
+ <div
+ aria-hidden="true"
+ className="mr-1 mt-0.5 flex text-muted-foreground"
+ >
+ <svg
+ aria-hidden="true"
+ height="8"
+ width="8"
+ viewBox="0 0 16 16"
+ fill="currentColor"
+ xmlns="http://www.w3.org/2000/svg"
+ >
+ <path d="M8.75 11.25a1.25 1.25 0 1 0-1.5 0v1a.75.75 0 0 0 1.5 0v-1Z"></path>
+ <path
+ fillRule="evenodd"
+ clipRule="evenodd"
+ d="M3.5 4v2h-1a1 1 0 0 0-1 1v6a3 3 0 0 0 3 3h7a3 3 0 0 0 3-3V7a1 1 0 0 0-1-1h-1V4a4 4 0 0 0-4-4h-1a4 4 0 0 0-4 4ZM11 6V4a2.5 2.5 0 0 0-2.5-2.5h-1A2.5 2.5 0 0 0 5 4v2h6Zm-8 7V7.5h10V13a1.5 1.5 0 0 1-1.5 1.5h-7A1.5 1.5 0 0 1 3 13Z"
+ ></path>
+ </svg>
+ </div>
+ <span className="whitespace-normal text-xs text-muted-foreground">
+ papermark.com/view/...
+ </span>
+ </div>
+ </div>
+
+ {/* Scaled front-page iframe */}
+ <div className="relative min-h-0 flex-1 overflow-x-auto">
+ <div className="relative h-full max-w-[1396px]">
+ <iframe
+ ref={iframeRef}
+ name="access-screen-preview"
+ id="access-screen-preview"
+ src={initialSrc}
+ sandbox="allow-scripts allow-same-origin"
+ className="absolute left-0 top-0 h-full w-full origin-top-left scale-50 overflow-hidden rounded-b-lg border-0 bg-white"
+ style={{
+ width: "200%",
+ height: "200%",
+ pointerEvents: "none",
+ }}
+ />
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/components/links/link-sheet/agreement-section.tsx b/components/links/link-sheet/agreement-section.tsx
index 02ec01dc..679cdc87 100644
--- a/components/links/link-sheet/agreement-section.tsx
+++ b/components/links/link-sheet/agreement-section.tsx
@@ -125,7 +125,7 @@ export default function AgreementSection({
return (
<div className="pb-5">
<LinkItem
- title="Require NDA to view"
+ title="NDA agreement"
link="https://www.papermark.com/help/article/require-nda-to-view"
tooltipContent="Users must acknowledge an agreement to access the content."
enabled={enabled}
diff --git a/components/links/link-sheet/ai-agents-section.tsx b/components/links/link-sheet/ai-agents-section.tsx
index 7690566f..b1ee05ba 100644
--- a/components/links/link-sheet/ai-agents-section.tsx
+++ b/components/links/link-sheet/ai-agents-section.tsx
@@ -50,7 +50,7 @@ export default function AIAgentsSection({
return (
<div className="pb-5">
<LinkItem
- title="AI Agents"
+ title="AI agents"
enabled={enabled}
action={handleToggle}
isAllowed={isAllowed}
diff --git a/components/links/link-sheet/allow-block-list-section.tsx b/components/links/link-sheet/allow-block-list-section.tsx
new file mode 100644
index 00000000..37cc96fd
--- /dev/null
+++ b/components/links/link-sheet/allow-block-list-section.tsx
@@ -0,0 +1,385 @@
+import { useEffect, useMemo, useState } from "react";
+
+import { LinkPreset } from "@prisma/client";
+import { CheckIcon, UsersIcon, XIcon } from "lucide-react";
+import { motion } from "motion/react";
+
+import { FADE_IN_ANIMATION_SETTINGS } from "@/lib/constants";
+import useVisitorGroups from "@/lib/swr/use-visitor-groups";
+import { validateList } from "@/lib/utils";
+
+import { Badge } from "@/components/ui/badge";
+import { Button } from "@/components/ui/button";
+import {
+ Popover,
+ PopoverContent,
+ PopoverTrigger,
+} from "@/components/ui/popover";
+import { Textarea } from "@/components/ui/textarea";
+
+import { DEFAULT_LINK_TYPE } from ".";
+import LinkItem from "./link-item";
+import { LinkUpgradeOptions } from "./link-options";
+
+/**
+ * Combines the "Allow specified viewers" and "Block specified viewers" controls
+ * behind a single toggle. When enabled, both the allow list (with visitor
+ * groups) and the block list inputs are shown, preserving the existing ability
+ * to configure either or both at once.
+ */
+export default function AllowBlockListSection({
+ data,
+ setData,
+ isAllowed,
+ handleUpgradeStateChange,
+ presets,
+ setValidationError,
+}: {
+ data: DEFAULT_LINK_TYPE;
+ setData: React.Dispatch<React.SetStateAction<DEFAULT_LINK_TYPE>>;
+ isAllowed: boolean;
+ handleUpgradeStateChange: ({
+ state,
+ trigger,
+ plan,
+ highlightItem,
+ }: LinkUpgradeOptions) => void;
+ presets: LinkPreset | null;
+ setValidationError?: (key: string, errors: string[]) => void;
+}) {
+ const { emailProtected, allowList, denyList, visitorGroupIds } = data;
+ const { visitorGroups } = useVisitorGroups();
+
+ const [enabled, setEnabled] = useState<boolean>(
+ (!!allowList && allowList.length > 0) ||
+ (!!visitorGroupIds && visitorGroupIds.length > 0) ||
+ (!!denyList && denyList.length > 0),
+ );
+ const [allowListInput, setAllowListInput] = useState<string>(
+ allowList?.join("\n") || "",
+ );
+ const [denyListInput, setDenyListInput] = useState<string>(
+ denyList?.join("\n") || "",
+ );
+
+ const allowValidation = useMemo(
+ () => validateList(allowListInput, "both"),
+ [allowListInput],
+ );
+ const denyValidation = useMemo(
+ () => validateList(denyListInput, "both"),
+ [denyListInput],
+ );
+
+ useEffect(() => {
+ if (!setValidationError) return;
+ if (enabled && emailProtected) {
+ setValidationError("allowList", allowValidation.invalid);
+ setValidationError("denyList", denyValidation.invalid);
+ } else {
+ setValidationError("allowList", []);
+ setValidationError("denyList", []);
+ }
+ }, [
+ enabled,
+ emailProtected,
+ allowValidation.invalid,
+ denyValidation.invalid,
+ setValidationError,
+ ]);
+
+ useEffect(() => {
+ return () => {
+ setValidationError?.("allowList", []);
+ setValidationError?.("denyList", []);
+ };
+ }, [setValidationError]);
+
+ useEffect(() => {
+ if (!emailProtected && enabled) {
+ setEnabled(false);
+ setData((prevData) => ({
+ ...prevData,
+ allowList: [],
+ visitorGroupIds: [],
+ denyList: [],
+ }));
+ }
+ }, [emailProtected, enabled, setData]);
+
+ useEffect(() => {
+ if (!isAllowed) return;
+ const hasAllowPreset = !!presets?.allowList && presets.allowList.length > 0;
+ const hasDenyPreset = !!presets?.denyList && presets.denyList.length > 0;
+ if (hasAllowPreset || hasDenyPreset) {
+ setEnabled(true);
+ if (hasAllowPreset) setAllowListInput(presets!.allowList!.join("\n"));
+ if (hasDenyPreset) setDenyListInput(presets!.denyList!.join("\n"));
+ }
+ }, [presets, isAllowed]);
+
+ const handleEnable = () => {
+ const updatedEnabled = !enabled;
+ setEnabled(updatedEnabled);
+
+ if (updatedEnabled) {
+ setData((prevData) => ({
+ ...prevData,
+ allowList: validateList(allowListInput).valid,
+ denyList: validateList(denyListInput).valid,
+ emailAuthenticated: true, // Turn on email authentication
+ emailProtected: true, // Turn on email protection
+ }));
+ } else {
+ setData((prevData) => ({
+ ...prevData,
+ allowList: [],
+ visitorGroupIds: [],
+ denyList: [],
+ }));
+ }
+ };
+
+ const handleAllowListChange = (
+ event: React.ChangeEvent<HTMLTextAreaElement>,
+ ) => {
+ const updated = event.target.value;
+ setAllowListInput(updated);
+ if (emailProtected && enabled) {
+ setData((prevData) => ({
+ ...prevData,
+ allowList: validateList(updated).valid,
+ }));
+ }
+ };
+
+ const handleDenyListChange = (
+ event: React.ChangeEvent<HTMLTextAreaElement>,
+ ) => {
+ const updated = event.target.value;
+ setDenyListInput(updated);
+ if (emailProtected && enabled) {
+ setData((prevData) => ({
+ ...prevData,
+ denyList: validateList(updated).valid,
+ }));
+ }
+ };
+
+ const toggleVisitorGroup = (groupId: string) => {
+ setData((prevData) => {
+ const currentIds = prevData.visitorGroupIds || [];
+ const newIds = currentIds.includes(groupId)
+ ? currentIds.filter((id) => id !== groupId)
+ : [...currentIds, groupId];
+ return { ...prevData, visitorGroupIds: newIds };
+ });
+ };
+
+ const removeVisitorGroup = (groupId: string) => {
+ setData((prevData) => ({
+ ...prevData,
+ visitorGroupIds: (prevData.visitorGroupIds || []).filter(
+ (id) => id !== groupId,
+ ),
+ }));
+ };
+
+ const selectedGroups =
+ visitorGroups?.filter((g) => visitorGroupIds?.includes(g.id)) || [];
+
+ return (
+ <div className="pb-5">
+ <div className="flex flex-col space-y-4">
+ <LinkItem
+ title="Allow & block list"
+ link="https://www.papermark.com/help/article/allow-list"
+ tooltipContent={`Restrict access by allowing or blocking specific viewers. Enter emails or domains${visitorGroups && visitorGroups.length > 0 ? ", or select visitor groups" : ""}.`}
+ enabled={enabled}
+ isAllowed={isAllowed}
+ action={handleEnable}
+ requiredPlan="business"
+ upgradeAction={() =>
+ handleUpgradeStateChange({
+ state: true,
+ trigger: "link_sheet_allow_block_section",
+ plan: "Business",
+ highlightItem: ["allow-block"],
+ })
+ }
+ />
+
+ {enabled && (
+ <motion.div
+ className="mt-1 block w-full space-y-5"
+ {...FADE_IN_ANIMATION_SETTINGS}
+ >
+ {/* Allow list */}
+ <div className="space-y-3">
+ <span className="text-xs font-medium text-foreground">
+ Allow specified viewers
+ </span>
+
+ {/* Visitor Groups Selector */}
+ {visitorGroups && visitorGroups.length > 0 && (
+ <div>
+ <div className="mb-1.5 flex items-center gap-1.5">
+ <UsersIcon className="h-3.5 w-3.5 text-muted-foreground" />
+ <span className="text-xs font-medium text-muted-foreground">
+ Visitor Groups
+ </span>
+ </div>
+
+ {selectedGroups.length > 0 && (
+ <div className="mb-2 flex flex-wrap gap-1.5">
+ {selectedGroups.map((group) => (
+ <Badge
+ key={group.id}
+ variant="secondary"
+ className="gap-1 pr-1"
+ >
+ {group.name}
+ <span className="text-muted-foreground">
+ ({group.emails.length})
+ </span>
+ <button
+ type="button"
+ onClick={() => removeVisitorGroup(group.id)}
+ className="ml-0.5 rounded-full p-0.5 hover:bg-muted"
+ >
+ <XIcon className="h-3 w-3" />
+ </button>
+ </Badge>
+ ))}
+ </div>
+ )}
+
+ <Popover>
+ <PopoverTrigger asChild>
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ className="w-full justify-start text-muted-foreground"
+ >
+ <UsersIcon className="mr-2 h-3.5 w-3.5" />
+ {selectedGroups.length > 0
+ ? `${selectedGroups.length} group${selectedGroups.length > 1 ? "s" : ""} selected`
+ : "Select visitor groups..."}
+ </Button>
+ </PopoverTrigger>
+ <PopoverContent className="w-72 p-1" align="start">
+ <div className="max-h-60 overflow-y-auto">
+ {visitorGroups.map((group) => {
+ const isSelected = visitorGroupIds?.includes(
+ group.id,
+ );
+ return (
+ <button
+ key={group.id}
+ type="button"
+ className="flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm hover:bg-muted"
+ onClick={() => toggleVisitorGroup(group.id)}
+ >
+ <div
+ className={`flex h-4 w-4 items-center justify-center rounded-sm border ${
+ isSelected
+ ? "border-primary bg-primary text-primary-foreground"
+ : "border-muted-foreground/30"
+ }`}
+ >
+ {isSelected && (
+ <CheckIcon className="h-3 w-3" />
+ )}
+ </div>
+ <div className="min-w-0 flex-1">
+ <div className="truncate font-medium">
+ {group.name}
+ </div>
+ <div className="text-xs text-muted-foreground">
+ {group.emails.length}{" "}
+ {group.emails.length === 1
+ ? "entry"
+ : "entries"}
+ </div>
+ </div>
+ </button>
+ );
+ })}
+ </div>
+ </PopoverContent>
+ </Popover>
+
+ <div className="my-2 flex items-center gap-2">
+ <div className="h-px flex-1 bg-border" />
+ <span className="text-xs text-muted-foreground">
+ plus individual emails
+ </span>
+ <div className="h-px flex-1 bg-border" />
+ </div>
+ </div>
+ )}
+
+ <Textarea
+ className="focus:ring-inset"
+ rows={5}
+ placeholder={`Enter allowed emails/domains separated by comma, semicolon, or new line, e.g.
+ value={allowListInput}
+ onChange={handleAllowListChange}
+ aria-invalid={allowValidation.invalid.length > 0}
+ />
+ {allowValidation.invalid.length > 0 ? (
+ <p className="text-xs text-destructive">
+ The following entries are not valid emails or domains and must
+ be fixed before saving:{" "}
+ <span className="font-medium">
+ {allowValidation.invalid.slice(0, 5).join(", ")}
+ {allowValidation.invalid.length > 5
+ ? `, and ${allowValidation.invalid.length - 5} more`
+ : ""}
+ </span>
+ </p>
+ ) : null}
+ </div>
+
+ {/* Block list */}
+ <div className="space-y-3">
+ <span className="text-xs font-medium text-foreground">
+ Block specified viewers
+ </span>
+ <Textarea
+ className="focus:ring-inset"
+ rows={5}
+ placeholder={`Enter blocked emails/domains separated by comma, semicolon, or new line, e.g.
+ value={denyListInput}
+ onChange={handleDenyListChange}
+ aria-invalid={denyValidation.invalid.length > 0}
+ />
+ {denyValidation.invalid.length > 0 ? (
+ <p className="text-xs text-destructive">
+ The following entries are not valid emails or domains and must
+ be fixed before saving:{" "}
+ <span className="font-medium">
+ {denyValidation.invalid.slice(0, 5).join(", ")}
+ {denyValidation.invalid.length > 5
+ ? `, and ${denyValidation.invalid.length - 5} more`
+ : ""}
+ </span>
+ </p>
+ ) : null}
+ </div>
+
+ <p className="text-xs text-muted-foreground">
+ Separate multiple entries with a comma, semicolon, or new line.
+ Use <code>@example.org</code> to match a whole domain.
+ </p>
+ </motion.div>
+ )}
+ </div>
+ </div>
+ );
+}
diff --git a/components/links/link-sheet/allow-download-section.tsx b/components/links/link-sheet/allow-download-section.tsx
index 7c5c694a..790c2a8a 100644
--- a/components/links/link-sheet/allow-download-section.tsx
+++ b/components/links/link-sheet/allow-download-section.tsx
@@ -26,7 +26,7 @@ export default function AllowDownloadSection({
return (
<div className="pb-5">
<LinkItem
- title="Allow downloading"
+ title="Download permissions"
enabled={enabled}
link="https://www.papermark.com/help/article/link-settings"
action={handleAllowDownload}
diff --git a/components/links/link-sheet/allow-notification-section.tsx b/components/links/link-sheet/allow-notification-section.tsx
index 3c9bc9a3..24718e1b 100644
--- a/components/links/link-sheet/allow-notification-section.tsx
+++ b/components/links/link-sheet/allow-notification-section.tsx
@@ -1,14 +1,20 @@
import { useEffect, useState } from "react";
+import { cn } from "@/lib/utils";
+
import { DEFAULT_LINK_TYPE } from ".";
import LinkItem from "./link-item";
export default function AllowNotificationSection({
data,
setData,
+ title = "Receive email notification",
+ className = "pb-5",
}: {
data: DEFAULT_LINK_TYPE;
setData: React.Dispatch<React.SetStateAction<DEFAULT_LINK_TYPE>>;
+ title?: string;
+ className?: string;
}) {
const { enableNotification } = data;
const [enabled, setEnabled] = useState<boolean>(true);
@@ -24,9 +30,9 @@ export default function AllowNotificationSection({
};
return (
- <div className="pb-5">
+ <div className={cn(className)}>
<LinkItem
- title="Receive email notification"
+ title={title}
link="https://www.papermark.com/help/article/link-settings"
enabled={enabled}
action={handleEnableNotification}
diff --git a/components/links/link-sheet/custom-fields-panel/index.tsx b/components/links/link-sheet/custom-fields-panel/index.tsx
index 3d89044f..e002520d 100644
--- a/components/links/link-sheet/custom-fields-panel/index.tsx
+++ b/components/links/link-sheet/custom-fields-panel/index.tsx
@@ -17,6 +17,7 @@ import {
SheetTitle,
} from "@/components/ui/sheet";
+import AccessScreenPreview from "../access-screen-preview";
import CustomFieldComponent from "./custom-field";
export type CustomFieldData = Omit<
@@ -31,11 +32,19 @@ export default function CustomFieldsPanel({
onChange,
isConfigOpen,
setIsConfigOpen,
+ requireEmail,
+ requirePassword,
+ requireAgreement,
+ welcomeMessage,
}: {
fields: CustomFieldData[];
onChange: (fields: CustomFieldData[]) => void;
isConfigOpen: boolean;
setIsConfigOpen: (open: boolean) => void;
+ requireEmail?: boolean;
+ requirePassword?: boolean;
+ requireAgreement?: boolean;
+ welcomeMessage?: string | null;
}) {
const { limits } = useLimits();
@@ -109,7 +118,7 @@ export default function CustomFieldsPanel({
return (
<Sheet open={isConfigOpen} onOpenChange={setIsConfigOpen}>
- <SheetContent className="flex h-full flex-col">
+ <SheetContent className="flex h-full flex-col sm:max-w-6xl">
<SheetHeader>
<SheetTitle>Configure Custom Form Fields</SheetTitle>
<SheetDescription>
@@ -123,41 +132,62 @@ export default function CustomFieldsPanel({
</SheetDescription>
</SheetHeader>
- <div className="flex items-center justify-between">
- <div className="text-sm text-muted-foreground">
- {fields.length} of {fieldLimit} custom field
- {fields.length === 1 ? "" : "s"}
+ <div className="flex min-h-0 flex-1 flex-col gap-6 lg:flex-row lg:gap-8">
+ {/* Config column */}
+ <div className="flex min-h-0 flex-1 flex-col gap-4 lg:w-[360px] lg:flex-none">
+ <div className="flex items-center justify-between">
+ <div className="text-sm text-muted-foreground">
+ {fields.length} of {fieldLimit} custom field
+ {fields.length === 1 ? "" : "s"}
+ </div>
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={addField}
+ className="flex items-center gap-2"
+ disabled={fields.length >= fieldLimit}
+ >
+ <Plus className="h-4 w-4" />
+ Add Field
+ </Button>
+ </div>
+
+ <Separator />
+
+ <ScrollArea className="min-h-0 flex-1 lg:pr-4">
+ <div className="space-y-4">
+ {fields.map((field, index) => (
+ <CustomFieldComponent
+ key={index}
+ field={field}
+ onUpdate={(updatedField) =>
+ updateField(index, updatedField)
+ }
+ onDelete={() => removeField(index)}
+ onMoveUp={() => moveField(index, "up")}
+ onMoveDown={() => moveField(index, "down")}
+ isFirst={index === 0}
+ isLast={index === fields.length - 1}
+ />
+ ))}
+ </div>
+ </ScrollArea>
</div>
- <Button
- variant="outline"
- size="sm"
- onClick={addField}
- className="flex items-center gap-2"
- disabled={fields.length >= fieldLimit}
- >
- <Plus className="h-4 w-4" />
- Add Field
- </Button>
- </div>
- <Separator />
-
- <ScrollArea className="flex-1">
- <div className="space-y-4">
- {fields.map((field, index) => (
- <CustomFieldComponent
- key={index}
- field={field}
- onUpdate={(updatedField) => updateField(index, updatedField)}
- onDelete={() => removeField(index)}
- onMoveUp={() => moveField(index, "up")}
- onMoveDown={() => moveField(index, "down")}
- isFirst={index === 0}
- isLast={index === fields.length - 1}
- />
- ))}
+ {/* Separator */}
+ <div className="hidden lg:block lg:w-px lg:self-stretch lg:bg-border" />
+
+ {/* Preview column */}
+ <div className="min-h-0 flex-1 overflow-y-auto lg:pl-2">
+ <AccessScreenPreview
+ fields={fields}
+ requireEmail={requireEmail}
+ requirePassword={requirePassword}
+ requireAgreement={requireAgreement}
+ welcomeMessage={welcomeMessage}
+ />
</div>
- </ScrollArea>
+ </div>
</SheetContent>
</Sheet>
);
diff --git a/components/links/link-sheet/custom-fields-section.tsx b/components/links/link-sheet/custom-fields-section.tsx
index 80d3e12c..be269b4e 100644
--- a/components/links/link-sheet/custom-fields-section.tsx
+++ b/components/links/link-sheet/custom-fields-section.tsx
@@ -89,7 +89,7 @@ export default function CustomFieldsSection({
return (
<div className="pb-5">
<LinkItem
- title="Custom Form Fields"
+ title="Custom form fields"
tooltipContent="Add custom fields to collect additional information from viewers"
link="https://www.papermark.com/help/article/custom-fields"
enabled={enabled}
@@ -146,6 +146,10 @@ export default function CustomFieldsSection({
onChange={handleConfigSave}
isConfigOpen={isConfigOpen}
setIsConfigOpen={setIsConfigOpen}
+ requireEmail={data.emailProtected}
+ requirePassword={!!data.password}
+ requireAgreement={data.enableAgreement}
+ welcomeMessage={data.welcomeMessage}
/>
</div>
);
diff --git a/components/links/link-sheet/email-access-section.tsx b/components/links/link-sheet/email-access-section.tsx
new file mode 100644
index 00000000..087ff810
--- /dev/null
+++ b/components/links/link-sheet/email-access-section.tsx
@@ -0,0 +1,143 @@
+import { CircleHelpIcon } from "lucide-react";
+
+import PlanBadge from "@/components/billing/plan-badge";
+import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
+import { BadgeTooltip } from "@/components/ui/tooltip";
+
+import { DEFAULT_LINK_TYPE } from ".";
+import { LinkUpgradeOptions } from "./link-options";
+
+type EmailAccessLevel = "none" | "email" | "verified";
+
+const SEGMENTS: {
+ value: EmailAccessLevel;
+ label: string;
+ gated?: boolean;
+ tooltip: string;
+}[] = [
+ {
+ value: "none",
+ label: "No email",
+ tooltip: "Data room visitors can open the link without entering an email.",
+ },
+ {
+ value: "email",
+ label: "Email",
+ tooltip: "Data room visitors must enter their email before viewing.",
+ },
+ {
+ value: "verified",
+ label: "Verified email",
+ gated: true,
+ tooltip:
+ "Data room visitors must enter their email and confirm it with a one-time verification code.",
+ },
+];
+
+export default function EmailAccessSection({
+ data,
+ setData,
+ isAllowed,
+ handleUpgradeStateChange,
+}: {
+ data: DEFAULT_LINK_TYPE;
+ setData: React.Dispatch<React.SetStateAction<DEFAULT_LINK_TYPE>>;
+ isAllowed: boolean;
+ handleUpgradeStateChange: ({
+ state,
+ trigger,
+ plan,
+ highlightItem,
+ }: LinkUpgradeOptions) => void;
+}) {
+ const level: EmailAccessLevel = data.emailAuthenticated
+ ? "verified"
+ : data.emailProtected
+ ? "email"
+ : "none";
+
+ const handleSelect = (next: EmailAccessLevel) => {
+ if (next === level) return;
+
+ // Verified email requires a paid plan
+ if (next === "verified" && !isAllowed) {
+ handleUpgradeStateChange({
+ state: true,
+ trigger: "link_sheet_email_auth_section",
+ plan: "Business",
+ highlightItem: ["email-verify"],
+ });
+ return;
+ }
+
+ setData((prev) => {
+ if (next === "none") {
+ return {
+ ...prev,
+ emailProtected: false,
+ emailAuthenticated: false,
+ enableConversation: false,
+ enableAgreement: false,
+ allowList: [],
+ denyList: [],
+ };
+ }
+
+ if (next === "email") {
+ return {
+ ...prev,
+ emailProtected: true,
+ emailAuthenticated: false,
+ // Conversations require a verified email
+ enableConversation: false,
+ };
+ }
+
+ // verified
+ return {
+ ...prev,
+ emailProtected: true,
+ emailAuthenticated: true,
+ };
+ });
+ };
+
+ return (
+ <div className="pb-3">
+ <div className="flex flex-wrap items-center justify-between gap-x-2 gap-y-2">
+ <h2 className="flex flex-1 flex-row items-center gap-2 text-sm font-medium leading-6 text-foreground">
+ <span>Identity verification</span>
+ <BadgeTooltip
+ content="Control whether data room visitors must enter an email, and whether it must be verified with a one-time code."
+ key="email_access_tooltip"
+ link="https://www.papermark.com/help/article/require-email-to-view-document"
+ >
+ <CircleHelpIcon className="h-4 w-4 shrink-0 text-muted-foreground hover:text-foreground" />
+ </BadgeTooltip>
+ </h2>
+
+ <Tabs
+ value={level}
+ onValueChange={(value) => handleSelect(value as EmailAccessLevel)}
+ >
+ <TabsList className="px-1">
+ {SEGMENTS.map((segment) => {
+ const showBadge = segment.gated && !isAllowed;
+
+ return (
+ <BadgeTooltip content={segment.tooltip} key={segment.value}>
+ <span className="inline-flex">
+ <TabsTrigger value={segment.value} className="gap-1 px-6">
+ <span>{segment.label}</span>
+ {showBadge ? <PlanBadge plan="business" /> : null}
+ </TabsTrigger>
+ </span>
+ </BadgeTooltip>
+ );
+ })}
+ </TabsList>
+ </Tabs>
+ </div>
+ </div>
+ );
+}
diff --git a/components/links/link-sheet/expiration-section.tsx b/components/links/link-sheet/expiration-section.tsx
index 5f2ca5f1..6655118d 100644
--- a/components/links/link-sheet/expiration-section.tsx
+++ b/components/links/link-sheet/expiration-section.tsx
@@ -122,7 +122,7 @@ export default function ExpirationSection({
return (
<div className="pb-5">
<LinkItem
- title="Expiration Date"
+ title="Expiration date"
enabled={enabled}
link="https://www.papermark.com/help/article/expiration-date"
action={handleEnableExpiration}
diff --git a/components/links/link-sheet/expirationIn-section.tsx b/components/links/link-sheet/expirationIn-section.tsx
index 233f7b8d..e35e710b 100644
--- a/components/links/link-sheet/expirationIn-section.tsx
+++ b/components/links/link-sheet/expirationIn-section.tsx
@@ -109,7 +109,7 @@ export default function ExpirationInSection({
return (
<div className="pb-5">
<LinkItem
- title="Link Expires After"
+ title="Link expires after"
enabled={enabled}
link="https://www.papermark.com/help/article/expiration-date"
action={handleEnableExpiration}
diff --git a/components/links/link-sheet/index-file-section.tsx b/components/links/link-sheet/index-file-section.tsx
index 22ce2f2c..da94a555 100644
--- a/components/links/link-sheet/index-file-section.tsx
+++ b/components/links/link-sheet/index-file-section.tsx
@@ -35,7 +35,7 @@ export default function IndexFileSection({
return (
<div className="pb-5">
<LinkItem
- title="Enable index file generation"
+ title="Index file generation"
enabled={enabled}
link="https://www.papermark.com/help/article/link-settings"
action={handleEnableIndexFile}
diff --git a/components/links/link-sheet/index.tsx b/components/links/link-sheet/index.tsx
index 4a345a7f..d45b977f 100644
--- a/components/links/link-sheet/index.tsx
+++ b/components/links/link-sheet/index.tsx
@@ -51,11 +51,12 @@ import {
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { ButtonTooltip } from "@/components/ui/tooltip";
+import AllowNotificationSection from "./allow-notification-section";
import { CustomFieldData } from "./custom-fields-panel";
import { type ItemPermission } from "./dataroom-link-sheet";
import DomainSection from "./domain-section";
import { LinkOptions } from "./link-options";
-import TagSection from "./tags/tag-section";
+import InlineTagSelector from "./tags/inline-tag-selector";
export const DEFAULT_LINK_PROPS = (
linkType: Omit<LinkType, "WORKFLOW_LINK">,
@@ -207,34 +208,33 @@ export default function LinkSheet({
>({});
const formRef = useRef<HTMLFormElement>(null);
- const setValidationError = useCallback(
- (key: string, errors: string[]) => {
- setValidationErrors((prev) => {
- const hasErrors = errors.length > 0;
- const wasPresent = key in prev;
- if (!hasErrors && !wasPresent) return prev;
- if (!hasErrors && wasPresent) {
- const next = { ...prev };
- delete next[key];
- return next;
- }
- const previous = prev[key];
- if (
- previous &&
- previous.length === errors.length &&
- previous.every((value, index) => value === errors[index])
- ) {
- return prev;
- }
- return { ...prev, [key]: errors };
- });
- },
- [],
- );
+ const setValidationError = useCallback((key: string, errors: string[]) => {
+ setValidationErrors((prev) => {
+ const hasErrors = errors.length > 0;
+ const wasPresent = key in prev;
+ if (!hasErrors && !wasPresent) return prev;
+ if (!hasErrors && wasPresent) {
+ const next = { ...prev };
+ delete next[key];
+ return next;
+ }
+ const previous = prev[key];
+ if (
+ previous &&
+ previous.length === errors.length &&
+ previous.every((value, index) => value === errors[index])
+ ) {
+ return prev;
+ }
+ return { ...prev, [key]: errors };
+ });
+ }, []);
const validationErrorEntries = useMemo(
() =>
- Object.entries(validationErrors).filter(([, errors]) => errors.length > 0),
+ Object.entries(validationErrors).filter(
+ ([, errors]) => errors.length > 0,
+ ),
[validationErrors],
);
const hasValidationErrors = validationErrorEntries.length > 0;
@@ -244,9 +244,7 @@ export default function LinkSheet({
allowList: "Allow specified viewers",
denyList: "Block specified viewers",
};
- return validationErrorEntries
- .map(([key]) => labels[key] ?? key)
- .join(", ");
+ return validationErrorEntries.map(([key]) => labels[key] ?? key).join(", ");
}, [validationErrorEntries]);
const isPresetsAllowed =
@@ -375,9 +373,7 @@ export default function LinkSheet({
}
if (hasValidationErrors) {
- toast.error(
- `Fix invalid emails or domains in: ${validationErrorLabel}`,
- );
+ toast.error(`Fix invalid emails or domains in: ${validationErrorLabel}`);
return;
}
@@ -672,13 +668,18 @@ 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-[800px] sm:max-w-4xl md:px-5">
+ <SheetContent
+ onOpenAutoFocus={(e) => e.preventDefault()}
+ 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
- ? `Edit ${currentLink.audienceType === LinkAudienceType.GROUP ? "group" : ""} link`
- : "Create a new link"}
- </SheetTitle>
+ <div className="flex items-center justify-between gap-4 pr-8">
+ <SheetTitle>
+ {currentLink
+ ? `Edit ${currentLink.audienceType === LinkAudienceType.GROUP ? "group" : ""} link`
+ : "Create a new link"}
+ </SheetTitle>
+ </div>
</SheetHeader>
<form
@@ -725,7 +726,45 @@ export default function LinkSheet({
{/* GENERAL LINK */}
<div className="space-y-6 pt-2">
<div className="space-y-2">
- <Label htmlFor="link-name">Link Name</Label>
+ <div className="flex items-center justify-between gap-2">
+ <Label htmlFor="link-name">Link name</Label>
+ <div className="flex items-center gap-2">
+ {/* Preset selector - compact, only when creating a
+ new link and presets are available */}
+ {!currentLink &&
+ isPresetsAllowed &&
+ presets &&
+ presets.length > 0 && (
+ <Select onValueChange={applyPreset}>
+ <SelectTrigger className="flex h-8 w-[150px] rounded-md border border-input bg-white text-foreground placeholder-muted-foreground focus:border-muted-foreground focus:outline-none focus:ring-inset focus:ring-muted-foreground dark:border-gray-500 dark:bg-gray-800 focus:dark:bg-transparent sm:text-sm">
+ <SelectValue placeholder="Apply a preset" />
+ </SelectTrigger>
+ <SelectContent className="rounded-md border border-input bg-white text-foreground dark:border-gray-500 dark:bg-gray-800 sm:text-sm">
+ {presets.map((preset) => (
+ <SelectItem
+ key={preset.id}
+ value={preset.id}
+ className="hover:bg-muted hover:dark:bg-gray-700"
+ >
+ {preset.name}
+ </SelectItem>
+ ))}
+ <Separator className="my-1" />
+ <Link
+ href="/settings/presets"
+ className="flex items-center rounded-sm px-2 py-1.5 text-xs text-muted-foreground outline-none hover:bg-muted hover:text-foreground hover:dark:bg-gray-700"
+ >
+ Manage presets
+ </Link>
+ </SelectContent>
+ </Select>
+ )}
+ <InlineTagSelector
+ {...{ data, setData }}
+ teamId={teamInfo?.currentTeam?.id as string}
+ />
+ </div>
+ </div>
<Input
type="text"
name="link-name"
@@ -747,48 +786,11 @@ export default function LinkSheet({
/>
</div>
- {/* Preset Selector - only show when creating a new link */}
- {!currentLink &&
- isPresetsAllowed &&
- presets &&
- presets.length > 0 && (
- <div className="space-y-2">
- <div className="flex items-center justify-between">
- <Label htmlFor="preset">Link Preset</Label>
- <Link
- href="/settings/presets"
- className="text-xs text-muted-foreground hover:text-foreground hover:underline"
- >
- Manage
- </Link>
- </div>
- <Select onValueChange={applyPreset}>
- <SelectTrigger className="w-full">
- <SelectValue placeholder="Select a preset" />
- </SelectTrigger>
- <SelectContent>
- {presets.map((preset) => (
- <SelectItem
- key={preset.id}
- value={preset.id}
- >
- {preset.name}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
- <p className="text-xs text-muted-foreground">
- Apply a preset to quickly configure link
- settings
- </p>
- </div>
- )}
-
<div className="relative flex items-center">
<Separator className="absolute bg-muted-foreground" />
<div className="relative mx-auto">
<span className="bg-background px-2 text-sm text-muted-foreground dark:bg-gray-900">
- Link Options
+ Security controls
</span>
</div>
</div>
@@ -801,6 +803,7 @@ export default function LinkSheet({
editLink={!!currentLink}
currentPreset={currentPreset}
setValidationError={setValidationError}
+ dataroomStyle
/>
</div>
</TabsContent>
@@ -865,7 +868,45 @@ export default function LinkSheet({
</div>
<div className="space-y-2">
- <Label htmlFor="link-name">Link Name</Label>
+ <div className="flex items-center justify-between gap-2">
+ <Label htmlFor="link-name">Link name</Label>
+ <div className="flex items-center gap-2">
+ {/* Preset selector - compact, only when creating a
+ new link and presets are available */}
+ {!currentLink &&
+ isPresetsAllowed &&
+ presets &&
+ presets.length > 0 && (
+ <Select onValueChange={applyPreset}>
+ <SelectTrigger className="flex h-8 w-[150px] rounded-md border border-input bg-white text-foreground placeholder-muted-foreground focus:border-muted-foreground focus:outline-none focus:ring-inset focus:ring-muted-foreground dark:border-gray-500 dark:bg-gray-800 focus:dark:bg-transparent sm:text-sm">
+ <SelectValue placeholder="Apply a preset" />
+ </SelectTrigger>
+ <SelectContent className="rounded-md border border-input bg-white text-foreground dark:border-gray-500 dark:bg-gray-800 sm:text-sm">
+ {presets.map((preset) => (
+ <SelectItem
+ key={preset.id}
+ value={preset.id}
+ className="hover:bg-muted hover:dark:bg-gray-700"
+ >
+ {preset.name}
+ </SelectItem>
+ ))}
+ <Separator className="my-1" />
+ <Link
+ href="/settings/presets"
+ className="flex items-center rounded-sm px-2 py-1.5 text-xs text-muted-foreground outline-none hover:bg-muted hover:text-foreground hover:dark:bg-gray-700"
+ >
+ Manage presets
+ </Link>
+ </SelectContent>
+ </Select>
+ )}
+ <InlineTagSelector
+ {...{ data, setData }}
+ teamId={teamInfo?.currentTeam?.id as string}
+ />
+ </div>
+ </div>
<Input
type="text"
@@ -898,48 +939,11 @@ export default function LinkSheet({
/>
</div>
- {/* Preset Selector for Group links - only show when creating a new link */}
- {!currentLink &&
- isPresetsAllowed &&
- presets &&
- presets.length > 0 && (
- <div className="space-y-2">
- <div className="flex items-center justify-between">
- <Label htmlFor="preset">Link Preset</Label>
- <Link
- href="/settings/presets"
- className="text-xs text-muted-foreground hover:text-foreground hover:underline"
- >
- Manage
- </Link>
- </div>
- <Select onValueChange={applyPreset}>
- <SelectTrigger className="w-full">
- <SelectValue placeholder="Select a preset" />
- </SelectTrigger>
- <SelectContent>
- {presets.map((preset) => (
- <SelectItem
- key={preset.id}
- value={preset.id}
- >
- {preset.name}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
- <p className="text-xs text-muted-foreground">
- Apply a preset to quickly configure link
- settings
- </p>
- </div>
- )}
-
<div className="relative flex items-center">
<Separator className="absolute bg-muted-foreground" />
<div className="relative mx-auto">
<span className="bg-background px-2 text-sm text-muted-foreground dark:bg-gray-900">
- Link Options
+ Security controls
</span>
</div>
</div>
@@ -952,18 +956,18 @@ export default function LinkSheet({
editLink={!!currentLink}
currentPreset={currentPreset}
setValidationError={setValidationError}
+ dataroomStyle
/>
</div>
</TabsContent>
</Tabs>
</div>
- <Separator className="mb-6 mt-2" />
-
- <div className="space-y-2">
- <TagSection
+ <div className="mt-4 border-t border-gray-200 pt-4 dark:border-gray-800">
+ <AllowNotificationSection
{...{ data, setData }}
- teamId={teamInfo?.currentTeam?.id as string}
+ title="Receive email notification for each link access"
+ className=""
/>
</div>
</div>
@@ -984,7 +988,7 @@ export default function LinkSheet({
disabled={hasValidationErrors}
onClick={(e) => handleSubmit(e, false)}
>
- {currentLink ? "Update Link" : "Save Link"}
+ {currentLink ? "Update link" : "Save link"}
</Button>
<Button
type="button"
diff --git a/components/links/link-sheet/link-options.tsx b/components/links/link-sheet/link-options.tsx
index 50f9f62f..017e398b 100644
--- a/components/links/link-sheet/link-options.tsx
+++ b/components/links/link-sheet/link-options.tsx
@@ -6,16 +6,19 @@ import { LinkAudienceType, LinkType } from "@prisma/client";
import { LinkPreset } from "@prisma/client";
import { ChevronDown } from "lucide-react";
+import { useFeatureFlags } from "@/lib/hooks/use-feature-flags";
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";
+import AllowBlockListSection from "@/components/links/link-sheet/allow-block-list-section";
import AllowDownloadSection from "@/components/links/link-sheet/allow-download-section";
import AllowListSection from "@/components/links/link-sheet/allow-list-section";
import AllowNotificationSection from "@/components/links/link-sheet/allow-notification-section";
import DenyListSection from "@/components/links/link-sheet/deny-list-section";
+import EmailAccessSection from "@/components/links/link-sheet/email-access-section";
import EmailAuthenticationSection from "@/components/links/link-sheet/email-authentication-section";
import EmailProtectionSection from "@/components/links/link-sheet/email-protection-section";
import ExpirationSection from "@/components/links/link-sheet/expiration-section";
@@ -28,6 +31,7 @@ import {
CollapsibleContent,
CollapsibleTrigger,
} from "@/components/ui/collapsible";
+import { Separator } from "@/components/ui/separator";
import AgreementSection from "./agreement-section";
import AIAgentsSection from "./ai-agents-section";
@@ -61,14 +65,19 @@ const CollapsibleSection = ({
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 className="group relative mb-5 mt-4 flex w-full items-center">
+ <Separator className="absolute top-1/2 -translate-y-1/2" />
+ <div className="relative mx-auto flex items-center gap-1.5 bg-background px-3 dark:bg-gray-900">
+ <span className="text-sm text-muted-foreground transition-colors group-hover:text-foreground">
+ {title}
+ </span>
+ <ChevronDown
+ className={cn(
+ "h-4 w-4 text-muted-foreground transition-transform duration-200 group-hover:text-foreground",
+ isOpen ? "rotate-180" : "",
+ )}
+ />
+ </div>
</CollapsibleTrigger>
<CollapsibleContent className="overflow-hidden data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down">
<div className="pt-2">{children}</div>
@@ -85,6 +94,8 @@ export const LinkOptions = ({
editLink,
currentPreset = null,
setValidationError,
+ defaultExpandSections = true,
+ dataroomStyle = false,
}: {
data: DEFAULT_LINK_TYPE;
setData: React.Dispatch<React.SetStateAction<DEFAULT_LINK_TYPE>>;
@@ -93,6 +104,21 @@ export const LinkOptions = ({
editLink?: boolean;
currentPreset?: LinkPreset | null;
setValidationError?: (key: string, errors: string[]) => void;
+ /**
+ * Controls whether the "Custom branding" and "Advanced controls" sections
+ * start expanded. Defaults to `true` to preserve the create-link sheet's
+ * behaviour; the full-page builder passes `false` to start them collapsed.
+ */
+ defaultExpandSections?: boolean;
+ /**
+ * Opt into the data room-style layout for document links: a single
+ * "Identity verification" segmented control, a unified allow & block list,
+ * "Allow downloading" relocated under the expiration date, a flattened
+ * (non-collapsible) security controls group, and the view notification moved
+ * to the bottom of the sheet (rendered by the parent). Data room links always
+ * use this layout regardless of the flag.
+ */
+ dataroomStyle?: boolean;
}) => {
const {
isStarter,
@@ -103,6 +129,17 @@ export const LinkOptions = ({
isTrial,
} = usePlan();
const { limits } = useLimits();
+ const { isFeatureEnabled } = useFeatureFlags();
+ const isAIFeatureEnabled = isFeatureEnabled("ai");
+ // The "Advanced controls" section only renders content for data room links
+ // (upload, file indexing, conversations) or when the AI agents feature is
+ // enabled for the team. For document links without AI, it would be empty.
+ const showAdvancedControls =
+ linkType === LinkType.DATAROOM_LINK || isAIFeatureEnabled;
+ // Data room links always use the consolidated layout; document links opt in
+ // via the `dataroomStyle` prop (e.g. the create/edit link modal).
+ const useDataroomStyleLayout =
+ linkType === LinkType.DATAROOM_LINK || dataroomStyle;
const allowAdvancedLinkControls = limits
? limits?.advancedLinkControlsOnPro
: false;
@@ -128,12 +165,16 @@ export const LinkOptions = ({
setHighlightItem(highlightItem || []);
};
- return (
+ const securityControls = (
<div>
- {/* Basic Options - Always visible */}
- <AllowNotificationSection {...{ data, setData }} />
- <EmailProtectionSection {...{ data, setData }} />
- <EmailAuthenticationSection
+ <PasswordSection {...{ data, setData }} />
+ <ExpirationSection {...{ data, setData }} presets={currentPreset} />
+ {/* In the consolidated layout, "Allow downloading" sits directly under
+ the expiration date. */}
+ {useDataroomStyleLayout && (
+ <AllowDownloadSection {...{ data, setData }} />
+ )}
+ <ScreenshotProtectionSection
{...{ data, setData }}
isAllowed={
isTrial ||
@@ -144,12 +185,57 @@ export const LinkOptions = ({
}
handleUpgradeStateChange={handleUpgradeStateChange}
/>
- <AllowDownloadSection {...{ data, setData }} />
+ <ConfidentialViewSection
+ {...{ data, setData }}
+ isAllowed={isTrial || isBusiness || isDatarooms || isDataroomsPlus}
+ handleUpgradeStateChange={handleUpgradeStateChange}
+ />
+ <WatermarkSection
+ {...{ data, setData }}
+ isAllowed={
+ isTrial || isDatarooms || isDataroomsPlus || allowWatermarkOnBusiness
+ }
+ handleUpgradeStateChange={handleUpgradeStateChange}
+ presets={currentPreset}
+ />
+ <AgreementSection
+ {...{ data, setData }}
+ isAllowed={
+ isTrial || isDatarooms || isDataroomsPlus || allowAgreementOnBusiness
+ }
+ handleUpgradeStateChange={handleUpgradeStateChange}
+ />
+ </div>
+ );
- {data.audienceType === LinkAudienceType.GENERAL ? (
+ return (
+ <div>
+ {/* Basic Options - Always visible */}
+ {/* In the consolidated layout the owner-facing view notification is moved
+ to the bottom of the sheet (rendered by the parent) so the list leads
+ with viewer-facing access controls. */}
+ {!useDataroomStyleLayout && (
+ <AllowNotificationSection {...{ data, setData }} />
+ )}
+ {useDataroomStyleLayout ? (
+ // Combine "require email" + "require verification" into a single
+ // segmented control to make the relationship between the two levels
+ // clear and save vertical space.
+ <EmailAccessSection
+ {...{ data, setData }}
+ isAllowed={
+ isTrial ||
+ (isPro && allowAdvancedLinkControls) ||
+ isBusiness ||
+ isDatarooms ||
+ isDataroomsPlus
+ }
+ handleUpgradeStateChange={handleUpgradeStateChange}
+ />
+ ) : (
<>
- <AllowListSection
- key={`allow-list-${data.id ?? "new"}`}
+ <EmailProtectionSection {...{ data, setData }} />
+ <EmailAuthenticationSection
{...{ data, setData }}
isAllowed={
isTrial ||
@@ -159,11 +245,21 @@ export const LinkOptions = ({
isDataroomsPlus
}
handleUpgradeStateChange={handleUpgradeStateChange}
- presets={currentPreset}
- setValidationError={setValidationError}
/>
- <DenyListSection
- key={`deny-list-${data.id ?? "new"}`}
+ </>
+ )}
+ {/* In the consolidated layout "Allow downloading" is relocated under the
+ expiration date within the (flattened) security controls below. */}
+ {!useDataroomStyleLayout && (
+ <AllowDownloadSection {...{ data, setData }} />
+ )}
+
+ {data.audienceType === LinkAudienceType.GENERAL ? (
+ useDataroomStyleLayout ? (
+ // Combine the allow + block lists under a single toggle (both lists
+ // remain configurable).
+ <AllowBlockListSection
+ key={`allow-block-${data.id ?? "new"}`}
{...{ data, setData }}
isAllowed={
isTrial ||
@@ -176,51 +272,54 @@ export const LinkOptions = ({
presets={currentPreset}
setValidationError={setValidationError}
/>
- </>
+ ) : (
+ <>
+ <AllowListSection
+ key={`allow-list-${data.id ?? "new"}`}
+ {...{ data, setData }}
+ isAllowed={
+ isTrial ||
+ (isPro && allowAdvancedLinkControls) ||
+ isBusiness ||
+ isDatarooms ||
+ isDataroomsPlus
+ }
+ handleUpgradeStateChange={handleUpgradeStateChange}
+ presets={currentPreset}
+ setValidationError={setValidationError}
+ />
+ <DenyListSection
+ key={`deny-list-${data.id ?? "new"}`}
+ {...{ data, setData }}
+ isAllowed={
+ isTrial ||
+ (isPro && allowAdvancedLinkControls) ||
+ isBusiness ||
+ isDatarooms ||
+ isDataroomsPlus
+ }
+ handleUpgradeStateChange={handleUpgradeStateChange}
+ presets={currentPreset}
+ setValidationError={setValidationError}
+ />
+ </>
+ )
) : null}
- {/* Security Section */}
- <CollapsibleSection title="Security Controls" defaultOpen={true}>
+ {/* Security Section. In the consolidated layout the security controls are
+ merged into the main list (no collapsible subgroup/separator); the
+ standalone layout keeps the collapsible group. */}
+ {useDataroomStyleLayout ? (
+ securityControls
+ ) : (
+ <CollapsibleSection title="Security controls" defaultOpen={true}>
+ {securityControls}
+ </CollapsibleSection>
+ )}
+
+ {/* Custom Branding Section */}
+ <CollapsibleSection title="Custom branding" defaultOpen={defaultExpandSections}>
<div>
- <PasswordSection {...{ data, setData }} />
- <ExpirationSection {...{ data, setData }} presets={currentPreset} />
- <ScreenshotProtectionSection
- {...{ data, setData }}
- isAllowed={
- isTrial ||
- (isPro && allowAdvancedLinkControls) ||
- isBusiness ||
- isDatarooms ||
- isDataroomsPlus
- }
- handleUpgradeStateChange={handleUpgradeStateChange}
- />
- <ConfidentialViewSection
- {...{ data, setData }}
- isAllowed={isTrial || isBusiness || isDatarooms || isDataroomsPlus}
- handleUpgradeStateChange={handleUpgradeStateChange}
- />
- <WatermarkSection
- {...{ data, setData }}
- isAllowed={
- isTrial ||
- isDatarooms ||
- isDataroomsPlus ||
- allowWatermarkOnBusiness
- }
- handleUpgradeStateChange={handleUpgradeStateChange}
- presets={currentPreset}
- />
- <AgreementSection
- {...{ data, setData }}
- isAllowed={
- isTrial ||
- isDatarooms ||
- isDataroomsPlus ||
- allowAgreementOnBusiness
- }
- handleUpgradeStateChange={handleUpgradeStateChange}
- />
<CustomFieldsSection
{...{ data, setData }}
isAllowed={
@@ -233,12 +332,6 @@ export const LinkOptions = ({
handleUpgradeStateChange={handleUpgradeStateChange}
presets={currentPreset}
/>
- </div>
- </CollapsibleSection>
-
- {/* Custom Branding Section */}
- <CollapsibleSection title="Custom Branding" defaultOpen={true}>
- <div>
<WelcomeMessageSection
data={data}
setData={setData}
@@ -274,51 +367,58 @@ export const LinkOptions = ({
</CollapsibleSection>
{/* Advanced Section */}
- <CollapsibleSection title="Advanced Controls" defaultOpen={true}>
- <div>
- {/* AI Agents - Available for both document and dataroom links */}
- <AIAgentsSection
- {...{ data, setData }}
- isAllowed={isTrial || isBusiness || isDatarooms || isDataroomsPlus}
- handleUpgradeStateChange={handleUpgradeStateChange}
- />
+ {showAdvancedControls && (
+ <CollapsibleSection
+ title="Advanced controls"
+ defaultOpen={defaultExpandSections}
+ >
+ <div>
+ {/* AI Agents - Available for both document and dataroom links */}
+ <AIAgentsSection
+ {...{ data, setData }}
+ isAllowed={
+ isTrial || isBusiness || isDatarooms || isDataroomsPlus
+ }
+ handleUpgradeStateChange={handleUpgradeStateChange}
+ />
+
+ {/* Dataroom-specific options */}
+ {linkType === LinkType.DATAROOM_LINK ? (
+ <>
+ {targetId ? (
+ <UploadSection
+ {...{ data, setData }}
+ isAllowed={
+ isTrial ||
+ isDataroomsPlus ||
+ (isDatarooms && limits?.dataroomUpload === true)
+ }
+ handleUpgradeStateChange={handleUpgradeStateChange}
+ targetId={targetId}
+ />
+ ) : null}
+
+ <IndexFileSection
+ {...{ data, setData }}
+ isAllowed={isTrial || isDataroomsPlus}
+ handleUpgradeStateChange={handleUpgradeStateChange}
+ />
- {/* Dataroom-specific options */}
- {linkType === LinkType.DATAROOM_LINK ? (
- <>
- {targetId ? (
- <UploadSection
+ <ConversationSection
{...{ data, setData }}
isAllowed={
isTrial ||
isDataroomsPlus ||
- (isDatarooms && limits?.dataroomUpload === true)
+ ((isBusiness || isDatarooms) &&
+ !!limits?.conversationsInDataroom)
}
handleUpgradeStateChange={handleUpgradeStateChange}
- targetId={targetId}
/>
- ) : null}
-
- <IndexFileSection
- {...{ data, setData }}
- isAllowed={isTrial || isDataroomsPlus}
- handleUpgradeStateChange={handleUpgradeStateChange}
- />
-
- <ConversationSection
- {...{ data, setData }}
- isAllowed={
- isTrial ||
- isDataroomsPlus ||
- ((isBusiness || isDatarooms) &&
- !!limits?.conversationsInDataroom)
- }
- handleUpgradeStateChange={handleUpgradeStateChange}
- />
- </>
- ) : null}
- </div>
- </CollapsibleSection>
+ </>
+ ) : null}
+ </div>
+ </CollapsibleSection>
+ )}
<UpgradePlanModal
clickedPlan={upgradePlan}
diff --git a/components/links/link-sheet/og-section.tsx b/components/links/link-sheet/og-section.tsx
index 90ca1486..25654934 100644
--- a/components/links/link-sheet/og-section.tsx
+++ b/components/links/link-sheet/og-section.tsx
@@ -138,7 +138,7 @@ export default function OGSection({
<div className="pb-5">
<LinkItem
tooltipContent="Customize how your links look when shared."
- title="Custom Link Preview"
+ title="Custom link preview"
link="https://www.papermark.com/help/article/change-social-media-cards"
enabled={enableCustomMetatag}
action={handleCustomMetatag}
diff --git a/components/links/link-sheet/password-section.tsx b/components/links/link-sheet/password-section.tsx
index c4826787..3caba288 100644
--- a/components/links/link-sheet/password-section.tsx
+++ b/components/links/link-sheet/password-section.tsx
@@ -37,7 +37,7 @@ export default function PasswordSection({
return (
<div className="pb-5">
<LinkItem
- title="Require password to view"
+ title="Password protection"
enabled={enabled}
action={handleEnablePassword}
tooltipContent="Users must enter a password to access the content."
diff --git a/components/links/link-sheet/pro-banner-section.tsx b/components/links/link-sheet/pro-banner-section.tsx
index 0c5556fd..e5473693 100644
--- a/components/links/link-sheet/pro-banner-section.tsx
+++ b/components/links/link-sheet/pro-banner-section.tsx
@@ -36,7 +36,7 @@ export function ProBannerSection({
return (
<div className="pb-5">
<LinkItem
- title="Show Secured by Papermark"
+ title="Secured by Papermark badge"
tooltipContent="Display 'Secured by Papermark' branding on your shared documents"
link="https://www.papermark.com/help/article/remove-papermark-branding"
enabled={enabled}
diff --git a/components/links/link-sheet/question-section.tsx b/components/links/link-sheet/question-section.tsx
index f885fbc6..569a2255 100644
--- a/components/links/link-sheet/question-section.tsx
+++ b/components/links/link-sheet/question-section.tsx
@@ -50,7 +50,7 @@ export default function QuestionSection({
return (
<div className="pb-5">
<LinkItem
- title="Feedback Question"
+ title="Feedback question"
tooltipContent="Create a concise question for visitor feedback."
enabled={enabled}
action={handleQuestion}
diff --git a/components/links/link-sheet/screenshot-protection-section.tsx b/components/links/link-sheet/screenshot-protection-section.tsx
index 73d069cb..c32272d5 100644
--- a/components/links/link-sheet/screenshot-protection-section.tsx
+++ b/components/links/link-sheet/screenshot-protection-section.tsx
@@ -39,7 +39,7 @@ export default function ScreenshotProtectionSection({
return (
<div className="pb-5">
<LinkItem
- title="Enable screenshot protection"
+ title="Screenshot protection"
tooltipContent="Prevent users from taking screenshots of your content."
link="https://www.papermark.com/screenshot-protection"
enabled={enabled}
diff --git a/components/links/link-sheet/tags/inline-tag-selector.tsx b/components/links/link-sheet/tags/inline-tag-selector.tsx
new file mode 100644
index 00000000..9f314bf9
--- /dev/null
+++ b/components/links/link-sheet/tags/inline-tag-selector.tsx
@@ -0,0 +1,202 @@
+import Link from "next/link";
+
+import { Dispatch, SetStateAction, useMemo, useState } from "react";
+
+import { PlanEnum } from "@/ee/stripe/constants";
+import { Tag } from "lucide-react";
+import { AnimatePresence, motion } from "motion/react";
+import { toast } from "sonner";
+import { mutate } from "swr";
+
+import { usePlan } from "@/lib/swr/use-billing";
+import { useTags } from "@/lib/swr/use-tags";
+import { TagProps } from "@/lib/types";
+import { cn } from "@/lib/utils";
+
+import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
+import { Button } from "@/components/ui/button";
+import { MultiSelect } from "@/components/ui/multi-select-v2";
+import { ButtonTooltip } from "@/components/ui/tooltip";
+
+import { DEFAULT_LINK_TYPE } from "..";
+
+function getTagOption(tag: TagProps) {
+ return {
+ value: tag.id,
+ label: tag.name,
+ icon: (
+ <Tag
+ size={20}
+ className={`rounded-sm border border-gray-200 bg-${tag.color}-100 p-1 dark:text-primary-foreground`}
+ />
+ ),
+ meta: { color: tag.color, description: tag.description },
+ };
+}
+
+/**
+ * Compact tag control that lives inline on the link name row. Collapsed it
+ * shows just a Tag icon; pressing it stretches a tag selector open to the left.
+ */
+export default function InlineTagSelector({
+ data,
+ setData,
+ teamId,
+}: {
+ data: DEFAULT_LINK_TYPE;
+ setData: Dispatch<SetStateAction<DEFAULT_LINK_TYPE>>;
+ teamId: string;
+}) {
+ const [expanded, setExpanded] = useState((data.tags?.length ?? 0) > 0);
+ const [isPopoverOpen, setIsPopoverOpen] = useState(false);
+ const [selectedValues, setSelectedValues] = useState<string[]>(
+ data.tags || [],
+ );
+ const [showUpgradeModal, setShowUpgradeModal] = useState(false);
+ const { isFree } = usePlan();
+
+ const {
+ tagCount,
+ tags: availableTags,
+ loading: loadingTags,
+ } = useTags({
+ query: {
+ sortBy: "createdAt",
+ sortOrder: "desc",
+ },
+ });
+
+ const options = useMemo(
+ () => availableTags?.map((tag) => getTagOption(tag)),
+ [availableTags],
+ );
+
+ const handleValueChange = (value: string[]) => {
+ setSelectedValues(value);
+ setData((prevData) => ({
+ ...prevData,
+ tags: value,
+ }));
+ };
+
+ const createTag = async (tag: string) => {
+ if (isFree && tagCount && tagCount >= 5) {
+ setShowUpgradeModal(true);
+ toast.error("You have reached the maximum number of tags.");
+ return false;
+ }
+
+ const res = await fetch(`/api/teams/${teamId}/tags`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({ name: tag }),
+ });
+ if (!res.ok) {
+ const { error } = await res.json();
+ toast.error(error);
+ return false;
+ }
+
+ const newTag = await res.json();
+ await mutate(
+ `/api/teams/${teamId}/tags?${new URLSearchParams({
+ sortBy: "createdAt",
+ sortOrder: "desc",
+ includeLinksCount: false,
+ } as Record<string, any>).toString()}`,
+ );
+ setSelectedValues([...selectedValues, newTag.id]);
+ setData((prevData) => ({
+ ...prevData,
+ tags: [...prevData.tags, newTag.id],
+ }));
+ setIsPopoverOpen(false);
+ toast.success(`Successfully created tag!`);
+ return true;
+ };
+
+ const handleToggle = () => {
+ setExpanded((prev) => {
+ const next = !prev;
+ // Open the tag dropdown right away when stretching the field open.
+ if (next) {
+ setIsPopoverOpen(true);
+ } else {
+ setIsPopoverOpen(false);
+ }
+ return next;
+ });
+ };
+
+ return (
+ <div className="flex min-w-0 items-center justify-end gap-2">
+ <AnimatePresence initial={false}>
+ {expanded && (
+ <motion.div
+ key="inline-tags"
+ initial={{ width: 0, opacity: 0 }}
+ animate={{ width: 280, opacity: 1 }}
+ exit={{ width: 0, opacity: 0 }}
+ transition={{ duration: 0.2, ease: "easeInOut" }}
+ className="overflow-hidden"
+ >
+ <MultiSelect
+ loading={loadingTags}
+ options={options ?? []}
+ value={selectedValues}
+ setIsPopoverOpen={setIsPopoverOpen}
+ isPopoverOpen={isPopoverOpen}
+ onValueChange={handleValueChange}
+ placeholder="Select tags..."
+ maxCount={2}
+ searchPlaceholder="Search or add tags..."
+ onCreate={(search) => createTag(search)}
+ popoverClassName="w-[var(--radix-popover-trigger-width)] sm:w-[var(--radix-popover-trigger-width)] sm:max-w-none"
+ footer={
+ <Link
+ href="/settings/tags"
+ className="flex items-center rounded-sm px-2 py-1.5 text-xs text-muted-foreground outline-none hover:bg-muted hover:text-foreground hover:dark:bg-gray-700"
+ >
+ Manage tags
+ </Link>
+ }
+ />
+ </motion.div>
+ )}
+ </AnimatePresence>
+
+ <ButtonTooltip content={expanded ? "Hide tags" : "Add tags"}>
+ <Button
+ type="button"
+ size="icon"
+ variant="ghost"
+ onClick={handleToggle}
+ aria-pressed={expanded}
+ aria-label="Toggle tags"
+ className={cn(
+ "relative h-9 w-9 shrink-0 text-muted-foreground hover:text-foreground sm:h-10 sm:w-10",
+ (expanded || selectedValues.length > 0) && "text-foreground",
+ )}
+ >
+ <Tag className="h-4 w-4" />
+ {!expanded && selectedValues.length > 0 ? (
+ <span className="absolute right-0 top-0 z-10 flex h-4 min-w-4 items-center justify-center rounded-full bg-primary px-1 text-[10px] font-medium text-primary-foreground">
+ {selectedValues.length}
+ </span>
+ ) : null}
+ </Button>
+ </ButtonTooltip>
+
+ {showUpgradeModal && (
+ <UpgradePlanModal
+ clickedPlan={PlanEnum.Pro}
+ trigger="create_tag"
+ open={showUpgradeModal}
+ setOpen={setShowUpgradeModal}
+ />
+ )}
+ </div>
+ );
+}
diff --git a/components/links/link-sheet/watermark-panel/index.tsx b/components/links/link-sheet/watermark-panel/index.tsx
index ef99c72e..c86aacb7 100644
--- a/components/links/link-sheet/watermark-panel/index.tsx
+++ b/components/links/link-sheet/watermark-panel/index.tsx
@@ -33,6 +33,10 @@ import {
import { FADE_IN_ANIMATION_SETTINGS } from "@/lib/constants";
import { WatermarkConfig, WatermarkConfigSchema } from "@/lib/types";
+import WatermarkPreview from "./watermark-preview";
+
+const PREVIEW_PLACEHOLDER_TEXT = "Confidential {{email}}";
+
interface WatermarkConfigSheetProps {
isOpen: boolean;
onOpenChange: (open: boolean) => void;
@@ -50,6 +54,16 @@ export default function WatermarkConfigSheet({
useState<Partial<WatermarkConfig>>(initialConfig);
const [errors, setErrors] = useState<Record<string, string>>({});
+ const previewConfig: WatermarkConfig = {
+ text: formValues.text?.trim() ? formValues.text : PREVIEW_PLACEHOLDER_TEXT,
+ isTiled: formValues.isTiled ?? false,
+ position: formValues.position ?? "middle-center",
+ rotation: formValues.rotation ?? 45,
+ color: formValues.color ?? "#000000",
+ fontSize: formValues.fontSize ?? 24,
+ opacity: formValues.opacity ?? 0.5,
+ };
+
useEffect(() => {
setFormValues(initialConfig);
}, [initialConfig]);
@@ -85,7 +99,7 @@ export default function WatermarkConfigSheet({
return (
<Sheet open={isOpen} onOpenChange={onOpenChange}>
- <SheetContent className="flex h-full flex-col">
+ <SheetContent className="flex h-full flex-col sm:max-w-6xl">
<SheetHeader>
<SheetTitle>Watermark Configuration</SheetTitle>
<SheetDescription>
@@ -93,7 +107,9 @@ export default function WatermarkConfigSheet({
</SheetDescription>
</SheetHeader>
- <ScrollArea className="flex-1">
+ <div className="flex min-h-0 flex-1 flex-col gap-6 lg:flex-row lg:gap-8">
+ {/* Settings column */}
+ <ScrollArea className="min-h-0 flex-1 lg:w-[360px] lg:flex-none lg:pr-4">
<motion.div
className="relative mt-4 space-y-3"
{...FADE_IN_ANIMATION_SETTINGS}
@@ -305,7 +321,16 @@ export default function WatermarkConfigSheet({
</div>
</div>
</motion.div>
- </ScrollArea>
+ </ScrollArea>
+
+ {/* Separator */}
+ <div className="hidden lg:block lg:w-px lg:self-stretch lg:bg-border" />
+
+ {/* Preview column */}
+ <div className="min-h-0 flex-1 overflow-y-auto lg:pl-2">
+ <WatermarkPreview config={previewConfig} />
+ </div>
+ </div>
<SheetFooter className="flex-shrink-0">
<Button onClick={validateAndSave}>Save Watermark</Button>
diff --git a/components/links/link-sheet/watermark-panel/watermark-preview.tsx b/components/links/link-sheet/watermark-panel/watermark-preview.tsx
new file mode 100644
index 00000000..b5e4d1dd
--- /dev/null
+++ b/components/links/link-sheet/watermark-panel/watermark-preview.tsx
@@ -0,0 +1,169 @@
+import { WatermarkConfig } from "@/lib/types";
+
+import { SVGWatermark } from "@/components/view/watermark-svg";
+
+const PAGE_WIDTH = 400;
+const PAGE_HEIGHT = 518;
+
+const MOCK_VIEWER_DATA = {
+ email: "[email protected]",
+ date: new Date().toLocaleDateString(),
+ time: new Date().toLocaleTimeString(),
+ link: "Sample Link",
+ ipAddress: "192.168.1.1",
+};
+
+const FINANCIAL_ROWS = [
+ { label: "Total Revenue", current: "$152.4", prior: "$128.4", yoy: "18.7%" },
+ { label: "Gross Profit", current: "$68.6", prior: "$56.6", yoy: "21.3%" },
+ { label: "Gross Margin", current: "45.0%", prior: "44.1%", yoy: "+0.9 pp" },
+ { label: "Operating Income", current: "$27.8", prior: "$22.3", yoy: "24.6%" },
+ { label: "Net Income", current: "$20.4", prior: "$16.2", yoy: "26.1%" },
+ { label: "Diluted EPS", current: "$0.68", prior: "$0.54", yoy: "25.9%" },
+];
+
+function FinancialReport() {
+ return (
+ <div
+ className="absolute inset-0 overflow-hidden bg-white px-7 py-6 text-gray-900"
+ style={{ fontSize: 7, lineHeight: 1.5 }}
+ >
+ <h1 className="font-serif text-[13px] font-bold">
+ Q1 2024 Financial Performance Report
+ </h1>
+
+ <h2 className="mt-4 text-[8px] font-bold">Executive Summary</h2>
+ <p className="mt-1 text-gray-700">
+ Global Tech Solutions Inc. (&ldquo;GTS&rdquo; or &ldquo;the
+ Company&rdquo;) delivered a strong start to 2024, with solid revenue
+ growth and improved profitability across key product lines. Continued
+ operational efficiency and disciplined cost management contributed to
+ robust financial results.
+ </p>
+
+ <h2 className="mt-3 text-[8px] font-bold">Financial Highlights</h2>
+ <ul className="mt-1 list-disc space-y-0.5 pl-3 text-gray-700">
+ <li>Total revenue increased 18.7% year-over-year to $152.4 million.</li>
+ <li>
+ Gross profit grew 21.3% to $68.6 million, with gross margin expanding
+ to 45.0%.
+ </li>
+ <li>Operating income increased 24.6% to $27.8 million.</li>
+ <li>
+ Net income attributable to shareholders increased 26.1% to $20.4
+ million.
+ </li>
+ <li>Diluted earnings per share rose to $0.68, compared to $0.54.</li>
+ </ul>
+
+ <h2 className="mt-3 text-[8px] font-bold">Financial Results Summary</h2>
+ <table className="mt-1 w-full border-collapse text-left text-gray-700">
+ <thead>
+ <tr className="border-b border-gray-300 font-semibold">
+ <th className="py-0.5 pr-1">in millions</th>
+ <th className="py-0.5 pr-1">Q1 2024</th>
+ <th className="py-0.5 pr-1">Q1 2023</th>
+ <th className="py-0.5">YoY</th>
+ </tr>
+ </thead>
+ <tbody>
+ {FINANCIAL_ROWS.map((row) => (
+ <tr key={row.label} className="border-b border-gray-100">
+ <td className="py-0.5 pr-1">{row.label}</td>
+ <td className="py-0.5 pr-1">{row.current}</td>
+ <td className="py-0.5 pr-1">{row.prior}</td>
+ <td className="py-0.5">{row.yoy}</td>
+ </tr>
+ ))}
+ </tbody>
+ </table>
+
+ <h2 className="mt-3 text-[8px] font-bold">Outlook</h2>
+ <p className="mt-1 text-gray-700">
+ The Company remains focused on innovation, customer success, and
+ strategic investments to drive long-term growth. We reaffirm our
+ full-year 2024 guidance and are confident in our ability to deliver
+ sustained value to our shareholders.
+ </p>
+
+ <span className="absolute bottom-3 right-7 text-gray-400">1</span>
+ </div>
+ );
+}
+
+export default function WatermarkPreview({
+ config,
+}: {
+ config: WatermarkConfig;
+}) {
+ return (
+ <div className="flex h-full flex-col">
+ <p className="mb-3 text-sm font-medium text-foreground">Preview</p>
+ <div className="flex flex-1 justify-center">
+ <div
+ className="relative w-full max-w-[560px] rounded-lg bg-gray-200 p-1 shadow-lg dark:bg-gray-800"
+ style={{ height: 560 }}
+ >
+ <div className="relative flex h-full flex-col overflow-hidden rounded-lg bg-gray-100 dark:bg-gray-900">
+ {/* Browser chrome */}
+ <div className="mx-auto flex h-7 shrink-0 items-center justify-center">
+ <div className="pointer-events-none absolute left-3">
+ <div className="flex flex-row flex-nowrap justify-start">
+ <div className="mr-1 inline-block size-2 rounded-full bg-gray-300" />
+ <div className="mr-1 inline-block size-2 rounded-full bg-gray-300" />
+ <div className="mr-1 inline-block size-2 rounded-full bg-gray-300" />
+ </div>
+ </div>
+ <div className="flex items-center justify-center rounded-xl bg-white p-1 px-2 opacity-70 dark:bg-gray-800">
+ <div
+ aria-hidden="true"
+ className="mr-1 mt-0.5 flex text-muted-foreground"
+ >
+ <svg
+ aria-hidden="true"
+ height="8"
+ width="8"
+ viewBox="0 0 16 16"
+ fill="currentColor"
+ xmlns="http://www.w3.org/2000/svg"
+ >
+ <path d="M8.75 11.25a1.25 1.25 0 1 0-1.5 0v1a.75.75 0 0 0 1.5 0v-1Z"></path>
+ <path
+ fillRule="evenodd"
+ clipRule="evenodd"
+ d="M3.5 4v2h-1a1 1 0 0 0-1 1v6a3 3 0 0 0 3 3h7a3 3 0 0 0 3-3V7a1 1 0 0 0-1-1h-1V4a4 4 0 0 0-4-4h-1a4 4 0 0 0-4 4ZM11 6V4a2.5 2.5 0 0 0-2.5-2.5h-1A2.5 2.5 0 0 0 5 4v2h6Zm-8 7V7.5h10V13a1.5 1.5 0 0 1-1.5 1.5h-7A1.5 1.5 0 0 1 3 13Z"
+ ></path>
+ </svg>
+ </div>
+ <span className="whitespace-normal text-xs text-muted-foreground">
+ papermark.com/view/...
+ </span>
+ </div>
+ </div>
+
+ {/* Document viewport */}
+ <div className="relative min-h-0 flex-1 overflow-auto">
+ <div className="flex justify-center py-4">
+ <div
+ className="relative shrink-0 shadow-sm"
+ style={{ width: PAGE_WIDTH, height: PAGE_HEIGHT }}
+ >
+ <FinancialReport />
+ <SVGWatermark
+ config={config}
+ viewerData={MOCK_VIEWER_DATA}
+ documentDimensions={{
+ width: PAGE_WIDTH,
+ height: PAGE_HEIGHT,
+ }}
+ pageIndex={0}
+ />
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/components/links/link-sheet/watermark-section.tsx b/components/links/link-sheet/watermark-section.tsx
index 1cf6093c..38cc3538 100644
--- a/components/links/link-sheet/watermark-section.tsx
+++ b/components/links/link-sheet/watermark-section.tsx
@@ -88,7 +88,7 @@ export default function WatermarkSection({
return (
<div className="pb-5">
<LinkItem
- title="Apply Watermark"
+ title="Dynamic watermarking"
link="https://www.papermark.com/help/article/document-watermark"
tooltipContent="Add a dynamic watermark to your content."
enabled={enabled}
diff --git a/components/links/link-sheet/welcome-message-section.tsx b/components/links/link-sheet/welcome-message-section.tsx
index 6ae5bda1..bbe81d07 100644
--- a/components/links/link-sheet/welcome-message-section.tsx
+++ b/components/links/link-sheet/welcome-message-section.tsx
@@ -69,7 +69,7 @@ export function WelcomeMessageSection({
return (
<div className="pb-5">
<LinkItem
- title="Custom Welcome Message"
+ title="Custom welcome message"
tooltipContent="Override the default welcome message for this link"
enabled={enabled}
action={handleWelcomeMessageToggle}
diff --git a/components/links/links-table.tsx b/components/links/links-table.tsx
index 9f056c55..429c9e97 100644
--- a/components/links/links-table.tsx
+++ b/components/links/links-table.tsx
@@ -34,7 +34,6 @@ import {
import { useQueryState } from "nuqs";
import { toast } from "sonner";
import { mutate } from "swr";
-import z from "zod";
import { useFeatureFlags } from "@/lib/hooks/use-feature-flags";
import { usePlan } from "@/lib/swr/use-billing";
@@ -91,7 +90,6 @@ import LinkSheet, {
type DEFAULT_LINK_TYPE,
} from "./link-sheet";
import { DataroomLinkSheet } from "./link-sheet/dataroom-link-sheet";
-import { PermissionsSheet } from "./link-sheet/permissions-sheet";
import { TagColumn } from "./link-sheet/tags/tag-details";
import LinksVisitors from "./links-visitors";
@@ -370,10 +368,10 @@ export default function LinksTable({
const [popoverOpen, setPopoverOpen] = useState<string | null>(null);
const hoverTimeout = useRef<NodeJS.Timeout | null>(null);
- const [showPermissionsSheet, setShowPermissionsSheet] =
+ // When true, the dataroom link sheet opens straight into the file
+ // permissions panel (triggered from the "Edit file permissions" action).
+ const [openLinkSheetToFiles, setOpenLinkSheetToFiles] =
useState<boolean>(false);
- const [editPermissionLink, setEditPermissionLink] =
- useState<LinkWithViews | null>(null);
const [linkToDelete, setLinkToDelete] = useState<LinkWithViews | null>(null);
const { setShowDeleteLinkModal, DeleteLinkModal } = useDeleteLinkModal({
@@ -407,66 +405,69 @@ export default function LinksTable({
copyToClipboard(`${linkString}`, "Link copied to clipboard.");
};
+ const buildLinkFormData = (link: LinkWithViews): DEFAULT_LINK_TYPE => ({
+ id: link.id,
+ name: link.name || `Link #${link.id.slice(-5)}`,
+ domain: link.domainSlug,
+ slug: link.slug,
+ expiresAt: link.expiresAt,
+ password: link.password,
+ emailProtected: link.emailProtected,
+ emailAuthenticated: link.emailAuthenticated,
+ allowDownload: link.allowDownload ? link.allowDownload : false,
+ allowList: link.allowList,
+ denyList: link.denyList,
+ visitorGroupIds:
+ link.visitorGroups?.map(
+ (vg: { visitorGroupId: string }) => vg.visitorGroupId,
+ ) || [],
+ enableNotification: link.enableNotification
+ ? link.enableNotification
+ : false,
+ enableFeedback: link.enableFeedback ? link.enableFeedback : false,
+ enableScreenshotProtection: link.enableScreenshotProtection
+ ? link.enableScreenshotProtection
+ : false,
+ enableConfidentialView: link.enableConfidentialView
+ ? link.enableConfidentialView
+ : false,
+ enableCustomMetatag: link.enableCustomMetatag
+ ? link.enableCustomMetatag
+ : false,
+ enableQuestion: link.enableQuestion ? link.enableQuestion : false,
+ questionText: link.feedback ? link.feedback.data?.question : "",
+ questionType: link.feedback ? link.feedback.data?.type : "",
+ metaTitle: link.metaTitle,
+ metaDescription: link.metaDescription,
+ metaImage: link.metaImage,
+ metaFavicon: link.metaFavicon,
+ enableAgreement: link.enableAgreement ? link.enableAgreement : false,
+ agreementId: link.agreementId,
+ showBanner: link.showBanner ?? false,
+ enableWatermark: link.enableWatermark ?? false,
+ watermarkConfig: link.watermarkConfig as WatermarkConfig | null,
+ audienceType: link.audienceType,
+ groupId: link.groupId,
+ customFields: link.customFields || [],
+ tags: link.tags.map((tag) => tag.id) || [],
+ enableConversation: link.enableConversation ?? false,
+ enableUpload: link.enableUpload ?? false,
+ isFileRequestOnly: link.isFileRequestOnly ?? false,
+ uploadFolderIds: Array.isArray(link.uploadFolderIds)
+ ? link.uploadFolderIds
+ : [],
+ uploadFolders: Array.isArray(link.uploadFolders)
+ ? link.uploadFolders
+ : [],
+ enableIndexFile: link.enableIndexFile ?? false,
+ permissionGroupId: link.permissionGroupId ?? null,
+ welcomeMessage: link.welcomeMessage ?? null,
+ enableAIAgents: link.enableAIAgents ?? false,
+ });
+
const handleEditLink = (link: LinkWithViews) => {
- setSelectedLink({
- id: link.id,
- name: link.name || `Link #${link.id.slice(-5)}`,
- domain: link.domainSlug,
- slug: link.slug,
- expiresAt: link.expiresAt,
- password: link.password,
- emailProtected: link.emailProtected,
- emailAuthenticated: link.emailAuthenticated,
- allowDownload: link.allowDownload ? link.allowDownload : false,
- allowList: link.allowList,
- denyList: link.denyList,
- visitorGroupIds:
- link.visitorGroups?.map(
- (vg: { visitorGroupId: string }) => vg.visitorGroupId,
- ) || [],
- enableNotification: link.enableNotification
- ? link.enableNotification
- : false,
- enableFeedback: link.enableFeedback ? link.enableFeedback : false,
- enableScreenshotProtection: link.enableScreenshotProtection
- ? link.enableScreenshotProtection
- : false,
- enableConfidentialView: link.enableConfidentialView
- ? link.enableConfidentialView
- : false,
- enableCustomMetatag: link.enableCustomMetatag
- ? link.enableCustomMetatag
- : false,
- enableQuestion: link.enableQuestion ? link.enableQuestion : false,
- questionText: link.feedback ? link.feedback.data?.question : "",
- questionType: link.feedback ? link.feedback.data?.type : "",
- metaTitle: link.metaTitle,
- metaDescription: link.metaDescription,
- metaImage: link.metaImage,
- metaFavicon: link.metaFavicon,
- enableAgreement: link.enableAgreement ? link.enableAgreement : false,
- agreementId: link.agreementId,
- showBanner: link.showBanner ?? false,
- enableWatermark: link.enableWatermark ?? false,
- watermarkConfig: link.watermarkConfig as WatermarkConfig | null,
- audienceType: link.audienceType,
- groupId: link.groupId,
- customFields: link.customFields || [],
- tags: link.tags.map((tag) => tag.id) || [],
- enableConversation: link.enableConversation ?? false,
- enableUpload: link.enableUpload ?? false,
- isFileRequestOnly: link.isFileRequestOnly ?? false,
- uploadFolderIds: Array.isArray(link.uploadFolderIds)
- ? link.uploadFolderIds
- : [],
- uploadFolders: Array.isArray(link.uploadFolders)
- ? link.uploadFolders
- : [],
- enableIndexFile: link.enableIndexFile ?? false,
- permissionGroupId: link.permissionGroupId ?? null,
- welcomeMessage: link.welcomeMessage ?? null,
- enableAIAgents: link.enableAIAgents ?? false,
- });
+ setOpenLinkSheetToFiles(false);
+ setSelectedLink(buildLinkFormData(link));
//wait for dropdown to close before opening the link sheet
setTimeout(() => {
setIsLinkSheetVisible(true);
@@ -569,171 +570,14 @@ export default function LinksTable({
};
const handleEditPermissions = (link: LinkWithViews) => {
- setEditPermissionLink(link);
- setShowPermissionsSheet(true);
- };
-
- const handlePermissionsSave = async (permissions: any) => {
- if (!editPermissionLink) return;
-
- // Handle the case where user wants to share entire dataroom (permissions === null)
- if (permissions === null && editPermissionLink.permissionGroupId) {
- // Delete the permission group - database will set permissionGroupId to null automatically
- try {
- const teamIdParsed = z.string().cuid().parse(currentTeamId);
- const targetIdParsed = z.string().cuid().parse(targetId);
- const permissionGroupIdParsed = z
- .string()
- .cuid()
- .parse(editPermissionLink.permissionGroupId);
-
- const deleteResponse = await fetch(
- `/api/teams/${teamIdParsed}/datarooms/${targetIdParsed}/permission-groups/${permissionGroupIdParsed}`,
- {
- method: "DELETE",
- },
- );
-
- if (!deleteResponse.ok) {
- const { error } = await deleteResponse.json();
- throw new Error(error ?? "Failed to delete permission group");
- }
-
- // Refresh the links cache
- const endpointTargetType = `${targetType.toLowerCase()}s`;
- mutate(
- `/api/teams/${teamIdParsed}/${endpointTargetType}/${encodeURIComponent(
- targetIdParsed,
- )}/links`,
- (currentLinks: LinkWithViews[] | undefined) =>
- (currentLinks || []).map((link: LinkWithViews) =>
- link.id === editPermissionLink.id
- ? { ...link, permissionGroupId: null }
- : link,
- ),
- false,
- );
-
- // Invalidate the permission group cache
- mutate(
- `/api/teams/${teamIdParsed}/datarooms/${targetIdParsed}/permission-groups/${permissionGroupIdParsed}`,
- );
-
- setShowPermissionsSheet(false);
- setEditPermissionLink(null);
- toast.success("File permissions updated successfully");
- } catch (error) {
- console.error("Error updating file permissions:", error);
- toast.error("Failed to update file permissions");
- }
- return;
- }
-
- if (!editPermissionLink.permissionGroupId) {
- setIsLoading(true);
- try {
- const teamIdParsed = z.string().cuid().parse(currentTeamId);
- const targetIdParsed = z.string().cuid().parse(targetId);
- const response = await fetch(
- `/api/teams/${teamIdParsed}/datarooms/${targetIdParsed}/permission-groups`,
- {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- permissions: permissions,
- linkId: editPermissionLink.id,
- }),
- },
- );
-
- if (!response.ok) {
- const error = await response.json();
- throw new Error(error.error || "Failed to create permission group");
- }
-
- const { permissionGroup: newPermissionGroup, _ } =
- await response.json();
-
- // Refresh the links cache
- const endpointTargetType = `${targetType.toLowerCase()}s`;
- mutate(
- `/api/teams/${currentTeamId}/${endpointTargetType}/${encodeURIComponent(
- targetId,
- )}/links`,
- );
-
- // Cache the new permission group data
- if (newPermissionGroup?.id) {
- mutate(
- `/api/teams/${currentTeamId}/datarooms/${targetId}/permission-groups/${newPermissionGroup.id}`,
- newPermissionGroup,
- false,
- );
- }
-
- setShowPermissionsSheet(false);
- setEditPermissionLink(null);
- toast.success("File permissions updated successfully");
- } catch (error) {
- console.error("Error creating permission group:", error);
- toast.error("Failed to create permission group");
- } finally {
- setIsLoading(false);
- }
- } else {
- try {
- // Update the permissions for the existing link
- const teamIdParsed = z.string().cuid().parse(currentTeamId);
- const targetIdParsed = z.string().cuid().parse(targetId);
- const permissionGroupIdParsed = z
- .string()
- .cuid()
- .parse(editPermissionLink.permissionGroupId);
-
- const res = await fetch(
- `/api/teams/${teamIdParsed}/datarooms/${targetIdParsed}/permission-groups/${permissionGroupIdParsed}`,
- {
- method: "PUT",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- permissions: permissions,
- linkId: editPermissionLink.id,
- }),
- },
- );
-
- if (!res.ok) {
- const { error } = await res.json();
- throw new Error(error ?? "Failed to update permissions");
- }
-
- // Refresh the links cache
- const endpointTargetType = `${targetType.toLowerCase()}s`;
- mutate(
- `/api/teams/${currentTeamId}/${endpointTargetType}/${encodeURIComponent(
- targetId,
- )}/links`,
- );
-
- // Invalidate the permission group cache
- if (editPermissionLink.permissionGroupId) {
- mutate(
- `/api/teams/${currentTeamId}/datarooms/${targetId}/permission-groups/${editPermissionLink.permissionGroupId}`,
- );
- }
-
- setShowPermissionsSheet(false);
- setEditPermissionLink(null);
- toast.success("File permissions updated successfully");
- } catch (error) {
- console.error("Error updating file permissions:", error);
- toast.error("Failed to update file permissions");
- }
- }
+ // Open the link sheet directly on the file permissions panel so editing
+ // file access happens in the same place as creating a link.
+ setOpenLinkSheetToFiles(true);
+ setSelectedLink(buildLinkFormData(link));
+ //wait for dropdown to close before opening the link sheet
+ setTimeout(() => {
+ setIsLinkSheetVisible(true);
+ }, 0);
};
const AddLinkButton = () => {
@@ -1192,7 +1036,6 @@ export default function LinksTable({
link.audienceType !== LinkAudienceType.GROUP && (
<DropdownMenuItem
onClick={() => handleEditPermissions(link)}
- disabled={isLoading}
>
<FileSlidersIcon className="mr-2 h-4 w-4" />
Edit File Permissions
@@ -1335,26 +1178,19 @@ export default function LinksTable({
<>
<DataroomLinkSheet
isOpen={isLinkSheetVisible}
- setIsOpen={setIsLinkSheetVisible}
+ setIsOpen={(open: boolean) => {
+ setIsLinkSheetVisible(open);
+ if (!open) {
+ setOpenLinkSheetToFiles(false);
+ }
+ }}
linkType={`${targetType}_LINK`}
currentLink={selectedLink.id ? selectedLink : undefined}
existingLinks={links}
linkTargetId={targetId}
+ initialView={openLinkSheetToFiles ? "files" : undefined}
/>
- <PermissionsSheet
- isOpen={showPermissionsSheet}
- setIsOpen={(open: boolean) => {
- setShowPermissionsSheet(open);
- if (!open) {
- setEditPermissionLink(null);
- }
- }}
- dataroomId={targetId}
- linkId={editPermissionLink?.id}
- permissionGroupId={editPermissionLink?.permissionGroupId}
- onSave={handlePermissionsSave}
- />
{inviteLink ? (
<InviteViewersModal
open={isInviteModalOpen}
diff --git a/components/sidebar/dataroom-sidebar.tsx b/components/sidebar/dataroom-sidebar.tsx
index 9c010f30..5f47d68f 100644
--- a/components/sidebar/dataroom-sidebar.tsx
+++ b/components/sidebar/dataroom-sidebar.tsx
@@ -182,7 +182,7 @@ export function DataroomSidebarContent() {
segments: ["permissions", "groups"],
items: [
{
- title: "Links",
+ title: "Access links",
href: `/datarooms/${dataroomId}/permissions`,
icon: LinkIcon,
},
diff --git a/components/ui/multi-select-v2.tsx b/components/ui/multi-select-v2.tsx
index 9ae23c26..4d26fbbb 100644
--- a/components/ui/multi-select-v2.tsx
+++ b/components/ui/multi-select-v2.tsx
@@ -126,6 +126,8 @@ interface MultiSelectProps<
setIsPopoverOpen: React.Dispatch<React.SetStateAction<boolean>>;
loading?: boolean;
triggerIcon?: React.ReactNode;
+ /** Optional content rendered as a pinned footer inside the dropdown. */
+ footer?: React.ReactNode;
}
export type ComboboxOption<
@@ -165,6 +167,7 @@ export const MultiSelect = React.forwardRef<
isPopoverOpen,
loading,
triggerIcon,
+ footer,
...props
},
ref,
@@ -374,6 +377,9 @@ export const MultiSelect = React.forwardRef<
</CommandList>
</ScrollArea>
</Command>
+ {footer ? (
+ <div className="border-t border-border p-1">{footer}</div>
+ ) : null}
</PopoverContent>
{animation > 0 && value.length > 0 && (
<WandSparkles
diff --git a/pages/branding.tsx b/pages/branding.tsx
index 9fd2b0c5..01deea68 100644
--- a/pages/branding.tsx
+++ b/pages/branding.tsx
@@ -29,6 +29,7 @@ import { cn, convertDataUrlToFile, uploadImage } from "@/lib/utils";
import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
import { BannerEditor } from "@/ee/features/branding/components/banner-editor";
+import { BrandingPreviewFrame } from "@/ee/features/branding/components/branding-preview-frame";
import { BrandingLinkPreviewForm } from "@/ee/features/branding/components/branding-link-preview-form";
import { CollapsibleBrandingSection } from "@/ee/features/branding/components/collapsible-branding-section";
import { DataroomLayoutPresetCards } from "@/ee/features/branding/components/dataroom-layout-preset-cards";
@@ -1722,18 +1723,18 @@ export default function Branding() {
</div>
<div className="relative min-h-0 flex-1 overflow-x-auto">
<div className="relative h-full max-w-[1396px]">
- <iframe
- key={`document-view-${debouncedBrandColor}-${debouncedAccentColor}-${debouncedAccentButtonColor}-${previewCtaLabel}-${previewCtaUrl}`}
+ <BrandingPreviewFrame
name="document-view"
- id="document-view"
- src={`/nav_ppreview_demo?brandColor=${encodeURIComponent(debouncedBrandColor)}&accentColor=${encodeURIComponent(debouncedAccentColor)}&brandLogo=${blobUrl ? encodeURIComponent(blobUrl) : logo ? encodeURIComponent(logo) : ""}&accentButtonColor=${encodeURIComponent(debouncedAccentButtonColor)}&ctaLabel=${encodeURIComponent(previewCtaLabel)}&ctaUrl=${encodeURIComponent(previewCtaUrl)}`}
- className="absolute left-0 top-0 h-full w-full origin-top-left scale-50 overflow-hidden rounded-b-lg border-0 bg-white"
- style={{
- width: "200%",
- height: "200%",
- pointerEvents: "none",
+ basePath="/nav_ppreview_demo"
+ params={{
+ brandColor: debouncedBrandColor,
+ accentColor: debouncedAccentColor,
+ brandLogo: blobUrl || logo || "",
+ accentButtonColor: debouncedAccentButtonColor,
+ ctaLabel: previewCtaLabel,
+ ctaUrl: previewCtaUrl,
}}
- ></iframe>
+ />
</div>
</div>
</div>
@@ -1790,16 +1791,28 @@ export default function Branding() {
</div>
<div className="relative min-h-0 flex-1 overflow-x-auto">
<div className="relative h-full max-w-[1396px]">
- <iframe
- key={`dataroom-view-${debouncedBrandColor}-${debouncedAccentColor}-${debouncedAccentButtonColor}-${banner}-${applyAccentColorToDataroomView}-${previewCtaLabel}-${previewCtaUrl}-${cardLayout}-${showFolderTree}-${viewerHeaderStyle}-${hideFolderIconsInMain}`}
+ <BrandingPreviewFrame
name="dataroom-view"
- id="dataroom-view"
- src={`/room_ppreview_demo?brandColor=${encodeURIComponent(debouncedBrandColor)}&accentColor=${encodeURIComponent(debouncedAccentColor)}&applyAccentColorToDataroomView=${applyAccentColorToDataroomView ? "1" : "0"}&brandLogo=${blobUrl ? encodeURIComponent(blobUrl) : logo ? encodeURIComponent(logo) : ""}&brandBanner=${banner === "no-banner" ? encodeURIComponent("no-banner") : bannerBlobUrl ? encodeURIComponent(bannerBlobUrl) : banner ? encodeURIComponent(banner) : ""}&accentButtonColor=${encodeURIComponent(debouncedAccentButtonColor)}&ctaLabel=${encodeURIComponent(previewCtaLabel)}&ctaUrl=${encodeURIComponent(previewCtaUrl)}&cardLayout=${encodeURIComponent(cardLayout)}&showFolderTree=${showFolderTree ? "1" : "0"}&viewerHeaderStyle=${encodeURIComponent(viewerHeaderStyle)}&hideFolderIconsInMain=${hideFolderIconsInMain ? "1" : "0"}`}
- className="absolute left-0 top-0 h-full w-full origin-top-left scale-50 overflow-hidden rounded-b-lg border-0 bg-white"
- style={{
- width: "200%",
- height: "200%",
- pointerEvents: "none",
+ basePath="/room_ppreview_demo"
+ params={{
+ brandColor: debouncedBrandColor,
+ accentColor: debouncedAccentColor,
+ applyAccentColorToDataroomView:
+ applyAccentColorToDataroomView ? "1" : "0",
+ brandLogo: blobUrl || logo || "",
+ brandBanner:
+ banner === "no-banner"
+ ? "no-banner"
+ : bannerBlobUrl || banner || "",
+ accentButtonColor: debouncedAccentButtonColor,
+ ctaLabel: previewCtaLabel,
+ ctaUrl: previewCtaUrl,
+ cardLayout,
+ showFolderTree: showFolderTree ? "1" : "0",
+ viewerHeaderStyle,
+ hideFolderIconsInMain: hideFolderIconsInMain
+ ? "1"
+ : "0",
}}
/>
</div>
@@ -1858,18 +1871,16 @@ export default function Branding() {
</div>
<div className="relative min-h-0 flex-1 overflow-x-auto">
<div className="relative h-full max-w-[1396px]">
- <iframe
- key={`access-screen-${debouncedBrandColor}-${debouncedAccentColor}-${previewWelcomeMessage}`}
+ <BrandingPreviewFrame
name="access-screen"
- id="access-screen"
- src={`/entrance_ppreview_demo?brandColor=${encodeURIComponent(debouncedBrandColor)}&accentColor=${encodeURIComponent(debouncedAccentColor)}&brandLogo=${blobUrl ? encodeURIComponent(blobUrl) : logo ? encodeURIComponent(logo) : ""}&welcomeMessage=${encodeURIComponent(previewWelcomeMessage)}`}
- className="absolute left-0 top-0 h-full w-full origin-top-left scale-50 overflow-hidden rounded-b-lg border-0 bg-white"
- style={{
- width: "200%",
- height: "200%",
- pointerEvents: "none",
+ basePath="/entrance_ppreview_demo"
+ params={{
+ brandColor: debouncedBrandColor,
+ accentColor: debouncedAccentColor,
+ brandLogo: blobUrl || logo || "",
+ welcomeMessage: previewWelcomeMessage,
}}
- ></iframe>
+ />
</div>
</div>
</div>
diff --git a/pages/custom_fields_ppreview_demo.tsx b/pages/custom_fields_ppreview_demo.tsx
new file mode 100644
index 00000000..6be9e543
--- /dev/null
+++ b/pages/custom_fields_ppreview_demo.tsx
@@ -0,0 +1,264 @@
+import { useRouter } from "next/router";
+import { type CSSProperties, useEffect, useRef, useState } from "react";
+
+import { CustomField } from "@prisma/client";
+import { EyeOff } from "lucide-react";
+
+import {
+ ACCESS_PREVIEW_MESSAGE,
+ ACCESS_PREVIEW_READY,
+ type AccessPreviewPayload,
+} from "@/components/links/link-sheet/access-preview-message";
+import { Button } from "@/components/ui/button";
+import { Checkbox } from "@/components/ui/checkbox";
+import {
+ AccessFormThemeProvider,
+ createAccessFormTheme,
+} from "@/components/view/access-form/access-form-theme";
+import CustomFieldsViewer from "@/components/view/access-form/custom-fields-section";
+
+type PreviewState = {
+ accentColor?: string;
+ welcomeMessage: string;
+ requireEmail: boolean;
+ requirePassword: boolean;
+ requireAgreement: boolean;
+ fields: Partial<CustomField>[];
+};
+
+const DEFAULT_STATE: PreviewState = {
+ welcomeMessage: "",
+ requireEmail: true,
+ requirePassword: false,
+ requireAgreement: false,
+ fields: [],
+};
+
+export default function CustomFieldsPreviewDemo() {
+ const router = useRouter();
+ const [state, setState] = useState<PreviewState>(DEFAULT_STATE);
+ // Bootstrap from the URL at most once, and never after a live message has
+ // already arrived — otherwise a late `router.isReady` flip would clobber the
+ // freshest streamed state with the stale initial URL values.
+ const bootstrappedRef = useRef(false);
+ const messageReceivedRef = useRef(false);
+
+ // First paint: hydrate from the URL the parent baked the initial state into.
+ useEffect(() => {
+ if (!router.isReady || bootstrappedRef.current || messageReceivedRef.current)
+ return;
+ bootstrappedRef.current = true;
+ const {
+ accentColor,
+ welcomeMessage,
+ requireEmail,
+ requirePassword,
+ requireAgreement,
+ fields,
+ } = router.query as Record<string, string | undefined>;
+
+ let parsedFields: Partial<CustomField>[] = [];
+ try {
+ parsedFields = fields ? JSON.parse(fields) : [];
+ } catch {
+ parsedFields = [];
+ }
+
+ setState({
+ accentColor,
+ welcomeMessage: welcomeMessage ?? "",
+ requireEmail: requireEmail !== "false",
+ requirePassword: requirePassword === "true",
+ requireAgreement: requireAgreement === "true",
+ fields: parsedFields,
+ });
+ }, [router.isReady, router.query]);
+
+ // Live updates: the editor streams changes over postMessage so the preview
+ // never has to reload (and therefore never flashes).
+ useEffect(() => {
+ const onMessage = (event: MessageEvent) => {
+ if (event.origin !== window.location.origin) return;
+ if (event.data?.type !== ACCESS_PREVIEW_MESSAGE) return;
+ messageReceivedRef.current = true;
+ const payload = event.data.payload as AccessPreviewPayload;
+ setState((prev) => ({
+ ...prev,
+ welcomeMessage: payload.welcomeMessage ?? "",
+ requireEmail: !!payload.requireEmail,
+ requirePassword: !!payload.requirePassword,
+ requireAgreement: !!payload.requireAgreement,
+ fields: Array.isArray(payload.fields)
+ ? (payload.fields as Partial<CustomField>[])
+ : [],
+ }));
+ };
+
+ window.addEventListener("message", onMessage);
+ // Tell the parent the listener is attached and it can start streaming.
+ window.parent?.postMessage(
+ { type: ACCESS_PREVIEW_READY },
+ window.location.origin,
+ );
+ return () => window.removeEventListener("message", onMessage);
+ }, []);
+
+ const theme = createAccessFormTheme(state.accentColor);
+
+ const parsedFields = state.fields;
+ const { welcomeMessage, accentColor } = state;
+ const showEmail = state.requireEmail;
+ const showPassword = state.requirePassword;
+ const showAgreement = state.requireAgreement;
+
+ return (
+ <div
+ className="bg-gray-950"
+ style={{ backgroundColor: accentColor || theme.backgroundColor }}
+ >
+ <div className="mx-auto px-2 sm:px-6 lg:px-8">
+ <div className="relative flex h-16 items-center justify-between">
+ <div className="mt-20 flex flex-1 items-stretch justify-center"></div>
+ </div>
+ <div className="sm:mx-auto sm:w-full sm:max-w-md">
+ <h1
+ className="mt-16 text-2xl font-bold leading-9 tracking-tight text-white"
+ style={{ color: theme.textColor }}
+ >
+ {welcomeMessage || "Your action is requested to continue"}
+ </h1>
+ </div>
+
+ <div className="mt-10 sm:mx-auto sm:w-full sm:max-w-md">
+ <AccessFormThemeProvider value={theme}>
+ <form className="space-y-4">
+ {showEmail && (
+ <div className="pb-1">
+ <div className="relative space-y-2 rounded-md shadow-sm">
+ <label
+ htmlFor="email"
+ className="block text-sm font-medium leading-6 text-white"
+ style={{ color: theme.textColor }}
+ >
+ Email address
+ </label>
+ <input
+ name="email"
+ id="email"
+ type="email"
+ readOnly
+ className="flex w-full cursor-text rounded-md border-0 bg-black py-1.5 text-white shadow-sm ring-1 ring-inset ring-gray-600 placeholder:text-[var(--access-placeholder)] sm:text-sm sm:leading-6"
+ style={
+ {
+ backgroundColor: theme.controlBgColor,
+ borderColor: theme.controlBorderColor,
+ "--access-placeholder": theme.controlPlaceholderColor,
+ "--access-input-focus":
+ theme.controlBorderStrongColor,
+ color: theme.textColor,
+ } as CSSProperties
+ }
+ placeholder="Enter email"
+ data-1p-ignore
+ />
+ <p
+ className="text-sm"
+ style={{ color: theme.subtleTextColor }}
+ >
+ This data will be shared with the sender.
+ </p>
+ </div>
+ </div>
+ )}
+
+ {showPassword && (
+ <div className="space-y-2 rounded-md shadow-sm">
+ <label
+ htmlFor="password"
+ className="block text-sm font-medium leading-6 text-white"
+ style={{ color: theme.textColor }}
+ >
+ Passcode
+ </label>
+ <div className="relative">
+ <input
+ name="password"
+ id="password"
+ type="password"
+ readOnly
+ className="flex w-full cursor-text rounded-md border-0 bg-black py-1.5 text-white shadow-sm ring-1 ring-inset ring-gray-600 placeholder:text-[var(--access-placeholder)] sm:text-sm sm:leading-6"
+ style={
+ {
+ backgroundColor: theme.controlBgColor,
+ borderColor: theme.controlBorderColor,
+ "--access-placeholder": theme.controlPlaceholderColor,
+ color: theme.textColor,
+ } as CSSProperties
+ }
+ placeholder="Enter passcode"
+ data-1p-ignore
+ />
+ <span className="absolute inset-y-0 right-0 flex items-center pr-3">
+ <EyeOff
+ className="h-4 w-4"
+ style={{ color: theme.controlIconColor }}
+ aria-hidden="true"
+ />
+ </span>
+ </div>
+ </div>
+ )}
+
+ <CustomFieldsViewer
+ fields={parsedFields}
+ data={{}}
+ setData={() => {}}
+ />
+
+ {showAgreement && (
+ <div className="relative flex items-start space-x-2 pt-5">
+ <Checkbox
+ id="agreement"
+ checked={false}
+ className="border border-gray-400"
+ style={
+ {
+ borderColor: theme.controlBorderStrongColor,
+ } as CSSProperties
+ }
+ />
+ <label
+ className="text-sm font-normal leading-5 text-white"
+ style={{ color: theme.textColor }}
+ >
+ I have reviewed and agree to the terms of this agreement.
+ </label>
+ </div>
+ )}
+
+ <div className="flex justify-center pt-5">
+ <Button
+ type="button"
+ className="w-1/3 min-w-fit bg-white text-gray-950 hover:bg-white/90"
+ style={{
+ backgroundColor: theme.ctaBgColor,
+ color: theme.ctaTextColor,
+ }}
+ >
+ Continue
+ </Button>
+ </div>
+ </form>
+ </AccessFormThemeProvider>
+ </div>
+ </div>
+
+ <div
+ style={{ height: "calc(100vh - 64px)" }}
+ className="relative flex items-center"
+ >
+ <div className="relative mx-auto flex h-full w-full justify-center"></div>
+ </div>
+ </div>
+ );
+}
diff --git a/pages/datarooms/[id]/branding/index.tsx b/pages/datarooms/[id]/branding/index.tsx
index c4e3e36d..d6ffa7a4 100644
--- a/pages/datarooms/[id]/branding/index.tsx
+++ b/pages/datarooms/[id]/branding/index.tsx
@@ -30,6 +30,7 @@ import {
import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
import { BannerEditor } from "@/ee/features/branding/components/banner-editor";
+import { BrandingPreviewFrame } from "@/ee/features/branding/components/branding-preview-frame";
import { CollapsibleBrandingSection } from "@/ee/features/branding/components/collapsible-branding-section";
import { DataroomLayoutPresetCards } from "@/ee/features/branding/components/dataroom-layout-preset-cards";
import { BrandingLinkPreviewForm } from "@/ee/features/branding/components/branding-link-preview-form";
@@ -829,36 +830,35 @@ export default function DataroomBrandPage() {
}
};
- // Build preview iframe URL with all branding + layout params so the embedded
- // demo page can render an accurate preview.
- const buildPreviewQuery = () => {
- const params = new URLSearchParams();
- params.set("brandColor", debouncedBrandColor);
- params.set("accentColor", debouncedAccentColor);
- params.set(
- "applyAccentColorToDataroomView",
- applyAccentColorToDataroomView ? "1" : "0",
- );
+ // Build preview params with all branding + layout values so the embedded
+ // demo page can render an accurate preview. Shared by the initial iframe URL
+ // and the live postMessage stream (see `BrandingPreviewFrame`).
+ const buildRoomPreviewParams = (): Record<string, string> => {
+ const params: Record<string, string> = {
+ brandColor: debouncedBrandColor,
+ accentColor: debouncedAccentColor,
+ applyAccentColorToDataroomView: applyAccentColorToDataroomView
+ ? "1"
+ : "0",
+ cardLayout,
+ showFolderTree: showFolderTree ? "1" : "0",
+ viewerHeaderStyle,
+ hideFolderIconsInMain: hideFolderIconsInMain ? "1" : "0",
+ };
const logoSrc = blobUrl || logo || "";
- if (logoSrc) params.set("brandLogo", logoSrc);
+ if (logoSrc) params.brandLogo = logoSrc;
const bannerSrc =
- banner === "no-banner"
- ? "no-banner"
- : bannerBlobUrl || banner || "";
- if (bannerSrc) params.set("brandBanner", bannerSrc);
- params.set("cardLayout", cardLayout);
- params.set("showFolderTree", showFolderTree ? "1" : "0");
+ banner === "no-banner" ? "no-banner" : bannerBlobUrl || banner || "";
+ if (bannerSrc) params.brandBanner = bannerSrc;
// When the toggle is on we always render a preview button so the user can
// see the styling, even before they type a label/url. Real viewers still
// require both fields.
if (hasBusinessMessagingAccess && ctaEnabled) {
- params.set("ctaLabel", ctaLabel.trim() || "Book a call");
- params.set("ctaUrl", ctaUrl.trim() || "#");
+ params.ctaLabel = ctaLabel.trim() || "Book a call";
+ params.ctaUrl = ctaUrl.trim() || "#";
}
- if (accentButtonColor) params.set("accentButtonColor", accentButtonColor);
- params.set("viewerHeaderStyle", viewerHeaderStyle);
- params.set("hideFolderIconsInMain", hideFolderIconsInMain ? "1" : "0");
- return params.toString();
+ if (accentButtonColor) params.accentButtonColor = accentButtonColor;
+ return params;
};
return (
@@ -1893,17 +1893,10 @@ export default function DataroomBrandPage() {
</div>
<div className="relative min-h-0 flex-1 overflow-x-auto">
<div className="relative h-full max-w-[1396px]">
- <iframe
- key={`dataroom-view-${debouncedBrandColor}-${debouncedAccentColor}-${banner}-${cardLayout}-${showFolderTree}-${viewerHeaderStyle}-${hideFolderIconsInMain}-${ctaLabel}`}
+ <BrandingPreviewFrame
name="dataroom-view"
- id="dataroom-view"
- src={`/room_ppreview_demo?${buildPreviewQuery()}`}
- className="absolute left-0 top-0 h-full w-full origin-top-left scale-50 overflow-hidden rounded-b-lg border-0 bg-white"
- style={{
- width: "200%",
- height: "200%",
- pointerEvents: "none",
- }}
+ basePath="/room_ppreview_demo"
+ params={buildRoomPreviewParams()}
/>
</div>
</div>
@@ -1961,16 +1954,13 @@ export default function DataroomBrandPage() {
</div>
<div className="relative min-h-0 flex-1 overflow-x-auto">
<div className="relative h-full max-w-[1396px]">
- <iframe
- key={`document-view-${debouncedBrandColor}-${debouncedAccentColor}`}
+ <BrandingPreviewFrame
name="document-view"
- id="document-view"
- src={`/nav_ppreview_demo?brandColor=${encodeURIComponent(debouncedBrandColor)}&accentColor=${encodeURIComponent(debouncedAccentColor)}&brandLogo=${blobUrl ? encodeURIComponent(blobUrl) : logo ? encodeURIComponent(logo) : ""}`}
- className="absolute left-0 top-0 h-full w-full origin-top-left scale-50 overflow-hidden rounded-b-lg border-0 bg-white"
- style={{
- width: "200%",
- height: "200%",
- pointerEvents: "none",
+ basePath="/nav_ppreview_demo"
+ params={{
+ brandColor: debouncedBrandColor,
+ accentColor: debouncedAccentColor,
+ brandLogo: blobUrl || logo || "",
}}
/>
</div>
@@ -2028,16 +2018,14 @@ export default function DataroomBrandPage() {
</div>
<div className="relative min-h-0 flex-1 overflow-x-auto">
<div className="relative h-full max-w-[1396px]">
- <iframe
- key={`access-screen-${debouncedBrandColor}-${debouncedAccentColor}-${previewWelcomeMessage}`}
+ <BrandingPreviewFrame
name="access-screen"
- id="access-screen"
- src={`/entrance_ppreview_demo?brandColor=${encodeURIComponent(debouncedBrandColor)}&accentColor=${encodeURIComponent(debouncedAccentColor)}&brandLogo=${blobUrl ? encodeURIComponent(blobUrl) : logo ? encodeURIComponent(logo) : ""}&welcomeMessage=${encodeURIComponent(previewWelcomeMessage)}`}
- className="absolute left-0 top-0 h-full w-full origin-top-left scale-50 overflow-hidden rounded-b-lg border-0 bg-white"
- style={{
- width: "200%",
- height: "200%",
- pointerEvents: "none",
+ basePath="/entrance_ppreview_demo"
+ params={{
+ brandColor: debouncedBrandColor,
+ accentColor: debouncedAccentColor,
+ brandLogo: blobUrl || logo || "",
+ welcomeMessage: previewWelcomeMessage,
}}
/>
</div>
diff --git a/pages/datarooms/[id]/permissions/index.tsx b/pages/datarooms/[id]/permissions/index.tsx
index e877bd31..291de405 100644
--- a/pages/datarooms/[id]/permissions/index.tsx
+++ b/pages/datarooms/[id]/permissions/index.tsx
@@ -1,6 +1,6 @@
import dynamic from "next/dynamic";
-import { useState } from "react";
+import { useEffect, useRef, useState } from "react";
import { InviteViewersModal } from "@/ee/features/dataroom-invitations/components/invite-viewers-modal";
import {
@@ -38,7 +38,7 @@ const BulkImportLinksModal = dynamic(
export default function DataroomLinksPage() {
const { dataroom } = useDataroom();
- const { links } = useDataroomLinks();
+ const { links, loading: linksLoading } = useDataroomLinks();
const { isDatarooms, isDataroomsPlus, isTrial } = usePlan();
const { isFeatureEnabled } = useFeatureFlags();
const canInviteViewers =
@@ -48,6 +48,24 @@ export default function DataroomLinksPage() {
const [isInviteModalOpen, setIsInviteModalOpen] = useState(false);
const [isBulkImportOpen, setIsBulkImportOpen] = useState(false);
+ // First-time experience: when the data room has no links yet, auto-open the
+ // link sheet. With no existing links it opens with both panels (link access
+ // controls + granular file permissions) side by side; once a link exists it
+ // opens showing just the link settings. Guard with a ref so it only opens
+ // once per visit and never reopens after the user closes it.
+ const didAutoOpenRef = useRef(false);
+ useEffect(() => {
+ if (
+ !didAutoOpenRef.current &&
+ !linksLoading &&
+ links &&
+ links.length === 0
+ ) {
+ didAutoOpenRef.current = true;
+ setIsLinkSheetOpen(true);
+ }
+ }, [linksLoading, links]);
+
if (!dataroom) {
return <div>Loading...</div>;
}
@@ -58,7 +76,7 @@ export default function DataroomLinksPage() {
<div className="flex items-start justify-between">
<div className="space-y-1">
<h3 className="text-2xl font-semibold tracking-tight text-foreground">
- Links
+ Access links
</h3>
<p className="flex flex-row items-center gap-2 text-sm text-muted-foreground">
Share your data room with access controls.
@@ -109,7 +127,7 @@ export default function DataroomLinksPage() {
<TabMenu
navigation={[
{
- label: "Links",
+ label: "Access links",
href: `/datarooms/${dataroom.id}/permissions`,
value: "links",
currentValue: "links",
diff --git a/pages/entrance_ppreview_demo.tsx b/pages/entrance_ppreview_demo.tsx
index ca3b90fb..30f6f0fb 100644
--- a/pages/entrance_ppreview_demo.tsx
+++ b/pages/entrance_ppreview_demo.tsx
@@ -1,16 +1,14 @@
-import { useRouter } from "next/router";
import type { CSSProperties } from "react";
+import { useBrandingPreviewParams } from "@/ee/features/branding/lib/use-branding-preview-params";
import { createAdaptiveSurfacePalette } from "@/lib/utils/create-adaptive-surface-palette";
import { Button } from "@/components/ui/button";
export default function ViewPage() {
- const router = useRouter();
- const { accentColor, welcomeMessage } = router.query as {
- accentColor: string;
- welcomeMessage?: string;
- };
+ // Seeded from the URL on first paint, then live-updated over postMessage so
+ // the editor never has to reload (and therefore never flashes) this iframe.
+ const { accentColor, welcomeMessage } = useBrandingPreviewParams();
const palette = createAdaptiveSurfacePalette(accentColor);
return (
diff --git a/pages/nav_ppreview_demo.tsx b/pages/nav_ppreview_demo.tsx
index 3e1a4337..998d9d46 100644
--- a/pages/nav_ppreview_demo.tsx
+++ b/pages/nav_ppreview_demo.tsx
@@ -1,9 +1,10 @@
-import { useRouter } from "next/router";
-
import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
+import { useBrandingPreviewParams } from "@/ee/features/branding/lib/use-branding-preview-params";
+
export default function ViewPage() {
- const router = useRouter();
+ // Seeded from the URL on first paint, then live-updated over postMessage so
+ // the editor never has to reload (and therefore never flashes) this iframe.
const {
brandLogo,
brandColor,
@@ -11,14 +12,7 @@ export default function ViewPage() {
accentButtonColor,
ctaLabel,
ctaUrl,
- } = router.query as {
- brandLogo: string;
- brandColor: string;
- accentColor: string;
- accentButtonColor?: string;
- ctaLabel?: string;
- ctaUrl?: string;
- };
+ } = useBrandingPreviewParams();
const safeCtaUrl = (() => {
if (!ctaUrl) return null;
diff --git a/pages/room_ppreview_demo.tsx b/pages/room_ppreview_demo.tsx
index f9fb8b32..9fe1227e 100644
--- a/pages/room_ppreview_demo.tsx
+++ b/pages/room_ppreview_demo.tsx
@@ -1,14 +1,19 @@
-import { useRouter } from "next/router";
-
import { type CSSProperties, type ReactNode, useMemo, useState } from "react";
import {
type DataroomCardLayout,
type DataroomViewerHeaderStyle,
} from "@/ee/features/branding/lib/dataroom-viewer-layout";
+import { useBrandingPreviewParams } from "@/ee/features/branding/lib/use-branding-preview-params";
import { PlayIcon } from "lucide-react";
+import {
+ buildViewerI18nPageProps,
+ type ViewerI18nPageProps,
+} from "@/lib/i18n/viewer-page-props";
+
+import { ViewerI18nProvider } from "@/components/view/viewer-i18n-provider";
import { ViewFolderTree } from "@/components/datarooms/folders";
import {
Breadcrumb,
@@ -185,9 +190,9 @@ function VideoBannerPreview({
}
/** Preview iframe: align with dataroom viewer (sharp corners, optional folder tree). */
-export default function ViewPage() {
- const router = useRouter();
- const [previewFolderId, setPreviewFolderId] = useState<string | null>(null);
+export default function ViewPage({ i18n }: ViewerI18nPageProps) {
+ // Seeded from the URL on first paint, then live-updated over postMessage so
+ // the editor never has to reload (and therefore never flashes) this iframe.
const {
brandLogo,
brandColor,
@@ -201,20 +206,8 @@ export default function ViewPage() {
accentButtonColor,
viewerHeaderStyle: viewerHeaderStyleParam,
hideFolderIconsInMain: hideFolderIconsMainParam,
- } = router.query as {
- brandLogo?: string;
- brandColor?: string;
- brandBanner?: string;
- accentColor?: string;
- applyAccentColorToDataroomView?: string;
- cardLayout?: string;
- showFolderTree?: string;
- ctaLabel?: string;
- ctaUrl?: string;
- accentButtonColor?: string;
- viewerHeaderStyle?: string;
- hideFolderIconsInMain?: string;
- };
+ } = useBrandingPreviewParams();
+ const [previewFolderId, setPreviewFolderId] = useState<string | null>(null);
// Always the same "Example Virtual Data Room" — keeps the preview consistent
// across pages and avoids depending on per-team onboarding answers.
@@ -333,15 +326,21 @@ export default function ViewPage() {
);
return (
- <div
- className="min-h-screen bg-white"
- style={
- {
- backgroundColor: dataroomViewBackgroundColor,
- } as CSSProperties
- }
- >
- {/* Header — matches live viewer modes */}
+ // The cards below call `useTranslation` — without an initialized i18n
+ // instance they'd render the raw `Updated {{when}}` template on the client
+ // while the server interpolates it, tripping a hydration mismatch. Wrapping
+ // the tree in the same provider the live viewer uses keeps both sides in
+ // lockstep.
+ <ViewerI18nProvider locale={i18n.locale} resources={i18n.resources}>
+ <div
+ className="min-h-screen bg-white"
+ style={
+ {
+ backgroundColor: dataroomViewBackgroundColor,
+ } as CSSProperties
+ }
+ >
+ {/* Header — matches live viewer modes */}
<nav
className={cn(
headerMode === "SPLIT"
@@ -878,6 +877,18 @@ export default function ViewPage() {
</div>
</div>
</ViewerSurfaceThemeProvider>
- </div>
+ </div>
+ </ViewerI18nProvider>
);
}
+
+/**
+ * Load the viewer translation bundles at build time so the preview iframe
+ * renders translated card copy identically on the server and the client. We
+ * always use the default locale here — the branding preview isn't a live
+ * visitor surface, so there's no per-brand language to resolve.
+ */
+export const getStaticProps = async () => {
+ const props = await buildViewerI18nPageProps(null);
+ return { props };
+};