import CodeBlock from "@/src/components/twui/elements/CodeBlock"; import Tag from "@/src/components/twui/elements/Tag"; import type { FirewallRuleKind, FirewallRuleInfo, } from "@/src/functions/backend/firewall/grab-firewall-status"; import Row from "@/src/components/twui/layout/Row"; import Span from "@/src/components/twui/layout/Span"; import Stack from "@/src/components/twui/layout/Stack"; import type { TWUIButtonColorType } from "@/src/components/twui/layout/Button"; import { ShieldAlert, ShieldCheck, ShieldX, type LucideIcon, } from "lucide-react"; const KIND_META: Record< FirewallRuleKind, { label: string; color: TWUIButtonColorType; icon: LucideIcon; text_class: string; } > = { required: { label: `Active`, color: `success`, icon: ShieldCheck, text_class: `text-success`, }, temporary: { label: `Temporary`, color: `warning`, icon: ShieldAlert, text_class: `text-warning`, }, orphaned: { label: `Orphaned`, color: `error`, icon: ShieldX, text_class: `text-error`, }, other: { label: `Unmanaged`, color: `gray`, icon: ShieldCheck, text_class: `text-foreground-light/45 dark:text-foreground-dark/45`, }, }; type Props = { rule: FirewallRuleInfo; }; export default function FirewallRuleRow({ rule }: Props) { const meta = KIND_META[rule.kind]; const Icon = meta.icon; return ( {rule.description} {meta.label} {rule.delete_command ? ( {`# remove rule\n${rule.delete_command}`} ) : null} ); }