import { useEffect, useMemo, useState } from "react"; import { Boxes, Info, RefreshCw, Server, ShieldCheck, Tags, } from "lucide-react"; import { EmptyState } from "@/components/EmptyState"; import type { EksCluster, EksNodegroup } from "@/api/aws/eks.api"; import { useEksClustersQuery, useEksNodegroupsQuery, } from "@/api/aws/eks.queries"; function statusClass(status?: string) { const normalized = status?.toLowerCase(); if (normalized === "active") return "healthy"; if (normalized === "creating" || normalized === "updating") return "degraded"; if (normalized === "failed" || normalized === "deleting") return "unavailable"; return "unknown"; } function formatDate(value?: string) { if (!value) return "—"; return new Intl.DateTimeFormat(undefined, { dateStyle: "medium", timeStyle: "short", }).format(new Date(value)); } function yesNo(value?: boolean) { if (value === undefined) return "—"; return value ? "Enabled" : "Disabled"; } function ClusterListItem({ cluster, active, onSelect, }: { cluster: EksCluster; active: boolean; onSelect: () => void; }) { return ( ); } function ClusterSummary({ cluster }: { cluster: EksCluster }) { const vpc = cluster.resourcesVpcConfig; return (

Cluster

Networking

); } function ClusterTags({ tags }: { tags: Record }) { const entries = Object.entries(tags); return (

Tags

{entries.length}
{entries.length === 0 ? (

No tags returned for this cluster.

) : (
{entries.map(([key, value]) => ( {key} {value} ))}
)}
); } function Meta({ label, value }: { label: string; value: string }) { return (
{label} {value}
); } function NodegroupTable({ nodegroups }: { nodegroups: EksNodegroup[] }) { if (nodegroups.length === 0) { return ( ); } return ( {nodegroups.map((nodegroup) => ( ))}
Name Status Capacity Instances Scaling Updated
{nodegroup.name} {nodegroup.status ?? "unknown"} {nodegroup.capacityType ?? "—"} {nodegroup.instanceTypes.join(", ") || "—"} {nodegroup.scalingConfig ? `${nodegroup.scalingConfig.minSize ?? "?"}/${nodegroup.scalingConfig.desiredSize ?? "?"}/${nodegroup.scalingConfig.maxSize ?? "?"}` : "—"} {formatDate(nodegroup.modifiedAt ?? nodegroup.createdAt)}
); } export function EKSPage() { const clustersQuery = useEksClustersQuery(); const clusters = useMemo(() => clustersQuery.data ?? [], [clustersQuery.data]); const [selectedClusterName, setSelectedClusterName] = useState(null); useEffect(() => { if (!selectedClusterName && clusters[0]) { setSelectedClusterName(clusters[0].name); } }, [clusters, selectedClusterName]); const selectedCluster = useMemo( () => clusters.find((cluster) => cluster.name === selectedClusterName) ?? null, [clusters, selectedClusterName], ); const nodegroupsQuery = useEksNodegroupsQuery(selectedClusterName); return ( <>

EKS

Kubernetes clusters
{!selectedCluster ? ( ) : (

{selectedCluster.name}

{selectedCluster.status ?? "unknown"}

Managed nodegroups

{nodegroupsQuery.isLoading ? (

Loading nodegroups...

) : nodegroupsQuery.isError ? ( ) : ( )}
)}
); }