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]>
198 lines
5.6 KiB
TypeScript
198 lines
5.6 KiB
TypeScript
import { useRouter } from "next/router";
|
|
|
|
import { useState } from "react";
|
|
|
|
import { useTeam } from "@/context/team-context";
|
|
import { toast } from "sonner";
|
|
import { mutate } from "swr";
|
|
import { z } from "zod";
|
|
|
|
import {
|
|
DEFAULT_FOLDER_COLOR,
|
|
DEFAULT_FOLDER_ICON,
|
|
FolderColorId,
|
|
FolderIconId,
|
|
} from "@/lib/constants/folder-constants";
|
|
import { safeSlugify } from "@/lib/utils";
|
|
import { useAnalytics } from "@/lib/analytics";
|
|
|
|
import { Button } from "@/components/ui/button";
|
|
import {
|
|
Dialog,
|
|
DialogContent,
|
|
DialogDescription,
|
|
DialogFooter,
|
|
DialogHeader,
|
|
DialogTitle,
|
|
DialogTrigger,
|
|
} from "@/components/ui/dialog";
|
|
import { Input } from "@/components/ui/input";
|
|
import { Label } from "@/components/ui/label";
|
|
|
|
import { FolderIconColorPicker } from "./folder-icon-picker";
|
|
|
|
export function AddFolderModal({
|
|
// open,
|
|
// setOpen,
|
|
onAddition,
|
|
isDataroom,
|
|
dataroomId,
|
|
children,
|
|
}: {
|
|
// open?: boolean;
|
|
// setOpen?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
onAddition?: (folderName: string) => void;
|
|
isDataroom?: boolean;
|
|
dataroomId?: string;
|
|
children?: React.ReactNode;
|
|
}) {
|
|
const router = useRouter();
|
|
const [folderName, setFolderName] = useState<string>("");
|
|
const [folderIcon, setFolderIcon] = useState<FolderIconId>(DEFAULT_FOLDER_ICON);
|
|
const [folderColor, setFolderColor] = useState<FolderColorId>(DEFAULT_FOLDER_COLOR);
|
|
const [loading, setLoading] = useState<boolean>(false);
|
|
const [open, setOpen] = useState<boolean>(false);
|
|
|
|
const teamInfo = useTeam();
|
|
const analytics = useAnalytics();
|
|
|
|
/** current folder name */
|
|
const currentFolderPath = router.query.name as string[] | undefined;
|
|
|
|
const folderPath =
|
|
isDataroom && dataroomId
|
|
? `/datarooms/${dataroomId}/documents/${currentFolderPath ? currentFolderPath?.join("/") : ""}/${"/" + safeSlugify(folderName.trim())}`
|
|
: `/documents/tree/${currentFolderPath ? currentFolderPath?.join("/") : ""}${"/" + safeSlugify(folderName.trim())}`;
|
|
|
|
const addFolderSchema = z.object({
|
|
name: z
|
|
.string()
|
|
.min(3, {
|
|
message: "Please provide a folder name with at least 3 characters.",
|
|
})
|
|
.max(256, {
|
|
message: "Folder name must be 256 characters or less.",
|
|
}),
|
|
});
|
|
|
|
const validation = addFolderSchema.safeParse({ name: folderName });
|
|
|
|
const handleSubmit = async (event: any) => {
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
|
|
if (!validation.success) {
|
|
toast.error(validation.error.errors[0].message);
|
|
return;
|
|
}
|
|
|
|
setLoading(true);
|
|
const endpointTargetType =
|
|
isDataroom && dataroomId ? `datarooms/${dataroomId}/folders` : "folders";
|
|
|
|
try {
|
|
const response = await fetch(
|
|
`/api/teams/${teamInfo?.currentTeam?.id}/${endpointTargetType}`,
|
|
{
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
body: JSON.stringify({
|
|
name: folderName.trim(),
|
|
path: currentFolderPath?.join("/"),
|
|
icon: folderIcon,
|
|
color: folderColor,
|
|
}),
|
|
},
|
|
);
|
|
|
|
if (!response.ok) {
|
|
const { message } = await response.json();
|
|
setLoading(false);
|
|
toast.error(message.error);
|
|
return;
|
|
}
|
|
|
|
const { parentFolderPath } = await response.json();
|
|
|
|
analytics.capture("Folder Added", {
|
|
folderName: folderName.trim(),
|
|
icon: folderIcon,
|
|
color: folderColor,
|
|
dataroomId,
|
|
});
|
|
toast.success(`Folder added successfully!`, {
|
|
description: `"${folderName.trim()}"`,
|
|
action: {
|
|
label: "Open folder",
|
|
onClick: () => router.push(folderPath),
|
|
},
|
|
duration: 10000,
|
|
});
|
|
|
|
mutate(
|
|
`/api/teams/${teamInfo?.currentTeam?.id}/${endpointTargetType}?root=true`,
|
|
);
|
|
mutate(`/api/teams/${teamInfo?.currentTeam?.id}/${endpointTargetType}`);
|
|
mutate(
|
|
`/api/teams/${teamInfo?.currentTeam?.id}/${endpointTargetType}${parentFolderPath}`,
|
|
);
|
|
} catch (error) {
|
|
setLoading(false);
|
|
toast.error("Error adding folder. Please try again.");
|
|
return;
|
|
} finally {
|
|
setFolderName("");
|
|
setFolderIcon(DEFAULT_FOLDER_ICON);
|
|
setFolderColor(DEFAULT_FOLDER_COLOR);
|
|
setLoading(false);
|
|
setOpen(false);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<Dialog open={open} onOpenChange={setOpen}>
|
|
<DialogTrigger asChild>{children}</DialogTrigger>
|
|
<DialogContent className="sm:max-w-[425px]">
|
|
<DialogHeader className="text-start">
|
|
<DialogTitle>Add Folder</DialogTitle>
|
|
<DialogDescription>
|
|
Create a new folder with a custom icon and color.
|
|
</DialogDescription>
|
|
</DialogHeader>
|
|
<form onSubmit={handleSubmit}>
|
|
<Label htmlFor="folder-name" className="opacity-80">
|
|
Folder Name
|
|
</Label>
|
|
<div className="mb-4 mt-1 flex items-center gap-2">
|
|
<FolderIconColorPicker
|
|
iconValue={folderIcon}
|
|
colorValue={folderColor}
|
|
onIconChange={setFolderIcon}
|
|
onColorChange={setFolderColor}
|
|
/>
|
|
<Input
|
|
id="folder-name"
|
|
placeholder="Choose a helpful name"
|
|
className="flex-1"
|
|
value={folderName}
|
|
onChange={(e) => setFolderName(e.target.value)}
|
|
/>
|
|
</div>
|
|
<DialogFooter>
|
|
<Button
|
|
type="submit"
|
|
className="h-9 w-full"
|
|
disabled={!validation.success}
|
|
loading={loading}
|
|
>
|
|
Create
|
|
</Button>
|
|
</DialogFooter>
|
|
</form>
|
|
</DialogContent>
|
|
</Dialog>
|
|
);
|
|
}
|