Skip to content

Open source alternative to Semrush and Ahrefs

Port account settings and organization to shadcn, with inline invite errors (EVE-303) (#748)

Carter Smith0a2a020f4e4f
diff --git a/src/client/components/RowActionsMenu.tsx b/src/client/components/RowActionsMenu.tsx
index aa5e9ecf..55687a1b 100644
--- a/src/client/components/RowActionsMenu.tsx
+++ b/src/client/components/RowActionsMenu.tsx
@@ -23,7 +23,7 @@ export function RowActionsMenu({
>
<MoreHorizontal />
</DropdownMenuTrigger>
- <DropdownMenuContent align="end" className="w-40">
+ <DropdownMenuContent align="end" className="w-auto min-w-40">
{children}
</DropdownMenuContent>
</DropdownMenu>
diff --git a/src/client/components/ThemePreferenceMenuItems.tsx b/src/client/components/ThemePreferenceMenuItems.tsx
index 5fe0fbef..c7a6c82d 100644
--- a/src/client/components/ThemePreferenceMenuItems.tsx
+++ b/src/client/components/ThemePreferenceMenuItems.tsx
@@ -1,14 +1,16 @@
+import type { ReactNode } from "react";
import { Monitor, Moon, Sun } from "lucide-react";
+import { SegmentedToggle } from "@/client/components/SegmentedToggle";
import { type ThemePreference, useThemePreference } from "@/client/lib/theme";
const THEME_OPTIONS: {
value: ThemePreference;
label: string;
- icon: typeof Sun;
+ icon: ReactNode;
}[] = [
- { value: "system", label: "System", icon: Monitor },
- { value: "light", label: "Light", icon: Sun },
- { value: "dark", label: "Dark", icon: Moon },
+ { value: "system", label: "System", icon: <Monitor /> },
+ { value: "light", label: "Light", icon: <Sun /> },
+ { value: "dark", label: "Dark", icon: <Moon /> },
];
/** System / Light / Dark segmented radio, shared by Settings and account menus. */
@@ -16,39 +18,11 @@ export function ThemePreferenceRadio() {
const { themePreference, setThemePreference } = useThemePreference();
return (
- <div
- role="radiogroup"
- aria-label="Theme preference"
- className="flex gap-0.5 rounded-lg bg-base-200 p-0.5"
- >
- {THEME_OPTIONS.map((option) => {
- const isActive = option.value === themePreference;
- const Icon = option.icon;
-
- return (
- <div
- key={option.value}
- className="tooltip tooltip-bottom flex flex-1 before:whitespace-nowrap"
- data-tip={option.label}
- >
- <button
- type="button"
- role="radio"
- aria-checked={isActive}
- aria-label={option.label}
- className={`flex flex-1 cursor-pointer items-center justify-center rounded-md px-2.5 py-1.5 transition-colors ${
- isActive
- ? "bg-base-100 text-base-content shadow-sm"
- : "text-base-content/50 hover:text-base-content/80"
- }`}
- onClick={() => setThemePreference(option.value)}
- >
- <Icon className="size-4" />
- </button>
- </div>
- );
- })}
- </div>
+ <SegmentedToggle
+ items={THEME_OPTIONS}
+ value={themePreference}
+ onChange={setThemePreference}
+ />
);
}
diff --git a/src/client/features/settings/ApiKeySettings.tsx b/src/client/features/settings/ApiKeySettings.tsx
index 64bcbb6d..28b1d2fe 100644
--- a/src/client/features/settings/ApiKeySettings.tsx
+++ b/src/client/features/settings/ApiKeySettings.tsx
@@ -2,8 +2,12 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { QueryState } from "@/client/components/QueryState";
import { Trash2 } from "lucide-react";
import { useState } from "react";
+import { revalidateLogic } from "@tanstack/react-form";
import { toast } from "sonner";
+import { z } from "zod";
import { ConfirmDialog } from "@/client/components/ConfirmDialog";
+import { SectionHeader } from "@/client/components/PageHeader";
+import { useAppForm } from "@/client/components/form/useAppForm";
import { Button } from "@/client/components/ui/button";
import {
Dialog,
@@ -15,6 +19,14 @@ import {
} from "@/client/components/ui/dialog";
import { RowActionsMenu } from "@/client/components/RowActionsMenu";
import { DropdownMenuItem } from "@/client/components/ui/dropdown-menu";
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow,
+} from "@/client/components/ui/table";
import { CopyButton } from "@/client/components/CopyButton";
import { captureClientEvent } from "@/client/lib/posthog";
import { authClient } from "@/lib/auth-client";
@@ -22,10 +34,13 @@ import { authClient } from "@/lib/auth-client";
// Better Auth rejects longer names with INVALID_NAME_LENGTH.
const MAX_KEY_NAME_LENGTH = 32;
+const createKeySchema = z.object({
+ name: z.string().trim().min(1, "Name is required"),
+});
+
export function ApiKeySettings() {
const queryClient = useQueryClient();
const [isCreateOpen, setIsCreateOpen] = useState(false);
- const [name, setName] = useState("");
const [createdKey, setCreatedKey] = useState<string | null>(null);
const [revoking, setRevoking] = useState<{ id: string; name: string } | null>(
null,
@@ -63,7 +78,6 @@ export function ApiKeySettings() {
},
onSuccess: (key) => {
setCreatedKey(key);
- setName("");
captureClientEvent("mcp:api_key_created");
void queryClient.invalidateQueries({ queryKey: ["apiKeys"] });
},
@@ -84,27 +98,36 @@ export function ApiKeySettings() {
},
});
+ const form = useAppForm({
+ defaultValues: { name: "" },
+ validationLogic: revalidateLogic(),
+ validators: { onDynamic: createKeySchema },
+ onSubmit: async ({ value }) => {
+ await createMutation.mutateAsync(value.name.trim());
+ },
+ });
+
const closeCreateModal = () => {
setIsCreateOpen(false);
setCreatedKey(null);
- setName("");
+ form.reset();
};
return (
<section className="space-y-3">
- <h2 className="text-sm font-medium text-base-content/50">API keys</h2>
+ <SectionHeader title="API keys" />
<div className="flex items-start justify-between gap-6">
<div>
<p className="text-sm">
Authenticate MCP clients when OAuth doesn't work
</p>
- <p className="mt-1 text-sm text-base-content/60">
+ <p className="mt-1 text-sm text-muted-foreground">
Use this for remote agents like Hermes where the normal login flow
doesn't work.
</p>
<p className="mt-1 text-sm">
<a
- className="link link-primary"
+ className="text-primary underline-offset-4 hover:underline"
href="https://openseo.so/docs/mcp"
target="_blank"
rel="noreferrer"
@@ -113,13 +136,9 @@ export function ApiKeySettings() {
</a>
</p>
</div>
- <button
- type="button"
- className="btn btn-primary btn-sm"
- onClick={() => setIsCreateOpen(true)}
- >
+ <Button size="sm" onClick={() => setIsCreateOpen(true)}>
Create API key
- </button>
+ </Button>
</div>
<QueryState
@@ -128,40 +147,40 @@ export function ApiKeySettings() {
>
{(apiKeys) =>
apiKeys.length === 0 ? (
- <p className="text-sm text-base-content/60">No API keys yet.</p>
+ <p className="text-sm text-muted-foreground">No API keys yet.</p>
) : (
- <div className="overflow-x-auto rounded-lg border border-base-300 bg-base-100">
- <table className="table table-sm">
- <thead>
- <tr>
- <th>Name</th>
- <th>Key</th>
- <th>Created</th>
- <th>Last used</th>
- <th className="w-10"></th>
- </tr>
- </thead>
- <tbody>
+ <div className="rounded-lg border border-border bg-card">
+ <Table>
+ <TableHeader>
+ <TableRow>
+ <TableHead>Name</TableHead>
+ <TableHead>Key</TableHead>
+ <TableHead>Created</TableHead>
+ <TableHead>Last used</TableHead>
+ <TableHead className="w-10" />
+ </TableRow>
+ </TableHeader>
+ <TableBody>
{apiKeys.map((key) => (
- <tr key={key.id} className="hover">
- <td className="max-w-[220px] truncate font-medium">
+ <TableRow key={key.id}>
+ <TableCell className="max-w-[220px] truncate font-medium">
{key.name || "Unnamed key"}
- </td>
- <td
- className="font-mono text-xs text-base-content/70"
+ </TableCell>
+ <TableCell
+ className="font-mono text-xs text-muted-foreground"
data-ph-mask
>
{key.start || "oseo_"}…
- </td>
- <td className="text-xs text-base-content/70">
+ </TableCell>
+ <TableCell className="text-xs text-muted-foreground">
{key.createdAt.toLocaleDateString()}
- </td>
- <td className="text-xs text-base-content/70">
+ </TableCell>
+ <TableCell className="text-xs text-muted-foreground">
{key.lastRequest
? key.lastRequest.toLocaleDateString()
: "Never"}
- </td>
- <td>
+ </TableCell>
+ <TableCell>
<RowActionsMenu
label={`Actions for ${key.name || "API key"}`}
>
@@ -178,11 +197,11 @@ export function ApiKeySettings() {
Revoke key
</DropdownMenuItem>
</RowActionsMenu>
- </td>
- </tr>
+ </TableCell>
+ </TableRow>
))}
- </tbody>
- </table>
+ </TableBody>
+ </Table>
</div>
)
}
@@ -209,7 +228,12 @@ export function ApiKeySettings() {
if (!open && createdKey == null) closeCreateModal();
}}
>
- <DialogContent showCloseButton={false} className="sm:max-w-md">
+ <DialogContent
+ showCloseButton={false}
+ // A minmax(0, 1fr) track, so the long key scrolls in its box and does
+ // not push the Copy and Done buttons out of the dialog.
+ className="grid-cols-1 sm:max-w-md"
+ >
{createdKey ? (
<>
<DialogHeader>
@@ -219,12 +243,13 @@ export function ApiKeySettings() {
<span className="font-mono text-xs">
Authorization: Bearer
</span>{" "}
- to <span className="font-mono text-xs">{mcpUrl}</span>.
+ to{" "}
+ <span className="font-mono text-xs break-all">{mcpUrl}</span>.
</DialogDescription>
</DialogHeader>
<div className="flex items-center gap-2">
<code
- className="min-w-0 flex-1 overflow-x-auto rounded bg-base-200 px-2.5 py-2 font-mono text-xs"
+ className="min-w-0 flex-1 overflow-x-auto rounded bg-muted px-2.5 py-2 font-mono text-xs"
data-ph-mask
>
{createdKey}
@@ -242,43 +267,30 @@ export function ApiKeySettings() {
</DialogFooter>
</>
) : (
- <form
- className="grid gap-4"
- onSubmit={(event) => {
- event.preventDefault();
- if (name.trim()) createMutation.mutate(name.trim());
- }}
- >
- <DialogHeader>
- <DialogTitle>Create API key</DialogTitle>
- </DialogHeader>
- <label className="form-control w-full">
- <span className="label-text pb-1 text-xs text-base-content/60">
- Name
- </span>
- <input
- className="input input-sm input-bordered w-full"
- placeholder="Claude Code on laptop"
- value={name}
- maxLength={MAX_KEY_NAME_LENGTH}
- onChange={(event) => setName(event.currentTarget.value)}
- required
- autoFocus
- />
- </label>
- <DialogFooter>
- <Button variant="ghost" onClick={closeCreateModal}>
- Cancel
- </Button>
- <Button
- type="submit"
- pending={createMutation.isPending}
- disabled={!name.trim()}
- >
- Create
- </Button>
- </DialogFooter>
- </form>
+ <form.AppForm>
+ <form.Form className="grid gap-4">
+ <DialogHeader>
+ <DialogTitle>Create API key</DialogTitle>
+ </DialogHeader>
+ <form.AppField name="name">
+ {(field) => (
+ <field.TextField
+ label="Name"
+ placeholder="Claude Code on laptop"
+ maxLength={MAX_KEY_NAME_LENGTH}
+ required
+ autoFocus
+ />
+ )}
+ </form.AppField>
+ <DialogFooter>
+ <Button variant="ghost" onClick={closeCreateModal}>
+ Cancel
+ </Button>
+ <form.SubmitButton>Create</form.SubmitButton>
+ </DialogFooter>
+ </form.Form>
+ </form.AppForm>
)}
</DialogContent>
</Dialog>
diff --git a/src/client/features/team/InviteTeammateModal.tsx b/src/client/features/team/InviteTeammateModal.tsx
index 887ef881..44438dd1 100644
--- a/src/client/features/team/InviteTeammateModal.tsx
+++ b/src/client/features/team/InviteTeammateModal.tsx
@@ -1,10 +1,25 @@
import { useMutation } from "@tanstack/react-query";
-import { useState } from "react";
+import { revalidateLogic } from "@tanstack/react-form";
import { toast } from "sonner";
+import { z } from "zod";
+import { useAppForm } from "@/client/components/form/useAppForm";
+import { Button } from "@/client/components/ui/button";
+import {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from "@/client/components/ui/dialog";
import { getErrorCode } from "@/client/lib/error-messages";
import { captureClientEvent } from "@/client/lib/posthog";
import { sendTeamInvitation } from "@/serverFunctions/organization";
+const inviteSchema = z.object({
+ email: z.string().trim().email("Enter a valid email address."),
+});
+
export function inviteErrorMessage(error: Error) {
const code = getErrorCode(error);
if (code === "RATE_LIMITED") {
@@ -23,8 +38,6 @@ export function InviteTeammateModal({
onClose: () => void;
onInvited: () => void;
}) {
- const [email, setEmail] = useState("");
-
// Server function (not authClient.inviteMember): it enforces the daily send
// limits and fails visibly when the invite email doesn't send.
const inviteMutation = useMutation({
@@ -37,60 +50,66 @@ export function InviteTeammateModal({
onClose();
},
onError: (error: Error) => {
- toast.error(inviteErrorMessage(error));
+ if (getErrorCode(error) === "CONFLICT") {
+ form.setErrorMap({
+ onSubmit: { fields: { email: "This person is already a member." } },
+ });
+ } else {
+ toast.error(inviteErrorMessage(error));
+ }
// An email-send failure still creates the pending row — show it.
onInvited();
},
});
+ const form = useAppForm({
+ defaultValues: { email: "" },
+ validationLogic: revalidateLogic(),
+ validators: { onDynamic: inviteSchema },
+ onSubmit: ({ value }) => inviteMutation.mutateAsync(value.email.trim()),
+ });
+
return (
- <div className="modal modal-open">
- <div className="modal-box max-w-md">
- <form
- onSubmit={(event) => {
- event.preventDefault();
- const trimmed = email.trim();
- if (trimmed) inviteMutation.mutate(trimmed);
- }}
- >
- <h3 className="text-lg font-bold">Invite a teammate</h3>
- <p className="mt-2 text-sm text-base-content/60">
- They&rsquo;ll join as an Admin with full access to each project
- except for billing. The invitation link expires in 7 days.
- </p>
- <label className="form-control mt-4 w-full">
- <span className="label-text pb-1 text-xs text-base-content/60">
- Email
- </span>
- <input
- type="email"
- className="input input-sm input-bordered w-full"
- placeholder="[email protected]"
- value={email}
- onChange={(event) => setEmail(event.currentTarget.value)}
- required
- autoFocus
- />
- </label>
- <div className="modal-action">
- <button
- type="button"
- className="btn btn-ghost btn-sm"
- onClick={onClose}
- >
- Cancel
- </button>
- <button
- type="submit"
- className="btn btn-primary btn-sm"
- disabled={inviteMutation.isPending || !email.trim()}
- >
- {inviteMutation.isPending ? "Sending…" : "Send invite"}
- </button>
- </div>
- </form>
- </div>
- <div className="modal-backdrop" onClick={onClose} />
- </div>
+ <Dialog
+ open
+ onOpenChange={(open) => {
+ if (!open && !inviteMutation.isPending) onClose();
+ }}
+ >
+ <DialogContent showCloseButton={false} className="sm:max-w-md">
+ <form.AppForm>
+ <form.Form className="flex flex-col gap-4">
+ <DialogHeader>
+ <DialogTitle>Invite a teammate</DialogTitle>
+ <DialogDescription>
+ They&rsquo;ll join as an Admin with full access to each project
+ except for billing. The invitation link expires in 7 days.
+ </DialogDescription>
+ </DialogHeader>
+ <form.AppField name="email">
+ {(field) => (
+ <field.TextField
+ label="Email"
+ type="email"
+ placeholder="[email protected]"
+ required
+ autoFocus
+ />
+ )}
+ </form.AppField>
+ <DialogFooter>
+ <Button
+ variant="ghost"
+ onClick={onClose}
+ disabled={inviteMutation.isPending}
+ >
+ Cancel
+ </Button>
+ <form.SubmitButton>Send invite</form.SubmitButton>
+ </DialogFooter>
+ </form.Form>
+ </form.AppForm>
+ </DialogContent>
+ </Dialog>
);
}
diff --git a/src/client/features/team/TeamSettings.tsx b/src/client/features/team/TeamSettings.tsx
index a6837a3a..8ef274d2 100644
--- a/src/client/features/team/TeamSettings.tsx
+++ b/src/client/features/team/TeamSettings.tsx
@@ -6,8 +6,18 @@ import {
} from "@tanstack/react-query";
import { useState } from "react";
import { toast } from "sonner";
+import { SectionHeader } from "@/client/components/PageHeader";
+import { PermissionHint } from "@/client/components/PermissionHint";
import { QueryError } from "@/client/components/QueryState";
import { PageLoading } from "@/client/components/Spinner";
+import { Button } from "@/client/components/ui/button";
+import {
+ Table,
+ TableBody,
+ TableHead,
+ TableHeader,
+ TableRow,
+} from "@/client/components/ui/table";
import {
InviteTeammateModal,
inviteErrorMessage,
@@ -139,38 +149,39 @@ export function TeamSettings() {
return (
<section className="space-y-3">
- <div className="flex items-center justify-between gap-4">
- <h2 className="text-sm font-medium text-base-content/50">Members</h2>
- {canManageTeam ? (
- <button
- type="button"
- className="btn btn-primary btn-sm"
- onClick={() => setIsInviteOpen(true)}
- >
- Invite teammate
- </button>
- ) : null}
- </div>
- <p className="text-sm text-base-content/60">
+ <SectionHeader
+ title="Members"
+ action={
+ canManageTeam ? (
+ <Button size="sm" onClick={() => setIsInviteOpen(true)}>
+ Invite teammate
+ </Button>
+ ) : null
+ }
+ />
+ <p className="text-sm text-muted-foreground">
Teammates join as Admins. Admins have full access to each project except
for billing.
</p>
+ {orgContextQuery.isSuccess && !canManageTeam ? (
+ <PermissionHint action="invite or remove teammates" />
+ ) : null}
{loadError}
{teamQuery.isPending ? (
<PageLoading />
) : (
- <div className="overflow-x-auto rounded-lg border border-base-300 bg-base-100">
- <table className="table table-sm">
- <thead>
- <tr>
- <th>Member</th>
- <th>Role</th>
- <th>Status</th>
- <th className="w-10"></th>
- </tr>
- </thead>
- <tbody>
+ <div className="rounded-lg border border-border bg-card">
+ <Table>
+ <TableHeader>
+ <TableRow>
+ <TableHead>Member</TableHead>
+ <TableHead>Role</TableHead>
+ <TableHead>Status</TableHead>
+ <TableHead className="w-10" />
+ </TableRow>
+ </TableHeader>
+ <TableBody>
{members.map((member) => (
<MemberRow
key={member.id}
@@ -196,8 +207,8 @@ export function TeamSettings() {
}
/>
))}
- </tbody>
- </table>
+ </TableBody>
+ </Table>
</div>
)}
diff --git a/src/client/features/team/TeamTableRows.tsx b/src/client/features/team/TeamTableRows.tsx
index 548eeb8c..eab7b342 100644
--- a/src/client/features/team/TeamTableRows.tsx
+++ b/src/client/features/team/TeamTableRows.tsx
@@ -1,5 +1,10 @@
import { Crown, Send, Trash2 } from "lucide-react";
-import { PortalMenu } from "@/client/components/PortalMenu";
+import { useState } from "react";
+import { ConfirmDialog } from "@/client/components/ConfirmDialog";
+import { RowActionsMenu } from "@/client/components/RowActionsMenu";
+import { Badge } from "@/client/components/ui/badge";
+import { DropdownMenuItem } from "@/client/components/ui/dropdown-menu";
+import { TableCell, TableRow } from "@/client/components/ui/table";
import { hasOrgPermission } from "@/lib/org-permissions";
const ROLE_LABELS: Record<string, string> = {
@@ -54,72 +59,60 @@ export function MemberRow({
const canRemove = canManageTeam && !isSelf && (!memberIsOwner || isOwner);
// Owners can always remove, so this only ever adds to the remove menu.
const canTransferOwnership = isOwner && !isSelf && !memberIsOwner;
+ const [isConfirmingRemove, setIsConfirmingRemove] = useState(false);
return (
- <tr className="hover">
- <td className="max-w-[280px]">
+ <TableRow>
+ <TableCell className="max-w-[280px]">
<p className="truncate font-medium" data-ph-mask>
{member.user.name || member.user.email}
{isSelf ? (
- <span className="font-normal text-base-content/50"> (you)</span>
+ <span className="font-normal text-muted-foreground"> (you)</span>
) : null}
</p>
- <p className="truncate text-xs text-base-content/50" data-ph-mask>
+ <p className="truncate text-xs text-muted-foreground" data-ph-mask>
{member.user.email}
</p>
- </td>
- <td>
- <span className="badge badge-ghost badge-sm">
- {formatRole(member.role)}
- </span>
- </td>
- <td className="text-xs text-base-content/70">Active</td>
- <td>
+ </TableCell>
+ <TableCell>
+ <Badge variant="secondary">{formatRole(member.role)}</Badge>
+ </TableCell>
+ <TableCell className="text-xs text-muted-foreground">Active</TableCell>
+ <TableCell>
{canRemove ? (
- <PortalMenu
- ariaLabel={`Actions for ${member.user.email}`}
- menuClassName="w-52"
+ <RowActionsMenu label={`Actions for ${member.user.email}`}>
+ {canTransferOwnership ? (
+ <DropdownMenuItem onClick={onTransferOwnership}>
+ <Crown />
+ Transfer ownership
+ </DropdownMenuItem>
+ ) : null}
+ <DropdownMenuItem
+ variant="destructive"
+ disabled={isRemoving}
+ onClick={() => setIsConfirmingRemove(true)}
+ >
+ <Trash2 />
+ Remove member
+ </DropdownMenuItem>
+ </RowActionsMenu>
+ ) : null}
+ {isConfirmingRemove ? (
+ <ConfirmDialog
+ title={`Remove ${member.user.email} from this organization?`}
+ confirmLabel="Remove member"
+ destructive
+ onClose={() => setIsConfirmingRemove(false)}
+ onConfirm={() => {
+ setIsConfirmingRemove(false);
+ onRemove();
+ }}
>
- {(close) => (
- <>
- {canTransferOwnership ? (
- <li>
- <button
- onClick={() => {
- close();
- onTransferOwnership();
- }}
- >
- <Crown className="size-3.5" />
- Transfer ownership
- </button>
- </li>
- ) : null}
- <li>
- <button
- className="text-error"
- disabled={isRemoving}
- onClick={() => {
- close();
- if (
- window.confirm(
- `Remove ${member.user.email} from this organization? They lose access immediately.`,
- )
- ) {
- onRemove();
- }
- }}
- >
- <Trash2 className="size-3.5" />
- Remove member
- </button>
- </li>
- </>
- )}
- </PortalMenu>
+ They lose access immediately.
+ </ConfirmDialog>
) : null}
- </td>
- </tr>
+ </TableCell>
+ </TableRow>
);
}
@@ -139,59 +132,41 @@ export function InvitationRow({
onCancel: () => void;
}) {
return (
- <tr className="hover">
- <td className="max-w-[280px]">
+ <TableRow>
+ <TableCell className="max-w-[280px]">
<p className="truncate font-medium" data-ph-mask>
{invitation.email}
</p>
- </td>
- <td>
- <span className="badge badge-ghost badge-sm">
+ </TableCell>
+ <TableCell>
+ <Badge variant="secondary">
{formatRole(invitation.role ?? "member")}
- </span>
- </td>
- <td className="text-xs text-base-content/70">
+ </Badge>
+ </TableCell>
+ <TableCell className="text-xs text-muted-foreground">
Invited &middot; expires{" "}
{new Date(invitation.expiresAt).toLocaleDateString()}
- </td>
- <td>
+ </TableCell>
+ <TableCell>
{canManageTeam ? (
- <PortalMenu
- ariaLabel={`Actions for the invitation to ${invitation.email}`}
- menuClassName="w-52"
+ <RowActionsMenu
+ label={`Actions for the invitation to ${invitation.email}`}
>
- {(close) => (
- <>
- <li>
- <button
- disabled={isResending}
- onClick={() => {
- close();
- onResend();
- }}
- >
- <Send className="size-3.5" />
- Resend invitation
- </button>
- </li>
- <li>
- <button
- className="text-error"
- disabled={isCanceling}
- onClick={() => {
- close();
- onCancel();
- }}
- >
- <Trash2 className="size-3.5" />
- Cancel invitation
- </button>
- </li>
- </>
- )}
- </PortalMenu>
+ <DropdownMenuItem disabled={isResending} onClick={onResend}>
+ <Send />
+ Resend invitation
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ variant="destructive"
+ disabled={isCanceling}
+ onClick={onCancel}
+ >
+ <Trash2 />
+ Cancel invitation
+ </DropdownMenuItem>
+ </RowActionsMenu>
) : null}
- </td>
- </tr>
+ </TableCell>
+ </TableRow>
);
}
diff --git a/src/client/features/team/TransferOwnershipModal.tsx b/src/client/features/team/TransferOwnershipModal.tsx
index c2fed800..7a29c4d0 100644
--- a/src/client/features/team/TransferOwnershipModal.tsx
+++ b/src/client/features/team/TransferOwnershipModal.tsx
@@ -1,6 +1,14 @@
import { useMutation } from "@tanstack/react-query";
import { toast } from "sonner";
-import { Modal } from "@/client/components/Modal";
+import { Button } from "@/client/components/ui/button";
+import {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from "@/client/components/ui/dialog";
import { getErrorCode } from "@/client/lib/error-messages";
import { captureClientEvent } from "@/client/lib/posthog";
import { transferOwnership } from "@/serverFunctions/organization";
@@ -48,45 +56,43 @@ export function TransferOwnershipModal({
});
return (
- <Modal
- maxWidth="max-w-md"
- onClose={transferMutation.isPending ? undefined : onClose}
- labelledBy="transfer-ownership-title"
+ <Dialog
+ open
+ onOpenChange={(open) => {
+ if (!open && !transferMutation.isPending) onClose();
+ }}
>
- <div>
- <h3 id="transfer-ownership-title" className="text-lg font-bold">
- Transfer ownership?
- </h3>
- <p className="mt-2 text-sm text-base-content/70">
- <span className="font-medium text-base-content" data-ph-mask>
- {displayName}
- </span>{" "}
- becomes the owner of this organization and manages its billing. You
- become an Admin and keep full access to each project.
- </p>
- <p className="mt-2 text-sm text-base-content/70">
- Projects, data, and the subscription stay with the organization. Only
- the new owner can transfer ownership again.
- </p>
- </div>
- <div className="modal-action mt-0">
- <button
- type="button"
- className="btn btn-ghost btn-sm"
- onClick={onClose}
- disabled={transferMutation.isPending}
- >
- Cancel
- </button>
- <button
- type="button"
- className="btn btn-primary btn-sm"
- onClick={() => transferMutation.mutate()}
- disabled={transferMutation.isPending}
- >
- {transferMutation.isPending ? "Transferring…" : "Transfer ownership"}
- </button>
- </div>
- </Modal>
+ <DialogContent showCloseButton={false} className="sm:max-w-md">
+ <DialogHeader>
+ <DialogTitle>Transfer ownership?</DialogTitle>
+ <DialogDescription>
+ <span className="font-medium text-foreground" data-ph-mask>
+ {displayName}
+ </span>{" "}
+ becomes the owner of this organization and manages its billing. You
+ become an Admin and keep full access to each project.
+ </DialogDescription>
+ <DialogDescription>
+ Projects, data, and the subscription stay with the organization.
+ Only the new owner can transfer ownership again.
+ </DialogDescription>
+ </DialogHeader>
+ <DialogFooter>
+ <Button
+ variant="ghost"
+ onClick={onClose}
+ disabled={transferMutation.isPending}
+ >
+ Cancel
+ </Button>
+ <Button
+ onClick={() => transferMutation.mutate()}
+ pending={transferMutation.isPending}
+ >
+ Transfer ownership
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
);
}
diff --git a/src/routes/_app/settings.tsx b/src/routes/_app/settings.tsx
index 062349d2..127823c6 100644
--- a/src/routes/_app/settings.tsx
+++ b/src/routes/_app/settings.tsx
@@ -1,5 +1,6 @@
import { createFileRoute, Outlet } from "@tanstack/react-router";
import { NavTab, NavTabs } from "@/client/components/NavTabs";
+import { PageHeader } from "@/client/components/PageHeader";
import { isHostedClientAuthMode } from "@/lib/auth-mode";
export const Route = createFileRoute("/_app/settings")({
@@ -22,7 +23,7 @@ function SettingsLayout() {
<div className="h-full overflow-auto">
<div className="mx-auto w-full max-w-4xl space-y-8 p-4 py-8 pb-24 sm:p-6 md:py-12 md:pb-12">
<div className="space-y-4">
- <h1 className="text-2xl font-bold tracking-tight">Settings</h1>
+ <PageHeader title="Settings" />
<NavTabs label="Settings sections">
{tabs.map((tab) => (
<NavTab
diff --git a/src/routes/_app/settings/index.tsx b/src/routes/_app/settings/index.tsx
index 85f20c64..5a398f7f 100644
--- a/src/routes/_app/settings/index.tsx
+++ b/src/routes/_app/settings/index.tsx
@@ -2,7 +2,9 @@ import { createFileRoute } from "@tanstack/react-router";
import { useState } from "react";
import { toast } from "sonner";
import { ApiKeySettings } from "@/client/features/settings/ApiKeySettings";
+import { SectionHeader } from "@/client/components/PageHeader";
import { ThemePreferenceRadio } from "@/client/components/ThemePreferenceMenuItems";
+import { Switch } from "@/client/components/ui/switch";
import { authClient, useSession } from "@/lib/auth-client";
import { isHostedClientAuthMode } from "@/lib/auth-mode";
import { version } from "../../../../package.json";
@@ -39,7 +41,7 @@ function PersonalSettings() {
return (
<div className="space-y-10">
<section className="space-y-3">
- <h2 className="text-sm font-medium text-base-content/50">Appearance</h2>
+ <SectionHeader title="Appearance" />
<div className="flex items-center justify-between gap-6">
<span className="text-sm">Theme</span>
<ThemePreferenceRadio />
@@ -51,23 +53,19 @@ function PersonalSettings() {
<ApiKeySettings />
<section className="space-y-3">
- <h2 className="text-sm font-medium text-base-content/50">
- Analytics
- </h2>
+ <SectionHeader title="Analytics" />
<div className="flex items-start justify-between gap-6">
<div>
<p className="text-sm">Help improve OpenSEO</p>
- <p className="mt-1 text-sm text-base-content/60">
+ <p className="mt-1 text-sm text-muted-foreground">
Share analytics and usage data.
</p>
</div>
- <input
- type="checkbox"
- className="toggle toggle-primary"
+ <Switch
checked={analyticsEnabled}
disabled={isSaving}
- onChange={(event) => {
- void updateAnalyticsPreference(event.currentTarget.checked);
+ onCheckedChange={(checked) => {
+ void updateAnalyticsPreference(checked);
}}
aria-label="Enable product analytics"
/>
@@ -76,10 +74,10 @@ function PersonalSettings() {
</>
) : (
<section className="space-y-3">
- <h2 className="text-sm font-medium text-base-content/50">About</h2>
+ <SectionHeader title="About" />
<div className="flex items-center justify-between gap-6">
<span className="text-sm">Version</span>
- <span className="font-mono text-sm text-base-content/60">
+ <span className="font-mono text-sm text-muted-foreground">
v{version}
</span>
</div>
diff --git a/src/serverFunctions/organization.ts b/src/serverFunctions/organization.ts
index e72e42be..488c4a71 100644
--- a/src/serverFunctions/organization.ts
+++ b/src/serverFunctions/organization.ts
@@ -1,4 +1,5 @@
import { createServerFn } from "@tanstack/react-start";
+import { APIError } from "better-auth/api";
import { getRequest } from "@tanstack/react-start/server";
import { z } from "zod";
import { getAuth, getHostedBaseUrl } from "@/lib/auth";
@@ -117,17 +118,28 @@ export const sendTeamInvitation = createServerFn({ method: "POST" })
await consumeInvitationSendBudget(context.organizationId, data.email);
- const invitation = await getAuth().api.createInvitation({
- headers: getRequest().headers,
- body: {
- email: data.email,
- role: "admin",
- resend: true,
- // Bind the invitation to the request's resolved org, not the session's
- // active-organization hint, which can be stale after a switch.
- organizationId: context.organizationId,
- },
- });
+ const invitation = await getAuth()
+ .api.createInvitation({
+ headers: getRequest().headers,
+ body: {
+ email: data.email,
+ role: "admin",
+ resend: true,
+ // Bind the invitation to the request's resolved org, not the session's
+ // active-organization hint, which can be stale after a switch.
+ organizationId: context.organizationId,
+ },
+ })
+ .catch((error: unknown) => {
+ // The invite dialog shows this one inline, next to the email.
+ if (
+ error instanceof APIError &&
+ error.body?.code === "USER_IS_ALREADY_A_MEMBER_OF_THIS_ORGANIZATION"
+ ) {
+ throw new AppError("CONFLICT");
+ }
+ throw error;
+ });
const [inviter, memberships] = await Promise.all([
AuthRepository.getHostedUser(context.userId),