Skip to content

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

feat: improve intro page and q&a permission

Marc Seitzf4e5850d50a6
diff --git a/components/datarooms/settings/introduction-settings.tsx b/components/datarooms/settings/introduction-settings.tsx
index 6568b17d..abc537d7 100644
--- a/components/datarooms/settings/introduction-settings.tsx
+++ b/components/datarooms/settings/introduction-settings.tsx
@@ -8,7 +8,7 @@ import { toast } from "sonner";
import { mutate } from "swr";
import { usePlan } from "@/lib/swr/use-billing";
-import { uploadImage } from "@/lib/utils";
+import { cn, uploadImage } from "@/lib/utils";
import { PlanEnum } from "@/ee/stripe/constants";
@@ -20,9 +20,11 @@ import {
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog";
+import { Label } from "@/components/ui/label";
import LoadingSpinner from "@/components/ui/loading-spinner";
import { RichTextEditor } from "@/components/ui/rich-text-editor";
import { ScrollArea } from "@/components/ui/scroll-area";
+import { Switch } from "@/components/ui/switch";
interface IntroductionSettingsProps {
dataroomId: string;
@@ -633,9 +635,6 @@ export default function IntroductionSettings({
return;
}
setIntroductionEnabled(checked);
- if (checked) {
- toast.success("Introduction page enabled");
- }
};
const hasContent =
@@ -651,39 +650,83 @@ export default function IntroductionSettings({
return (
<div className="space-y-6">
- <div className="flex items-center gap-3">
- <Button
- variant="outline"
- size="sm"
- onClick={() => setShowPreview(true)}
- disabled={!hasContent}
- >
- <EyeIcon className="mr-1.5 h-4 w-4" />
- Preview
- </Button>
- {isFeatureAvailable ? (
+ <div
+ className={cn(
+ "flex flex-col gap-4 rounded-lg border p-4 transition-colors sm:flex-row sm:items-center sm:justify-between sm:gap-6 sm:px-5",
+ introductionEnabled && isFeatureAvailable
+ ? "border-emerald-200 bg-emerald-50/50 dark:border-emerald-900/40 dark:bg-emerald-950/20"
+ : "border-border bg-muted/30",
+ )}
+ >
+ <div className="flex items-start gap-3">
+ <span
+ className={cn(
+ "mt-1.5 inline-flex h-2 w-2 shrink-0 rounded-full ring-4 transition-colors",
+ introductionEnabled && isFeatureAvailable
+ ? "bg-emerald-500 ring-emerald-500/15"
+ : "bg-muted-foreground/40 ring-muted-foreground/10",
+ )}
+ aria-hidden="true"
+ />
+ <div className="space-y-0.5">
+ <Label
+ htmlFor="introduction-toggle"
+ className="block cursor-pointer text-sm font-medium text-foreground"
+ >
+ {introductionEnabled && isFeatureAvailable
+ ? "Introduction page is on"
+ : "Introduction page is off"}
+ </Label>
+ <p className="text-xs text-muted-foreground">
+ {introductionEnabled && isFeatureAvailable
+ ? "Viewers see this page when they first open the data room."
+ : "Turn on to show this page to viewers on their first visit."}
+ </p>
+ </div>
+ </div>
+
+ <div className="flex items-center gap-2 sm:gap-3">
+ {isSaving && (
+ <span
+ className="text-xs text-muted-foreground"
+ aria-live="polite"
+ >
+ Saving…
+ </span>
+ )}
<Button
- variant={introductionEnabled ? "default" : "outline"}
+ variant="outline"
size="sm"
- onClick={() => handleToggle(!introductionEnabled)}
+ onClick={() => setShowPreview(true)}
+ disabled={!hasContent}
>
- {introductionEnabled ? "Enabled" : "Disabled"}
+ <EyeIcon className="mr-1.5 h-4 w-4" />
+ Preview
</Button>
- ) : (
- <UpgradePlanModal
- clickedPlan={PlanEnum.DataRoomsPlus}
- trigger="dataroom_introduction_settings"
- highlightItem={["introduction"]}
- >
- <Button variant="outline" size="sm" className="gap-1.5">
- <CrownIcon className="h-4 w-4" />
- Upgrade to Enable
- </Button>
- </UpgradePlanModal>
- )}
- {isSaving && (
- <span className="text-xs text-muted-foreground">Saving...</span>
- )}
+ {isFeatureAvailable ? (
+ <Switch
+ id="introduction-toggle"
+ checked={introductionEnabled}
+ onCheckedChange={handleToggle}
+ aria-label={
+ introductionEnabled
+ ? "Disable introduction page"
+ : "Enable introduction page"
+ }
+ />
+ ) : (
+ <UpgradePlanModal
+ clickedPlan={PlanEnum.DataRoomsPlus}
+ trigger="dataroom_introduction_settings"
+ highlightItem={["introduction"]}
+ >
+ <Button variant="outline" size="sm" className="gap-1.5">
+ <CrownIcon className="h-4 w-4" />
+ Upgrade to enable
+ </Button>
+ </UpgradePlanModal>
+ )}
+ </div>
</div>
{/* Rich Text Editor */}