-
-
+ {selectedType === "http_json" && (
+
+
{
- const copy = [...steps];
- copy[i].extractName = e.target.value;
- setSteps(copy);
- }}
- placeholder="auth_token"
+ required
+ value={jsonPath}
+ onChange={(e) => setJsonPath(e.target.value)}
+ placeholder="data.status"
className="pg-input font-mono"
/>
-
-
-
+
+
-
-
-
+
+
{
- const copy = [...steps];
- copy[i].extractSelector = e.target.value;
- setSteps(copy);
- }}
- placeholder="data.access_token"
+ value={jsonExpected}
+ onChange={(e) => setJsonExpected(e.target.value)}
+ placeholder="ok"
className="pg-input font-mono"
/>
-
+
+ )}
+
+ {method !== "GET" && method !== "HEAD" && (
+
+
+ )}
+ >
+ )}
+
+ {/* Multi-step synthetic */}
+ {selectedType === "http_synthetic" && (
+ <>
+
+
+ Steps run in order. Use extracted values in later steps as{" "}
+ {"{{name}}"}.
+
+
- ))}
-
- )}
- {/* Host / Port / Network / Game / TLS */}
- {(selectedType === "tcp" ||
- selectedType === "udp" ||
- selectedType === "tls" ||
- selectedType === "minecraft_java" ||
- selectedType === "minecraft_bedrock" ||
- selectedType === "source_a2s" ||
- selectedType === "fivem") && (
-
-
-
-
+ {steps.map((step, i) => (
+
+
+
+ updateStep(i, { name: e.target.value })}
+ className="pg-input font-medium"
+ />
+
+ {steps.length > 1 && (
+
+ )}
+
+
+
+
+
+
+
+ updateStep(i, { url: e.target.value })}
+ placeholder="https://api.example.com/resource?token={{auth_token}}"
+ className="pg-input font-mono"
+ />
+
+
+
+
+
+ updateStep(i, { extractName: e.target.value })}
+ placeholder="auth_token"
+ className="pg-input font-mono"
+ />
+
+
+
+
+
+ updateStep(i, { extractSelector: e.target.value })}
+ placeholder="data.access_token"
+ className="pg-input font-mono"
+ />
+
+
+
+ ))}
+
+ >
+ )}
+
+ {/* Host and port based checks */}
+ {HOST_PORT_TYPES.includes(selectedType) && (
+
+ setHost(e.target.value)}
- placeholder="play.example.com"
- className="pg-input font-mono"
- />
-
-
-
- setPort(Number(e.target.value))}
- className="pg-input font-mono"
- />
-
+ label="Hostname or IP address"
+ error={fieldErrors["net-host"]}
+ className="md:col-span-2"
+ >
+
setHost(e.target.value)}
+ placeholder="play.example.com"
+ className="pg-input font-mono"
+ />
+
+
+ setPort(Number(e.target.value))}
+ className="pg-input font-mono"
+ />
+
- {selectedType === "tcp" && (
- <>
-
-
- setTcpSend(e.target.value)}
- placeholder="PING\r\n"
- className="pg-input font-mono"
- />
-
-
-
- setTcpExpect(e.target.value)}
- placeholder="PONG"
- className="pg-input font-mono"
- />
-
-
-
-
- >
- )}
+
+
+ setTcpExpect(e.target.value)}
+ placeholder="PONG"
+ className="pg-input font-mono"
+ />
+
+
+ >
+ )}
- {selectedType === "udp" && (
- <>
-
-
-
+ setUdpPayload(e.target.value)}
- placeholder="ping"
- className="pg-input font-mono"
- />
-
-
-
+ label="Payload"
+ hint="UTF-8 text, or hex as hex:deadbeef."
+ className="md:col-span-2"
+ >
+ setUdpPayload(e.target.value)}
+ placeholder="ping"
+ className="pg-input font-mono"
+ />
+
+
+ setUdpExpect(e.target.value)}
+ placeholder="pong"
+ className="pg-input font-mono"
+ />
+
+ >
+ )}
+
+ {selectedType === "tls" && (
+ <>
+
+ setWarnDays(Number(e.target.value))}
+ className="pg-input font-mono"
+ />
+
+
+ setCritDays(Number(e.target.value))}
+ className="pg-input font-mono"
+ />
+
+ >
+ )}
+
+ {(selectedType === "minecraft_java" ||
+ selectedType === "minecraft_bedrock" ||
+ selectedType === "fivem") && (
+
setUdpExpect(e.target.value)}
- placeholder="pong"
- className="pg-input font-mono"
+ value={expectedMotd}
+ onChange={(e) => setExpectedMotd(e.target.value)}
+ placeholder="Survival SMP"
+ className="pg-input"
/>
-
- >
- )}
+
+ )}
- {selectedType === "tls" && (
- <>
-
-
- setWarnDays(Number(e.target.value))}
- className="pg-input font-mono"
- />
-
-
-
+ {selectedType === "source_a2s" && (
+
setCritDays(Number(e.target.value))}
+ {...a11y("game-map", true)}
+ type="text"
+ value={expectedMap}
+ onChange={(e) => setExpectedMap(e.target.value)}
+ placeholder="de_dust2"
className="pg-input font-mono"
/>
-
- >
- )}
+
+ )}
+
+ )}
- {(selectedType === "minecraft_java" ||
- selectedType === "minecraft_bedrock" ||
- selectedType === "fivem") && (
-
-
+ {selectedType === "icmp" && (
+
+
setExpectedMotd(e.target.value)}
- placeholder="Optional match text"
- className="pg-input"
+ required
+ value={host}
+ onChange={(e) => setHost(e.target.value)}
+ placeholder="1.1.1.1"
+ className="pg-input font-mono"
/>
-
- )}
-
- {selectedType === "source_a2s" && (
-
-
+
+
setExpectedMap(e.target.value)}
- placeholder="de_dust2 or Procedural Map"
+ {...a11y("icmp-count", true)}
+ type="number"
+ min={1}
+ max={10}
+ value={icmpCount}
+ onChange={(e) => setIcmpCount(Number(e.target.value))}
className="pg-input font-mono"
/>
-
- )}
-
- )}
-
- {selectedType === "icmp" && (
-
- )}
+ )}
- {selectedType === "grpc" && (
-
- )}
+ )}
- {selectedType === "dns" && (
-
-
-
-
+ setDnsHostname(e.target.value)}
- placeholder="example.com"
- className="pg-input font-mono"
- />
-
-
-
-
-
-
- setDnsNameserver(e.target.value)}
- placeholder="1.1.1.1"
- className="pg-input font-mono"
- />
-
-
-
-
+
+
+ setDnsNameserver(e.target.value)}
+ placeholder="1.1.1.1"
+ className="pg-input font-mono"
+ />
+
+ setDnsExpected(e.target.value)}
- placeholder="93.184.216.34 or v=spf1"
- className="pg-input font-mono"
- />
+ label="Expected value"
+ hint="Optional substring of any returned record."
+ className="md:col-span-4"
+ >
+ setDnsExpected(e.target.value)}
+ placeholder="93.184.216.34 or v=spf1"
+ className="pg-input font-mono"
+ />
+
-
- )}
+ )}
- {selectedType === "heartbeat" && (
-
-
-
-
+ setHbInterval(Number(e.target.value))}
- className="pg-input font-mono"
- />
-
-
-
- )}
+ )}
- {selectedType === "rdap" && (
-
-
-
- setRdapDomain(e.target.value)}
- placeholder="example.com"
- className="pg-input font-mono"
- />
-
-
-
- setWarnDays(Number(e.target.value))}
- className="pg-input font-mono"
- />
-
-
- )}
+ )}
- {selectedType === "external_status" && (
-
+ {selectedType === "external_status" && (
-
-
+
-
-
-
+
+
setExtProvider(e.target.value)}
- className="pg-input"
+ className="pg-select"
>
-
+
-
+
-
-
-
+
+
setExtComponent(e.target.value)}
placeholder="API Requests"
className="pg-input"
/>
-
+
+
+ Works with Statuspage /api/v2/status.json or{" "}
+ /api/v2/summary.json, Instatus{" "}
+ /summary.json and Uptime{" "}
+ /summary.json feeds.
+
-
- Supports Statuspage JSON (/api/v2/status.json or{" "}
- /api/v2/summary.json), Instatus{" "}
- /summary.json, and Uptime{" "}
- /summary.json feeds. Leave component filter blank to
- track overall page status.
-
-
- )}
+ )}
+
- {/* Scheduling & Quorum */}
-
-
-
-
+ setIntervalSecs(Number(e.target.value))}
- className="pg-input font-mono"
- />
-
-
-
-
+ setIntervalSecs(Number(e.target.value))}
+ className="pg-input font-mono"
+ />
+
+ setTimeoutMs(Number(e.target.value))}
- className="pg-input font-mono"
- />
+ label="Timeout, ms"
+ hint="Minimum 500."
+ error={fieldErrors["sched-timeout"]}
+ >
+ setTimeoutMs(Number(e.target.value))}
+ className="pg-input font-mono"
+ />
+
+
+ setRegionsCsv(e.target.value)}
+ placeholder="us-east, eu-west"
+ className="pg-input font-mono"
+ />
+
-
-
-
+
+
+
+
+ setConfirmFailures(Number(e.target.value))}
+ className="pg-input font-mono"
+ />
+
+ setQuorumMin(Number(e.target.value))}
- className="pg-input font-mono"
- />
+ label="Region quorum"
+ hint="Regions that must agree the target is down."
+ error={fieldErrors["sched-quorum"]}
+ >
+ setQuorumMin(Number(e.target.value))}
+ className="pg-input font-mono"
+ />
+
-
-
-
setConfirmFailures(Number(e.target.value))}
- className="pg-input font-mono"
- />
+
+
+
+
+ {error ? (
+
+ {error}
+
+ ) : Object.keys(fieldErrors).length > 0 ? (
+
+ Fix the highlighted field{Object.keys(fieldErrors).length === 1 ? "" : "s"} to
+ continue.
+
+ ) : null}
-
-
-
setRegionsCsv(e.target.value)}
- placeholder="us-east, eu-west"
- className="pg-input font-mono"
- />
+
+
+ Cancel
+
+
+
+
+ );
+}
- {error && (
-
- {error}
-
- )}
+function FormSection({
+ title,
+ description,
+ children,
+}: {
+ title: string;
+ description: ReactNode;
+ children: ReactNode;
+}) {
+ return (
+
+
+
{title}
+
+ {description}
+
+
+ {children}
+
+ );
+}
-
-
- Cancel
-
-
-
-
+/** Label above the control, then either the inline error or the helper text. */
+function Field({
+ id,
+ label,
+ hint,
+ error,
+ className,
+ children,
+}: {
+ id: string;
+ label: string;
+ hint?: string;
+ error?: string;
+ className?: string;
+ children: ReactNode;
+}) {
+ return (
+
+
+ {children}
+ {error ? (
+
+ {error}
+
+ ) : hint ? (
+
+ {hint}
+
+ ) : null}
);
}
+
+function CheckboxField({
+ checked,
+ onChange,
+ label,
+}: {
+ checked: boolean;
+ onChange: (v: boolean) => void;
+ label: string;
+}) {
+ return (
+
+ );
+}
diff --git a/web/src/pages/OrganizationPage.tsx b/web/src/pages/OrganizationPage.tsx
index 77c62ab..b03a3cf 100644
--- a/web/src/pages/OrganizationPage.tsx
+++ b/web/src/pages/OrganizationPage.tsx
@@ -1,28 +1,56 @@
-import { Trash2 } from "lucide-react";
-import { useEffect, useState } from "react";
+import { MailPlus, MoreHorizontal, Trash2, UserMinus, Users } from "lucide-react";
+import { type FormEvent, useEffect, useState } from "react";
import { ArrowGlyph } from "../components/BrandMark";
+import { Dialog } from "../components/Dialog";
+import { EmptyState } from "../components/EmptyState";
+import { Menu, type MenuEntry } from "../components/Menu";
+import { PageHeader } from "../components/PageHeader";
import type { AuthMeResponse } from "../lib/api";
import { authClient } from "../lib/auth-client";
+import { relativeTime } from "../lib/time";
+
+type Role = "owner" | "admin" | "member";
interface OrgMember {
id: string;
userId: string;
role: string;
+ createdAt?: string | Date;
user: {
name: string;
email: string;
};
}
+interface OrgInvitation {
+ id: string;
+ email: string;
+ role: string;
+ status: string;
+ expiresAt?: string | Date;
+}
+
+const ROLES: Array<{ value: Role; label: string }> = [
+ { value: "member", label: "Member" },
+ { value: "admin", label: "Admin" },
+ { value: "owner", label: "Owner" },
+];
+
+const roleLabel = (r: string) => ROLES.find((x) => x.value === r)?.label ?? r;
+
export function OrganizationPage({ me }: { me: AuthMeResponse }) {
- const [members, setMembers] = useState
([]);
+ const [members, setMembers] = useState(null);
+ const [invitations, setInvitations] = useState([]);
+ const [loadError, setLoadError] = useState(null);
const [inviteEmail, setInviteEmail] = useState("");
- const [inviteRole, setInviteRole] = useState<"member" | "admin" | "owner">(
- "member",
- );
- const [message, setMessage] = useState<{ text: string; ok: boolean } | null>(
- null,
- );
+ const [inviteRole, setInviteRole] = useState("member");
+ const [inviting, setInviting] = useState(false);
+ const [inviteMsg, setInviteMsg] = useState<{ text: string; ok: boolean } | null>(null);
+ const [rowError, setRowError] = useState(null);
+ const [toRemove, setToRemove] = useState(null);
+ const [toCancel, setToCancel] = useState(null);
+ const [confirmBusy, setConfirmBusy] = useState(false);
+ const [confirmError, setConfirmError] = useState(null);
const activeOrg = me.memberships.find(
(m) => m.organizationId === me.active_organization_id,
@@ -33,67 +61,92 @@ export function OrganizationPage({ me }: { me: AuthMeResponse }) {
const res = await authClient.organization.getFullOrganization({
query: { organizationId: activeOrg.organizationId },
});
- if (res.data?.members) {
- setMembers(res.data.members as unknown as OrgMember[]);
+ if (res.error) {
+ setLoadError(res.error.message || "Could not load members");
+ setMembers((prev) => prev ?? []);
+ return;
}
+ setLoadError(null);
+ setMembers((res.data?.members ?? []) as unknown as OrgMember[]);
+ setInvitations(
+ ((res.data?.invitations ?? []) as unknown as OrgInvitation[]).filter(
+ (i) => i.status === "pending",
+ ),
+ );
};
+ // biome-ignore lint/correctness/useExhaustiveDependencies: reload when the workspace changes
useEffect(() => {
- loadMembers().catch(() => {});
+ loadMembers().catch((err) => {
+ setLoadError(err instanceof Error ? err.message : "Could not load members");
+ setMembers((prev) => prev ?? []);
+ });
}, [activeOrg?.organizationId]);
- const handleInvite = async (e: React.FormEvent) => {
+ const handleInvite = async (e: FormEvent) => {
e.preventDefault();
if (!activeOrg) return;
- setMessage(null);
- const res = await authClient.organization.inviteMember({
- email: inviteEmail.trim(),
- role: inviteRole,
- organizationId: activeOrg.organizationId,
- });
- if (res.error) {
- setMessage({
- text: res.error.message || "Failed to send invitation",
- ok: false,
+ setInviteMsg(null);
+ setInviting(true);
+ try {
+ const res = await authClient.organization.inviteMember({
+ email: inviteEmail.trim(),
+ role: inviteRole,
+ organizationId: activeOrg.organizationId,
});
- } else {
- setMessage({
- text: `Invitation created for ${inviteEmail} (${inviteRole}).`,
- ok: true,
- });
- setInviteEmail("");
+ if (res.error) {
+ setInviteMsg({ text: res.error.message || "Failed to send invitation", ok: false });
+ } else {
+ setInviteMsg({
+ text: `Invitation created for ${inviteEmail.trim()} as ${roleLabel(inviteRole).toLowerCase()}.`,
+ ok: true,
+ });
+ setInviteEmail("");
+ await loadMembers();
+ }
+ } finally {
+ setInviting(false);
}
};
- const handleRoleChange = async (
- memberId: string,
- role: "owner" | "admin" | "member",
- ) => {
+ const handleRoleChange = async (memberId: string, role: Role) => {
if (!activeOrg) return;
- setMessage(null);
+ setRowError(null);
const res = await authClient.organization.updateMemberRole({
memberId,
role,
organizationId: activeOrg.organizationId,
});
if (res.error) {
- setMessage({
- text: res.error.message || "Role update failed",
- ok: false,
- });
+ setRowError(res.error.message || "Role update failed");
} else {
await loadMembers();
}
};
- const handleRemove = async (memberId: string) => {
- if (!activeOrg || !confirm("Remove this member from the organization?"))
- return;
- await authClient.organization.removeMember({
- memberIdOrEmail: memberId,
- organizationId: activeOrg.organizationId,
- });
- await loadMembers();
+ const runConfirm = async () => {
+ if (!activeOrg) return;
+ setConfirmBusy(true);
+ setConfirmError(null);
+ try {
+ const res = toRemove
+ ? await authClient.organization.removeMember({
+ memberIdOrEmail: toRemove.id,
+ organizationId: activeOrg.organizationId,
+ })
+ : toCancel
+ ? await authClient.organization.cancelInvitation({ invitationId: toCancel.id })
+ : null;
+ if (res?.error) {
+ setConfirmError(res.error.message || "Request failed");
+ return;
+ }
+ setToRemove(null);
+ setToCancel(null);
+ await loadMembers();
+ } finally {
+ setConfirmBusy(false);
+ }
};
const canManage =
@@ -103,131 +156,280 @@ export function OrganizationPage({ me }: { me: AuthMeResponse }) {
return (
-
-
- {activeOrg?.name ?? "Organization"}
-
-
- Manage workspace owners, admins, and members with role-based access
- control.
-
-
+
{canManage && (
-