"use client";
import type { ReactNode } from "react";
import { LockKeyhole, Pencil, ShieldCheck } from "lucide-react";
import type { ServerSystemUser } from "@/lib/api";
import type { UserBadgeTone } from "@/app/servers/components/server-config-utils";
export function ConfigInfoRow({
label,
value,
}: {
label: string;
value: string;
}) {
return (
{label}
{value}
);
}
export function UserBadge({
label,
tone,
}: {
label: string;
tone: UserBadgeTone;
}) {
const palette = {
danger: {
color: "#ef4444",
background: "rgba(239,68,68,0.08)",
border: "rgba(239,68,68,0.2)",
},
success: {
color: "#10b981",
background: "rgba(16,185,129,0.08)",
border: "rgba(16,185,129,0.2)",
},
neutral: {
color: "var(--text-secondary)",
background: "var(--bg-input)",
border: "var(--border)",
},
warning: {
color: "#f59e0b",
background: "rgba(245,158,11,0.08)",
border: "rgba(245,158,11,0.2)",
},
info: {
color: "#3b82f6",
background: "rgba(59,130,246,0.08)",
border: "rgba(59,130,246,0.2)",
},
} as const;
const style = palette[tone];
return (
{label}
);
}
export function ServiceStatusBadge({ state }: { state: string }) {
const normalized = state.toLowerCase();
const tone =
normalized === "active"
? "success"
: normalized === "enabled"
? "info"
: normalized === "inactive"
? "danger"
: "warning";
return ;
}
export function ServerUserCard({
user,
canEdit = false,
isEditing = false,
onEdit,
children,
}: {
user: ServerSystemUser;
canEdit?: boolean;
isEditing?: boolean;
onEdit?: () => void;
children?: ReactNode;
}) {
const accountLabel = user.isRoot ? "root" : "non-root";
const accountTone = user.isRoot ? "danger" : "info";
return (
{user.username}
{user.isSshUser ? (
) : null}
UID {user.uid ?? "—"} • GID {user.gid ?? "—"}
{user.isRoot ? (
Protected
) : (
)}
0 ? user.groups.join(", ") : "—"}
/>
{children}
);
}