feat: improve UI contrast, dark mode, dialog sizing, color coherence, and add table sorting

- 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>
This commit is contained in:
fuomag9
2026-03-22 22:17:56 +01:00
parent 65753f6a8d
commit 9c60d11c2c
45 changed files with 1616 additions and 1052 deletions

View File

@@ -2,7 +2,7 @@
import { useEffect, useRef, useState } from "react";
import { useRouter, usePathname, useSearchParams } from "next/navigation";
import { MoreHorizontal } from "lucide-react";
import { Globe, MoreHorizontal, ArrowRight, Shield } from "lucide-react";
import type { AccessList } from "@/lib/models/access-lists";
import type { Certificate } from "@/lib/models/certificates";
import type { ProxyHost } from "@/lib/models/proxy-hosts";
@@ -12,6 +12,7 @@ import { toggleProxyHostAction } from "./actions";
import { PageHeader } from "@/components/ui/PageHeader";
import { SearchField } from "@/components/ui/SearchField";
import { DataTable } from "@/components/ui/DataTable";
import { StatusChip } from "@/components/ui/StatusChip";
import { CreateHostDialog, EditHostDialog, DeleteHostDialog } from "@/components/proxy-hosts/HostDialogs";
import { Button } from "@/components/ui/button";
import { Badge } from "@/components/ui/badge";
@@ -33,9 +34,10 @@ type Props = {
authentikDefaults: AuthentikSettings | null;
pagination: { total: number; page: number; perPage: number };
initialSearch: string;
initialSort?: { sortBy: string; sortDir: "asc" | "desc" };
};
export default function ProxyHostsClient({ hosts, certificates, accessLists, caCertificates, authentikDefaults, pagination, initialSearch }: Props) {
export default function ProxyHostsClient({ hosts, certificates, accessLists, caCertificates, authentikDefaults, pagination, initialSearch, initialSort }: Props) {
const [createOpen, setCreateOpen] = useState(false);
const [duplicateHost, setDuplicateHost] = useState<ProxyHost | null>(null);
const [editHost, setEditHost] = useState<ProxyHost | null>(null);
@@ -73,33 +75,72 @@ export default function ProxyHostsClient({ hosts, certificates, accessLists, caC
const columns = [
{
id: "name",
label: "Name",
label: "Name / Domain",
sortKey: "name",
render: (host: ProxyHost) => (
<div>
<p className="text-sm font-medium">{host.name}</p>
<p className="text-xs text-muted-foreground font-mono">
{host.domains[0]}{host.domains.length > 1 && ` +${host.domains.length - 1}`}
</p>
<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",
host.enabled
? "border-emerald-500/30 bg-emerald-500/10 text-emerald-500"
: "border-zinc-500/20 bg-zinc-500/10 text-zinc-400"
].join(" ")}>
<Globe className="h-3.5 w-3.5" />
</div>
<div>
<p className="text-sm font-semibold leading-tight">{host.name}</p>
<p className="text-xs text-muted-foreground font-mono mt-0.5">
{host.domains[0]}
{host.domains.length > 1 && (
<span className="ml-1 text-muted-foreground">+{host.domains.length - 1}</span>
)}
</p>
</div>
</div>
),
},
{
id: "target",
label: "Target",
label: "Upstream",
sortKey: "upstreams",
render: (host: ProxyHost) => (
<p className="text-sm text-muted-foreground font-mono">
{host.upstreams[0]}{host.upstreams.length > 1 && ` +${host.upstreams.length - 1} more`}
</p>
<div className="flex items-center gap-1.5">
<ArrowRight className="h-3 w-3 shrink-0 text-muted-foreground" />
<span className="text-sm font-mono font-medium text-foreground/80">
{host.upstreams[0]}
{host.upstreams.length > 1 && (
<span className="ml-1 text-muted-foreground">+{host.upstreams.length - 1}</span>
)}
</span>
</div>
),
},
{
id: "features",
label: "Features",
render: (host: ProxyHost) => (
<div className="flex flex-wrap gap-1">
{host.certificate_id && (
<Badge variant="info" className="text-[10px] px-1.5 py-0">TLS</Badge>
)}
{host.access_list_id && (
<Badge variant="warning" className="text-[10px] px-1.5 py-0">
<Shield className="h-2.5 w-2.5 mr-0.5" />Auth
</Badge>
)}
{!host.certificate_id && !host.access_list_id && (
<span className="text-xs text-muted-foreground"></span>
)}
</div>
),
},
{
id: "status",
label: "Status",
width: 100,
sortKey: "enabled",
width: 110,
render: (host: ProxyHost) => (
<Badge variant={host.enabled ? "default" : "secondary"}>
{host.enabled ? "Active" : "Paused"}
</Badge>
<StatusChip status={host.enabled ? "active" : "inactive"} />
),
},
{
@@ -138,17 +179,23 @@ export default function ProxyHostsClient({ hosts, certificates, accessLists, caC
];
const mobileCard = (host: ProxyHost) => (
<Card>
<Card className={[
"border-l-2",
host.enabled ? "border-l-emerald-500" : "border-l-zinc-500/30",
].join(" ")}>
<CardContent className="p-4">
<div className="flex items-start justify-between gap-2">
<div className="flex flex-col gap-1 min-w-0">
<p className="text-sm font-medium truncate">{host.name}</p>
<p className="text-sm font-semibold truncate">{host.name}</p>
<p className="text-xs text-muted-foreground font-mono truncate">
{host.domains[0]}{host.domains.length > 1 ? ` +${host.domains.length - 1}` : ""} {host.upstreams[0]}
{host.domains[0]}{host.domains.length > 1 ? ` +${host.domains.length - 1}` : ""}
<span className="mx-1 text-muted-foreground"></span>
{host.upstreams[0]}
</p>
<Badge variant={host.enabled ? "default" : "secondary"} className="w-fit mt-1">
{host.enabled ? "Active" : "Paused"}
</Badge>
<div className="flex items-center gap-1.5 mt-1">
<StatusChip status={host.enabled ? "active" : "inactive"} />
{host.certificate_id && <Badge variant="info" className="text-[10px] px-1.5 py-0">TLS</Badge>}
</div>
</div>
<div className="flex items-center gap-1 shrink-0">
<Switch
@@ -159,6 +206,7 @@ export default function ProxyHostsClient({ hosts, certificates, accessLists, caC
<DropdownMenuTrigger asChild>
<Button variant="ghost" size="icon" className="h-8 w-8">
<MoreHorizontal className="h-4 w-4" />
<span className="sr-only">Open menu</span>
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
@@ -196,7 +244,9 @@ export default function ProxyHostsClient({ hosts, certificates, accessLists, caC
keyField="id"
emptyMessage={searchTerm ? "No hosts match your search" : "No proxy hosts found"}
pagination={pagination}
sort={initialSort}
mobileCard={mobileCard}
rowClassName={(host) => host.enabled ? "" : "opacity-75"}
/>
<CreateHostDialog