mirror of
https://github.com/hanzo-apps/dataroom.git
synced 2026-10-30 14:47:36 +00:00
Papermark dual-licenses: AGPL-3.0 for the tree, a separate commercial
licence for ee/. We hold the first and not the second, so none of the
second may live here.
ee/ was already absent from main, but it was never deleted. 98f0da7fa
("ci: amd64-only build") renamed 150 files out of ee/ byte-identical
into features/, lib/billing/legacy/ (ee/stripe), lib/billing/limits/
(ee/limits), and flattened app/(ee)/ into app/ — putting commercially
licensed code under our AGPL root LICENSE. A rename is not a deletion.
Every path that commit moved is now gone, edited-since or not.
Deleted, with their routes and UI entry points: features/ai and
app/api/ai, features/workflows and app/api/{workflows,workflow-entry},
features/conversations and the Q&A/FAQ surface, features/security/sso
with app/api/auth/saml + app/api/scim + lib/jackson.ts (we use Hanzo
IAM OIDC natively), features/dataroom-invitations, features/templates,
features/access-notifications, features/conversions, features/
permissions. Five of these were gated by lib/featureFlags, which reads
@vercel/edge-config and returns false for every flag when EDGE_CONFIG
is unset — every non-Vercel deployment we run. Those flags are gone too.
Deleted the commercial gating outright rather than reimplementing it:
lib/billing/legacy (ee/stripe) and lib/billing/limits (ee/limits), the
upgrade modals and banners, UpgradeButton, FeaturePreview, PlanBadge,
the trial and blocking modals, /settings/upgrade, /settings/billing and
the billing checkout/seat/pause/cancel API. usePlan() no longer returns
capability booleans — the plan tag describes provisioning, it is not a
permission — and useLimits() is gone with every quota check it fed.
Subscription pause went the same way. Also dropped the npm dependencies
that existed only for the removed features (@boxyhq/saml-jackson, the
@ai-sdk packages, openai, streamdown, use-stick-to-bottom,
@trigger.dev/python) and the Jackson-specific next.config webpack shims.
Rewritten as original Hanzo code where a capability was load-bearing:
- lib/utils/get-file-size-limits.ts — one UPLOAD_LIMITS set plus
getFileSizeLimit(contentType), env-overridable. Operational limits,
not commercial ones, so the tus and browser-upload paths still refuse
oversized files without consulting a plan matrix.
- components/links/link-sheet/permissions-sheet.tsx — a flat, depth
annotated item list with view/download switches over the same
/permission-groups API. Two states, not three. ItemPermission now has
a single definition in lib/types.ts.
- app/api/links/[id]/upload/route.ts — visitor uploads, built around one
authorize() helper shared by GET and POST, and a notification debounce
keyed per (link, viewer) instead of listing and cancelling runs.
There is now exactly one link sheet: the ee DataroomLinkSheet duplicated
the AGPL LinkSheet, which already handled DATAROOM_LINK. Replaced
upstream's Omit<LinkType, "WORKFLOW_LINK"> — Omit on a string union
yields an object type and never narrowed anything — with a real union.
Verified: the S3/tus upload+download harness passes 13/13 against MinIO
after the deletions, and tsc goes from 257 pre-existing errors on
origin/main to 192 with zero files worse than baseline.
Reasoning recorded in LLM.md. LICENSE untouched.
Co-authored-by: Hanzo Dev <[email protected]>
522 lines
14 KiB
TypeScript
522 lines
14 KiB
TypeScript
import Link from "next/link";
|
|
import { useRouter } from "next/router";
|
|
|
|
import React, { useEffect, useMemo, useRef, useState } from "react";
|
|
|
|
import { useDataroom } from "@/lib/swr/use-dataroom";
|
|
import { useDocument } from "@/lib/swr/use-document";
|
|
import { useFolderWithParents } from "@/lib/swr/use-folders";
|
|
import useViewer from "@/lib/swr/use-viewer";
|
|
|
|
import { BreadcrumbComponent as DataroomBreadcrumb } from "@/components/datarooms/dataroom-breadcrumb";
|
|
import {
|
|
Breadcrumb,
|
|
BreadcrumbEllipsis,
|
|
BreadcrumbItem,
|
|
BreadcrumbLink,
|
|
BreadcrumbList,
|
|
BreadcrumbPage,
|
|
BreadcrumbSeparator,
|
|
} from "@/components/ui/breadcrumb";
|
|
import {
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuTrigger,
|
|
} from "@/components/ui/dropdown-menu";
|
|
import { BadgeTooltip } from "@/components/ui/tooltip";
|
|
|
|
const FOLDERS_TO_DISPLAY = 1; // Only show the last folder in the path
|
|
|
|
const SingleDocumentBreadcrumb = () => {
|
|
const { document } = useDocument();
|
|
const { folders } = useFolderWithParents({
|
|
name: document?.folder?.path ? [document.folder.path] : [],
|
|
});
|
|
|
|
return (
|
|
<Breadcrumb>
|
|
<BreadcrumbList>
|
|
<BreadcrumbItem>
|
|
<BreadcrumbLink asChild>
|
|
<Link href="/documents">Documents</Link>
|
|
</BreadcrumbLink>
|
|
</BreadcrumbItem>
|
|
<BreadcrumbSeparator />
|
|
{folders && folders.length > FOLDERS_TO_DISPLAY ? (
|
|
<>
|
|
<BreadcrumbItem>
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger className="flex items-center gap-1">
|
|
<BreadcrumbEllipsis className="h-4 w-4" />
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="start">
|
|
{folders.slice(0, -1).map((folder, index) => (
|
|
<DropdownMenuItem key={`${folder.path}-${index}`}>
|
|
<Link
|
|
href={`/documents/tree${folder.path}`}
|
|
className="w-full"
|
|
>
|
|
{folder.name}
|
|
</Link>
|
|
</DropdownMenuItem>
|
|
))}
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
</BreadcrumbItem>
|
|
<BreadcrumbSeparator />
|
|
<BreadcrumbItem>
|
|
<BreadcrumbLink asChild>
|
|
<Link
|
|
href={`/documents/tree${folders[folders.length - 1].path}`}
|
|
className="max-w-[200px] truncate"
|
|
>
|
|
{folders[folders.length - 1].name}
|
|
</Link>
|
|
</BreadcrumbLink>
|
|
</BreadcrumbItem>
|
|
<BreadcrumbSeparator key={`sep-last`} />
|
|
</>
|
|
) : (
|
|
folders?.map((folder, index) => (
|
|
<React.Fragment key={`${folder.path}-${index}`}>
|
|
<BreadcrumbItem>
|
|
<BreadcrumbLink asChild>
|
|
<Link
|
|
href={`/documents/tree${folder.path}`}
|
|
className="max-w-[200px] truncate"
|
|
>
|
|
{folder.name}
|
|
</Link>
|
|
</BreadcrumbLink>
|
|
</BreadcrumbItem>
|
|
<BreadcrumbSeparator />
|
|
</React.Fragment>
|
|
))
|
|
)}
|
|
{document && (
|
|
<BreadcrumbItem>
|
|
<BreadcrumbPage className="max-w-[200px] truncate">
|
|
{document.name}
|
|
</BreadcrumbPage>
|
|
</BreadcrumbItem>
|
|
)}
|
|
</BreadcrumbList>
|
|
</Breadcrumb>
|
|
);
|
|
};
|
|
|
|
export const TruncatedBreadcrumbLink = ({
|
|
href,
|
|
text,
|
|
}: {
|
|
href: string;
|
|
text: string | undefined;
|
|
}) => {
|
|
const [isTooltipVisible, setIsTooltipVisible] = useState(false);
|
|
const breadcrumbRef = useRef<HTMLAnchorElement>(null);
|
|
|
|
useEffect(() => {
|
|
if (
|
|
breadcrumbRef.current &&
|
|
breadcrumbRef.current.scrollWidth > breadcrumbRef.current.clientWidth
|
|
) {
|
|
setIsTooltipVisible(true);
|
|
} else {
|
|
setIsTooltipVisible(false);
|
|
}
|
|
}, [text]);
|
|
|
|
const link = (
|
|
<BreadcrumbLink asChild>
|
|
<Link
|
|
ref={breadcrumbRef}
|
|
href={href}
|
|
className="max-w-32 truncate md:max-w-60"
|
|
>
|
|
{text || "Loading..."}
|
|
</Link>
|
|
</BreadcrumbLink>
|
|
);
|
|
|
|
if (isTooltipVisible) {
|
|
return <BadgeTooltip content={text || ""}>{link}</BadgeTooltip>;
|
|
}
|
|
return link;
|
|
};
|
|
|
|
const SingleDataroomBreadcrumb = ({ path }: { path: string }) => {
|
|
const { dataroom } = useDataroom();
|
|
|
|
const title = useMemo(() => {
|
|
switch (path) {
|
|
case "/datarooms/[id]/documents":
|
|
return "Documents";
|
|
case "/datarooms/[id]/settings":
|
|
return "Settings";
|
|
case "/datarooms/[id]/branding":
|
|
return "Branding";
|
|
case "/datarooms/[id]/permissions":
|
|
case "/datarooms/[id]/groups":
|
|
case "/datarooms/[id]/groups/[groupId]":
|
|
case "/datarooms/[id]/groups/[groupId]/permissions":
|
|
case "/datarooms/[id]/groups/[groupId]/members":
|
|
case "/datarooms/[id]/groups/[groupId]/links":
|
|
return "Permissions";
|
|
case "/datarooms/[id]/analytics":
|
|
return "Analytics";
|
|
case "/datarooms/[id]/settings/notifications":
|
|
return "Notifications";
|
|
case "/datarooms/[id]/settings/file-permissions":
|
|
return "File Permissions";
|
|
default:
|
|
return dataroom?.name || "Loading...";
|
|
}
|
|
}, [path, dataroom]);
|
|
|
|
return (
|
|
<Breadcrumb>
|
|
<BreadcrumbList>
|
|
<BreadcrumbItem>
|
|
<BreadcrumbLink asChild>
|
|
<Link href="/datarooms">Datarooms</Link>
|
|
</BreadcrumbLink>
|
|
</BreadcrumbItem>
|
|
<BreadcrumbSeparator />
|
|
<BreadcrumbItem>
|
|
<TruncatedBreadcrumbLink
|
|
href={`/datarooms/${dataroom?.id}/documents`}
|
|
text={dataroom?.name}
|
|
/>
|
|
</BreadcrumbItem>
|
|
<BreadcrumbSeparator />
|
|
<BreadcrumbItem>
|
|
<BreadcrumbPage>{title}</BreadcrumbPage>
|
|
</BreadcrumbItem>
|
|
</BreadcrumbList>
|
|
</Breadcrumb>
|
|
);
|
|
};
|
|
|
|
const SettingsBreadcrumb = () => {
|
|
const router = useRouter();
|
|
const path = router.pathname;
|
|
|
|
const settingsTitle = useMemo(() => {
|
|
switch (path) {
|
|
case "/settings/general":
|
|
return "General";
|
|
case "/settings/people":
|
|
return "Team";
|
|
case "/settings/domains":
|
|
return "Domains";
|
|
case "/settings/presets":
|
|
return "Presets";
|
|
case "/settings/tokens":
|
|
return "API Tokens";
|
|
case "/settings/webhooks":
|
|
return "Webhooks";
|
|
case "/settings/slack":
|
|
return "Slack";
|
|
case "/settings/incoming-webhooks":
|
|
return "Incoming Webhooks";
|
|
case "/settings/branding":
|
|
return "Branding";
|
|
default:
|
|
return "Settings";
|
|
}
|
|
}, [path]);
|
|
|
|
return (
|
|
<Breadcrumb>
|
|
<BreadcrumbList>
|
|
<BreadcrumbItem>
|
|
<BreadcrumbLink asChild>
|
|
<Link href="/settings/general">Settings</Link>
|
|
</BreadcrumbLink>
|
|
</BreadcrumbItem>
|
|
<BreadcrumbSeparator />
|
|
<BreadcrumbItem>
|
|
<BreadcrumbPage>{settingsTitle}</BreadcrumbPage>
|
|
</BreadcrumbItem>
|
|
</BreadcrumbList>
|
|
</Breadcrumb>
|
|
);
|
|
};
|
|
|
|
const AccountBreadcrumb = () => {
|
|
const router = useRouter();
|
|
const path = router.pathname;
|
|
|
|
const accountTitle = useMemo(() => {
|
|
switch (path) {
|
|
case "/account/general":
|
|
return "General";
|
|
case "/account/security":
|
|
return "Security";
|
|
default:
|
|
return "Account";
|
|
}
|
|
}, [path]);
|
|
|
|
return (
|
|
<Breadcrumb>
|
|
<BreadcrumbList>
|
|
<BreadcrumbItem>
|
|
<BreadcrumbLink asChild>
|
|
<Link href="/account/general">Account</Link>
|
|
</BreadcrumbLink>
|
|
</BreadcrumbItem>
|
|
<BreadcrumbSeparator />
|
|
<BreadcrumbItem>
|
|
<BreadcrumbPage>{accountTitle}</BreadcrumbPage>
|
|
</BreadcrumbItem>
|
|
</BreadcrumbList>
|
|
</Breadcrumb>
|
|
);
|
|
};
|
|
|
|
const DocumentsBreadcrumb = () => {
|
|
const router = useRouter();
|
|
const { name } = router.query as { name: string[] };
|
|
|
|
const { folders } = useFolderWithParents({ name });
|
|
|
|
return (
|
|
<Breadcrumb>
|
|
<BreadcrumbList>
|
|
<BreadcrumbItem>
|
|
<BreadcrumbLink asChild>
|
|
<Link href="/documents">Documents</Link>
|
|
</BreadcrumbLink>
|
|
</BreadcrumbItem>
|
|
<BreadcrumbSeparator />
|
|
{folders && folders.length > 2 ? (
|
|
<>
|
|
<BreadcrumbItem>
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger className="flex items-center gap-1">
|
|
<BreadcrumbEllipsis className="h-4 w-4" />
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="start">
|
|
{folders.slice(0, -2).map((folder, index) => (
|
|
<DropdownMenuItem key={`${folder.path}-${index}`}>
|
|
<Link
|
|
href={`/documents/tree${folder.path}`}
|
|
className="w-full"
|
|
>
|
|
{folder.name}
|
|
</Link>
|
|
</DropdownMenuItem>
|
|
))}
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
</BreadcrumbItem>
|
|
<BreadcrumbSeparator />
|
|
<BreadcrumbItem>
|
|
<BreadcrumbLink asChild>
|
|
<Link
|
|
href={`/documents/tree${folders[folders.length - 2].path}`}
|
|
className="max-w-[200px] truncate"
|
|
>
|
|
{folders[folders.length - 2].name}
|
|
</Link>
|
|
</BreadcrumbLink>
|
|
</BreadcrumbItem>
|
|
<BreadcrumbSeparator />
|
|
<BreadcrumbItem>
|
|
<BreadcrumbPage className="max-w-[200px] truncate">
|
|
{folders[folders.length - 1].name}
|
|
</BreadcrumbPage>
|
|
</BreadcrumbItem>
|
|
</>
|
|
) : (
|
|
folders?.map((folder, index) => (
|
|
<React.Fragment key={`${folder.path}-${index}`}>
|
|
<BreadcrumbItem key={`item-${index}`}>
|
|
{index === folders.length - 1 ? (
|
|
<BreadcrumbPage className="max-w-[200px] truncate">
|
|
{folder.name}
|
|
</BreadcrumbPage>
|
|
) : (
|
|
<BreadcrumbLink asChild>
|
|
<Link
|
|
href={`/documents/tree${folder.path}`}
|
|
className="max-w-[200px] truncate"
|
|
>
|
|
{folder.name}
|
|
</Link>
|
|
</BreadcrumbLink>
|
|
)}
|
|
</BreadcrumbItem>
|
|
{index < folders.length - 1 && <BreadcrumbSeparator />}
|
|
</React.Fragment>
|
|
))
|
|
)}
|
|
</BreadcrumbList>
|
|
</Breadcrumb>
|
|
);
|
|
};
|
|
|
|
const VisitorsBreadcrumb = () => {
|
|
return (
|
|
<Breadcrumb>
|
|
<BreadcrumbList>
|
|
<BreadcrumbItem>
|
|
<BreadcrumbLink asChild>
|
|
<Link href="/visitors">Visitors</Link>
|
|
</BreadcrumbLink>
|
|
</BreadcrumbItem>
|
|
</BreadcrumbList>
|
|
</Breadcrumb>
|
|
);
|
|
};
|
|
|
|
const SingleVisitorBreadcrumb = () => {
|
|
const { viewer } = useViewer();
|
|
|
|
return (
|
|
<Breadcrumb>
|
|
<BreadcrumbList>
|
|
<BreadcrumbItem>
|
|
<BreadcrumbLink asChild>
|
|
<Link href="/visitors">Visitors</Link>
|
|
</BreadcrumbLink>
|
|
</BreadcrumbItem>
|
|
<BreadcrumbSeparator />
|
|
<BreadcrumbItem>
|
|
<BreadcrumbPage className="max-w-[200px] truncate">
|
|
{viewer?.email || "Loading..."}
|
|
</BreadcrumbPage>
|
|
</BreadcrumbItem>
|
|
</BreadcrumbList>
|
|
</Breadcrumb>
|
|
);
|
|
};
|
|
|
|
const AnalyticsBreadcrumb = () => {
|
|
const router = useRouter();
|
|
const { type = "links" } = router.query;
|
|
|
|
const title = useMemo(() => {
|
|
switch (type) {
|
|
case "links":
|
|
return "Links";
|
|
case "documents":
|
|
return "Documents";
|
|
case "visitors":
|
|
return "Visitors";
|
|
case "views":
|
|
return "Recent Views";
|
|
default:
|
|
return "Analytics";
|
|
}
|
|
}, [type]);
|
|
|
|
return (
|
|
<Breadcrumb>
|
|
<BreadcrumbList>
|
|
<BreadcrumbItem>
|
|
<BreadcrumbLink asChild>
|
|
<Link href="/dashboard?interval=7d&type=links">Dashboard</Link>
|
|
</BreadcrumbLink>
|
|
</BreadcrumbItem>
|
|
<BreadcrumbSeparator />
|
|
<BreadcrumbItem>
|
|
<BreadcrumbPage>{title}</BreadcrumbPage>
|
|
</BreadcrumbItem>
|
|
</BreadcrumbList>
|
|
</Breadcrumb>
|
|
);
|
|
};
|
|
|
|
export const AppBreadcrumb = () => {
|
|
const router = useRouter();
|
|
const path = router.pathname;
|
|
const { id } = router.query as {
|
|
id?: string;
|
|
};
|
|
|
|
const breadcrumb = useMemo(() => {
|
|
// Analytics routes
|
|
if (path === "/dashboard") {
|
|
return <AnalyticsBreadcrumb />;
|
|
}
|
|
|
|
// Settings routes
|
|
if (path.startsWith("/settings")) {
|
|
return <SettingsBreadcrumb />;
|
|
}
|
|
|
|
// Account routes
|
|
if (path.startsWith("/account")) {
|
|
return <AccountBreadcrumb />;
|
|
}
|
|
|
|
// Root documents route
|
|
if (path === "/documents") {
|
|
return (
|
|
<Breadcrumb>
|
|
<BreadcrumbList>
|
|
<BreadcrumbItem>
|
|
<BreadcrumbPage>Documents</BreadcrumbPage>
|
|
</BreadcrumbItem>
|
|
</BreadcrumbList>
|
|
</Breadcrumb>
|
|
);
|
|
}
|
|
|
|
// Document tree routes
|
|
if (path === "/documents/tree/[...name]") {
|
|
return <DocumentsBreadcrumb />;
|
|
}
|
|
|
|
// Single document route
|
|
if (path === "/documents/[id]" && id) {
|
|
return <SingleDocumentBreadcrumb />;
|
|
}
|
|
|
|
// Dataroom document routes
|
|
if (path === "/datarooms/[id]/documents" && id) {
|
|
return <DataroomBreadcrumb />;
|
|
}
|
|
|
|
// Dataroom document routes
|
|
if (path === "/datarooms/[id]/documents/[...name]" && id) {
|
|
return <DataroomBreadcrumb />;
|
|
}
|
|
|
|
// Single dataroom route
|
|
if (path.startsWith("/datarooms/[id]") && id) {
|
|
return <SingleDataroomBreadcrumb path={path} />;
|
|
}
|
|
|
|
// Root datarooms route
|
|
if (path === "/datarooms") {
|
|
return (
|
|
<Breadcrumb>
|
|
<BreadcrumbList>
|
|
<BreadcrumbItem>
|
|
<BreadcrumbPage>Datarooms</BreadcrumbPage>
|
|
</BreadcrumbItem>
|
|
</BreadcrumbList>
|
|
</Breadcrumb>
|
|
);
|
|
}
|
|
|
|
// Root visitors route
|
|
if (path === "/visitors") {
|
|
return <VisitorsBreadcrumb />;
|
|
}
|
|
|
|
// Single visitor route
|
|
if (path === "/visitors/[id]" && id) {
|
|
return <SingleVisitorBreadcrumb />;
|
|
}
|
|
|
|
return null;
|
|
}, [path, id]);
|
|
|
|
return breadcrumb;
|
|
};
|