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]>
442 lines
16 KiB
TypeScript
442 lines
16 KiB
TypeScript
import { useRouter } from "next/router";
|
|
|
|
import { useMemo, useState } from "react";
|
|
|
|
import { useTeam } from "@/context/team-context";
|
|
import { useSession } from "next-auth/react";
|
|
import { toast } from "sonner";
|
|
import { mutate } from "swr";
|
|
|
|
import { useAnalytics } from "@/lib/analytics";
|
|
import { useInvitations } from "@/lib/swr/use-invitations";
|
|
import { useGetTeam } from "@/lib/swr/use-team";
|
|
import { useTeams } from "@/lib/swr/use-teams";
|
|
import { CustomUser } from "@/lib/types";
|
|
|
|
import AppLayout from "@/components/layouts/app";
|
|
import { SettingsHeader } from "@/components/settings/settings-header";
|
|
import Folder from "@/components/shared/icons/folder";
|
|
import MoreVertical from "@/components/shared/icons/more-vertical";
|
|
import { AddTeamMembers } from "@/components/teams/add-team-member-modal";
|
|
import { Button } from "@/components/ui/button";
|
|
import {
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuLabel,
|
|
DropdownMenuTrigger,
|
|
} from "@/components/ui/dropdown-menu";
|
|
import { Skeleton } from "@/components/ui/skeleton";
|
|
|
|
export default function People() {
|
|
const [isTeamMemberInviteModalOpen, setTeamMemberInviteModalOpen] =
|
|
useState<boolean>(false);
|
|
const [leavingUserId, setLeavingUserId] = useState<string>("");
|
|
|
|
const { data: session } = useSession();
|
|
const { team, loading } = useGetTeam()!;
|
|
const teamInfo = useTeam();
|
|
const { teams } = useTeams();
|
|
const analytics = useAnalytics();
|
|
|
|
const { invitations } = useInvitations();
|
|
|
|
const router = useRouter();
|
|
|
|
const documentCountsByUser = useMemo(() => {
|
|
if (!team?.documents) return {};
|
|
|
|
const counts: Record<string, number> = {};
|
|
team.documents.forEach((document) => {
|
|
const ownerId = document.owner?.id;
|
|
if (ownerId) {
|
|
counts[ownerId] = (counts[ownerId] || 0) + 1;
|
|
}
|
|
});
|
|
return counts;
|
|
}, [team]);
|
|
|
|
const getUserDocumentCount = (userId: string) => {
|
|
return documentCountsByUser[userId] || 0;
|
|
};
|
|
|
|
const isCurrentUser = (userId: string) => {
|
|
if ((session?.user as CustomUser)?.id === userId) {
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
|
|
const isCurrentUserAdmin = () => {
|
|
return team?.users.some(
|
|
(user) =>
|
|
user.role === "ADMIN" &&
|
|
user.userId === (session?.user as CustomUser)?.id,
|
|
);
|
|
};
|
|
|
|
const changeRole = async (
|
|
teamId: string,
|
|
userId: string,
|
|
role: "ADMIN" | "MANAGER" | "MEMBER",
|
|
) => {
|
|
const response = await fetch(`/api/teams/${teamId}/change-role`, {
|
|
method: "PUT",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
body: JSON.stringify({
|
|
userToBeChanged: userId,
|
|
role: role,
|
|
}),
|
|
});
|
|
|
|
if (response.status !== 204) {
|
|
const error = await response.json();
|
|
toast.error(error);
|
|
return;
|
|
}
|
|
|
|
await mutate(`/api/teams/${teamId}`);
|
|
await mutate("/api/teams");
|
|
|
|
analytics.capture("Team Member Role Changed", {
|
|
userId: userId,
|
|
teamId: teamId,
|
|
role: role,
|
|
});
|
|
|
|
toast.success("Role changed successfully!");
|
|
};
|
|
|
|
const removeTeammate = async (teamId: string, userId: string) => {
|
|
setLeavingUserId(userId);
|
|
const response = await fetch(`/api/teams/${teamId}/remove-teammate`, {
|
|
method: "DELETE",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
body: JSON.stringify({
|
|
userToBeDeleted: userId,
|
|
}),
|
|
});
|
|
|
|
if (response.status !== 204) {
|
|
const error = await response.json();
|
|
toast.error(error);
|
|
setLeavingUserId("");
|
|
return;
|
|
}
|
|
|
|
await mutate(`/api/teams/${teamInfo?.currentTeam?.id}`);
|
|
await mutate("/api/teams");
|
|
mutate(`/api/teams/${teamInfo?.currentTeam?.id}/invitations`);
|
|
|
|
setLeavingUserId("");
|
|
if (isCurrentUser(userId)) {
|
|
toast.success(`Successfully leaved team ${teamInfo?.currentTeam?.name}`);
|
|
teamInfo?.setCurrentTeam({ id: teams![0].id });
|
|
router.push("/documents");
|
|
return;
|
|
}
|
|
|
|
analytics.capture("Team Member Removed", {
|
|
userId: userId,
|
|
teamId: teamInfo?.currentTeam?.id,
|
|
});
|
|
|
|
toast.success("Teammate removed successfully!");
|
|
};
|
|
|
|
// resend invitation function
|
|
const resendInvitation = async (invitation: { email: string } & any) => {
|
|
const response = await fetch(
|
|
`/api/teams/${teamInfo?.currentTeam?.id}/invitations/resend`,
|
|
{
|
|
method: "PUT",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
body: JSON.stringify({
|
|
email: invitation.email as string,
|
|
}),
|
|
},
|
|
);
|
|
|
|
if (response.status !== 200) {
|
|
const error = await response.json();
|
|
toast.error(error);
|
|
return;
|
|
}
|
|
|
|
analytics.capture("Team Member Invitation Resent", {
|
|
email: invitation.email as string,
|
|
teamId: teamInfo?.currentTeam?.id,
|
|
});
|
|
mutate(`/api/teams/${teamInfo?.currentTeam?.id}/invitations`);
|
|
|
|
toast.success("Invitation resent successfully!");
|
|
};
|
|
|
|
// revoke invitation function
|
|
const revokeInvitation = async (invitation: { email: string } & any) => {
|
|
const response = await fetch(
|
|
`/api/teams/${teamInfo?.currentTeam?.id}/invitations`,
|
|
{
|
|
method: "DELETE",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
body: JSON.stringify({
|
|
email: invitation.email as string,
|
|
}),
|
|
},
|
|
);
|
|
|
|
if (!response.ok) {
|
|
const error = await response.json();
|
|
toast.error(error);
|
|
return;
|
|
}
|
|
|
|
analytics.capture("Team Member Invitation Revoked", {
|
|
email: invitation.email as string,
|
|
teamId: teamInfo?.currentTeam?.id,
|
|
});
|
|
|
|
mutate(`/api/teams/${teamInfo?.currentTeam?.id}/invitations`);
|
|
|
|
toast.success("Invitation revoked successfully!");
|
|
};
|
|
|
|
return (
|
|
<AppLayout>
|
|
<main className="relative mx-2 mb-10 mt-4 space-y-8 overflow-hidden px-1 sm:mx-3 md:mx-5 md:mt-5 lg:mx-7 lg:mt-8 xl:mx-10">
|
|
<SettingsHeader />
|
|
<div>
|
|
<div className="mb-4 flex items-center justify-between md:mb-8 lg:mb-12">
|
|
<div className="space-y-1">
|
|
<h3 className="text-2xl font-semibold tracking-tight text-foreground">
|
|
Team Members
|
|
</h3>
|
|
<p className="text-sm text-muted-foreground">
|
|
Manage your team members
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div className="flex items-center justify-between gap-x-1 rounded-lg border border-border bg-secondary p-4 sm:p-10">
|
|
<div className="flex flex-col space-y-1 sm:space-y-3">
|
|
<h2 className="text-xl font-medium">Team</h2>
|
|
<p className="text-sm text-secondary-foreground">
|
|
Teammates that have access to this project.
|
|
</p>
|
|
</div>
|
|
<AddTeamMembers
|
|
open={isTeamMemberInviteModalOpen}
|
|
setOpen={setTeamMemberInviteModalOpen}
|
|
>
|
|
<Button>Invite</Button>
|
|
</AddTeamMembers>
|
|
</div>
|
|
</div>
|
|
|
|
<ul className="mt-6 divide-y rounded-lg border">
|
|
{loading && (
|
|
<div className="flex items-center justify-between px-10 py-4">
|
|
<div className="flex items-center gap-12">
|
|
<div className="space-y-2">
|
|
<Skeleton className="h-6 w-36" />
|
|
<Skeleton className="h-4 w-36" />
|
|
</div>
|
|
<Skeleton className="h-4 w-20" />
|
|
</div>
|
|
<div className="flex gap-12">
|
|
<Skeleton className="h-6 w-14" />
|
|
<Skeleton className="h-6 w-4" />
|
|
</div>
|
|
</div>
|
|
)}
|
|
{team?.users.map((member, index) => (
|
|
<li
|
|
className="flex items-center justify-between gap-12 overflow-auto px-10 py-4"
|
|
key={index}
|
|
>
|
|
<div className="flex items-center gap-12">
|
|
<div className="space-y-1">
|
|
<h4 className="text-sm font-semibold">
|
|
{member.user.name}
|
|
</h4>
|
|
<p className="text-xs text-muted-foreground">
|
|
{member.user.email}
|
|
</p>
|
|
</div>
|
|
<div className="text-sm">
|
|
<div className="flex items-center gap-2">
|
|
<Folder />
|
|
<span className="text-nowrap text-xs text-foreground">
|
|
{getUserDocumentCount(member.userId)}{" "}
|
|
{getUserDocumentCount(member.userId) === 1
|
|
? "document"
|
|
: "documents"}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div className="flex items-center gap-12">
|
|
<div className="flex flex-col items-end gap-1">
|
|
<span className="text-sm capitalize text-foreground">
|
|
{member.role.toLowerCase()}
|
|
</span>
|
|
</div>
|
|
{leavingUserId === member.userId ? (
|
|
<span className="text-xs">leaving...</span>
|
|
) : (
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button variant="ghost" className="h-8 w-8 p-0">
|
|
<span className="sr-only">Open menu</span>
|
|
<MoreVertical className="h-4 w-4" />
|
|
</Button>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="end">
|
|
<DropdownMenuLabel>Actions</DropdownMenuLabel>
|
|
{isCurrentUser(member.userId) && (
|
|
<DropdownMenuItem
|
|
onClick={() =>
|
|
removeTeammate(member.teamId, member.userId)
|
|
}
|
|
className="text-red-500 hover:cursor-pointer focus:bg-destructive focus:text-destructive-foreground"
|
|
>
|
|
Leave team
|
|
</DropdownMenuItem>
|
|
)}
|
|
{isCurrentUserAdmin() &&
|
|
!isCurrentUser(member.userId) ? (
|
|
<>
|
|
{member.role !== "ADMIN" && (
|
|
<DropdownMenuItem
|
|
onClick={() =>
|
|
changeRole(
|
|
member.teamId,
|
|
member.userId,
|
|
"ADMIN",
|
|
)
|
|
}
|
|
className="hover:cursor-pointer"
|
|
>
|
|
Change role to ADMIN
|
|
</DropdownMenuItem>
|
|
)}
|
|
{member.role !== "MANAGER" && (
|
|
<DropdownMenuItem
|
|
onClick={() =>
|
|
changeRole(
|
|
member.teamId,
|
|
member.userId,
|
|
"MANAGER",
|
|
)
|
|
}
|
|
className="hover:cursor-pointer"
|
|
>
|
|
Change role to MANAGER
|
|
</DropdownMenuItem>
|
|
)}
|
|
{member.role !== "MEMBER" && (
|
|
<DropdownMenuItem
|
|
onClick={() =>
|
|
changeRole(
|
|
member.teamId,
|
|
member.userId,
|
|
"MEMBER",
|
|
)
|
|
}
|
|
className="hover:cursor-pointer"
|
|
>
|
|
Change role to MEMBER
|
|
</DropdownMenuItem>
|
|
)}
|
|
<DropdownMenuItem
|
|
onClick={() =>
|
|
removeTeammate(member.teamId, member.userId)
|
|
}
|
|
className="text-red-500 hover:cursor-pointer focus:bg-destructive focus:text-destructive-foreground"
|
|
>
|
|
Remove teammate
|
|
</DropdownMenuItem>
|
|
</>
|
|
) : (
|
|
<DropdownMenuItem
|
|
disabled
|
|
className="text-red-500 focus:bg-destructive focus:text-destructive-foreground"
|
|
>
|
|
Remove teammate
|
|
</DropdownMenuItem>
|
|
)}
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
)}
|
|
</div>
|
|
</li>
|
|
))}
|
|
{invitations &&
|
|
invitations.map((invitation, index) => (
|
|
<li
|
|
className="flex items-center justify-between px-10 py-4"
|
|
key={index}
|
|
>
|
|
<div className="flex items-center gap-12">
|
|
<div className="space-y-1">
|
|
<h4 className="text-sm font-semibold">
|
|
{invitation.email}
|
|
</h4>
|
|
<p className="text-xs text-muted-foreground">
|
|
{invitation.email}
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<div className="flex items-center gap-12">
|
|
<span
|
|
className="text-sm text-foreground"
|
|
title={`Expires on ${new Date(
|
|
invitation.expires,
|
|
).toLocaleString()}`}
|
|
>
|
|
{new Date(invitation.expires) >= new Date(Date.now())
|
|
? "Pending"
|
|
: "Expired"}
|
|
</span>
|
|
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button variant="ghost" className="h-8 w-8 p-0">
|
|
<span className="sr-only">Open menu</span>
|
|
<MoreVertical className="h-4 w-4" />
|
|
</Button>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="end">
|
|
<DropdownMenuLabel>Actions</DropdownMenuLabel>
|
|
<DropdownMenuItem
|
|
onClick={() => resendInvitation(invitation)}
|
|
className="text-red-500 hover:cursor-pointer focus:bg-destructive focus:text-destructive-foreground"
|
|
>
|
|
Resend
|
|
</DropdownMenuItem>
|
|
<DropdownMenuItem
|
|
onClick={() => revokeInvitation(invitation)}
|
|
className="text-red-500 hover:cursor-pointer focus:bg-destructive focus:text-destructive-foreground"
|
|
>
|
|
Revoke invitation
|
|
</DropdownMenuItem>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
</div>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
</div>
|
|
</main>
|
|
</AppLayout>
|
|
);
|
|
}
|