Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
feat: updates sidebar for data rooms
Marc Seitz006293baea92
diff --git a/components/sidebar/app-sidebar.tsx b/components/sidebar/app-sidebar.tsxindex 0e309d56..faaeb93e 100644--- a/components/sidebar/app-sidebar.tsx+++ b/components/sidebar/app-sidebar.tsx@@ -20,6 +20,7 @@ import {} from "lucide-react";import { usePlan } from "@/lib/swr/use-billing";+import useDatarooms from "@/lib/swr/use-datarooms";import useLimits from "@/lib/swr/use-limits";import { useSlackIntegration } from "@/lib/swr/use-slack-integration";import { nFormatter } from "@/lib/utils";@@ -70,6 +71,9 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {enabled: !!currentTeam?.id,});+ // Fetch datarooms for the current team+ const { datarooms } = useDatarooms();+useEffect(() => {if (Cookies.get("hideProBanner") !== "pro-banner") {setShowProBanner(true);@@ -88,6 +92,24 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {}}, []);+ // Prepare datarooms items for sidebar (limit to first 5, sorted by most recent)+ const dataroomItems =+ datarooms && datarooms.length > 0+ ? datarooms+ .sort(+ (a, b) =>+ new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime(),+ )+ .slice(0, 5)+ .map((dataroom) => ({+ title: dataroom.name,+ url: `/datarooms/${dataroom.id}/documents`,+ current:+ router.pathname.includes("/datarooms/[id]") &&+ String(router.query.id) === String(dataroom.id),+ }))+ : undefined;+const data = {navMain: [{@@ -108,11 +130,13 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {title: "All Datarooms",url: "/datarooms",icon: ServerIcon,- current: router.pathname.includes("datarooms"),+ current: router.pathname === "/datarooms",disabled: !isBusiness && !isDatarooms && !isDataroomsPlus && !isTrial,trigger: "sidebar_datarooms",plan: PlanEnum.Business,highlightItem: ["datarooms"],+ isActive: router.pathname.includes("datarooms"),+ items: dataroomItems,},{title: "Visitors",diff --git a/components/sidebar/nav-main.tsx b/components/sidebar/nav-main.tsxindex 838e2e00..4005f659 100644--- a/components/sidebar/nav-main.tsx+++ b/components/sidebar/nav-main.tsx@@ -49,13 +49,19 @@ export function NavMain({ items }: { items: NavItem[] }) {<SidebarMenu className="space-y-0.5 text-foreground">{items.map((item) => (<Collapsible key={item.title} asChild defaultOpen={item.isActive}>- <SidebarMenuItem- className={cn(- item.current &&- "rounded-md bg-gray-200 font-semibold dark:bg-secondary",- )}- >- <SidebarMenuButton asChild tooltip={item.title}>+ <SidebarMenuItem>+ <SidebarMenuButton+ asChild+ tooltip={item.title}+ className={cn(+ item.current &&+ item.items?.length &&+ "rounded-md bg-gray-200 font-semibold dark:bg-secondary",+ item.current &&+ !item.items?.length &&+ "rounded-md bg-gray-200 font-semibold dark:bg-secondary",+ )}+ >{item.disabled ? (<UpgradePlanModalkey={item.title}