9c60d11c2c
- Fix dialog scrollability (flex layout + max-h-[90dvh]) and increase L4 dialog to lg width - Add styled enable card to L4 dialog matching proxy host pattern - Unify section colors across proxy host and L4 dialogs (cyan=LB, emerald=DNS, violet=upstream DNS, rose=geo, amber=mTLS) - Improve light mode contrast: muted-foreground oklch 0.552→0.502, remove opacity modifiers on secondary text - Improve dark mode: boost muted-foreground to 0.85, increase border opacity 10%→16%, input 15%→20% - Add bg-card to DataTable wrapper and bg-muted/40 to table headers for surface hierarchy - Add semantic badge variants (success, warning, info, muted) and StatusChip dark mode fix - Add server-side sortable columns to Proxy Hosts and L4 Proxy Hosts (name, upstream, status, protocol, listen) - Add sortKey to DataTable Column type with clickable sort headers (ArrowUp/Down indicators, URL param driven) - Fix E2E test selectors for shadcn UI (label associations, combobox roles, dropdown menus, mobile drawer) - Add htmlFor/id to proxy host form fields and aria-labels to select triggers for accessibility - Add sorting E2E tests for both proxy host pages Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
112 lines
3.3 KiB
TypeScript
112 lines
3.3 KiB
TypeScript
"use client";
|
|
|
|
import { Lock } from "lucide-react";
|
|
import { Card, CardContent } from "@/components/ui/card";
|
|
import { DataTable } from "@/components/ui/DataTable";
|
|
import { StatusChip } from "@/components/ui/StatusChip";
|
|
import type { AcmeHost } from "../page";
|
|
import { RelativeTime } from "./RelativeTime";
|
|
|
|
type Props = {
|
|
acmeHosts: AcmeHost[];
|
|
acmePagination: { total: number; page: number; perPage: number };
|
|
search: string;
|
|
statusFilter: string | null;
|
|
};
|
|
|
|
const columns = [
|
|
{
|
|
id: "name",
|
|
label: "Proxy Host",
|
|
render: (r: AcmeHost) => (
|
|
<div className="flex items-start gap-3">
|
|
<div className={[
|
|
"mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-md border",
|
|
r.enabled
|
|
? "border-emerald-500/30 bg-emerald-500/10 text-emerald-500"
|
|
: "border-zinc-500/20 bg-zinc-500/10 text-zinc-400",
|
|
].join(" ")}>
|
|
<Lock className="h-3.5 w-3.5" />
|
|
</div>
|
|
<div>
|
|
<p className="text-sm font-semibold leading-tight">{r.name}</p>
|
|
<p className="text-xs text-muted-foreground font-mono mt-0.5">
|
|
{r.domains[0]}
|
|
{r.domains.length > 1 && (
|
|
<span className="ml-1 text-muted-foreground">+{r.domains.length - 1}</span>
|
|
)}
|
|
</p>
|
|
</div>
|
|
</div>
|
|
),
|
|
},
|
|
{
|
|
id: "issuer",
|
|
label: "Issuer",
|
|
render: (r: AcmeHost) => (
|
|
<span className="text-xs text-muted-foreground font-mono">{r.certIssuer ?? "—"}</span>
|
|
),
|
|
},
|
|
{
|
|
id: "expiry",
|
|
label: "Expiry",
|
|
render: (r: AcmeHost) => <RelativeTime validTo={r.certValidTo} status={r.certExpiryStatus} />,
|
|
},
|
|
{
|
|
id: "status",
|
|
label: "Status",
|
|
width: 110,
|
|
render: (r: AcmeHost) => (
|
|
<StatusChip status={r.enabled ? "active" : "inactive"} />
|
|
),
|
|
},
|
|
];
|
|
|
|
function acmeMobileCard(r: AcmeHost) {
|
|
return (
|
|
<Card className={["border-l-2", r.enabled ? "border-l-emerald-500" : "border-l-zinc-500/30"].join(" ")}>
|
|
<CardContent className="p-4 flex flex-col gap-1.5">
|
|
<p className="text-sm font-semibold">{r.name}</p>
|
|
<p className="text-xs text-muted-foreground font-mono">
|
|
{r.domains[0]}{r.domains.length > 1 ? ` +${r.domains.length - 1}` : ""}
|
|
</p>
|
|
<div className="flex items-center gap-2 flex-wrap mt-1">
|
|
<RelativeTime validTo={r.certValidTo} status={r.certExpiryStatus} />
|
|
<StatusChip status={r.enabled ? "active" : "inactive"} />
|
|
</div>
|
|
</CardContent>
|
|
</Card>
|
|
);
|
|
}
|
|
|
|
export function AcmeTab({ acmeHosts, acmePagination, search, statusFilter }: Props) {
|
|
const filtered = acmeHosts.filter((h) => {
|
|
if (statusFilter && h.certExpiryStatus !== statusFilter) return false;
|
|
if (search) {
|
|
const q = search.toLowerCase();
|
|
return (
|
|
h.name.toLowerCase().includes(q) ||
|
|
h.domains.some((d) => d.toLowerCase().includes(q))
|
|
);
|
|
}
|
|
return true;
|
|
});
|
|
|
|
const pagination =
|
|
search || statusFilter
|
|
? { total: filtered.length, page: 1, perPage: filtered.length || 1 }
|
|
: acmePagination;
|
|
|
|
return (
|
|
<DataTable
|
|
columns={columns}
|
|
data={filtered}
|
|
keyField="id"
|
|
emptyMessage="No ACME certificates match"
|
|
pagination={pagination}
|
|
mobileCard={acmeMobileCard}
|
|
rowClassName={(r) => r.enabled ? "" : "opacity-75"}
|
|
/>
|
|
);
|
|
}
|