diff --git a/src/components/Kubernetes/NamespaceList.tsx b/src/components/Kubernetes/NamespaceList.tsx index 0a961209..5ad53927 100644 --- a/src/components/Kubernetes/NamespaceList.tsx +++ b/src/components/Kubernetes/NamespaceList.tsx @@ -1,6 +1,9 @@ -import React from "react"; -import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, Badge } from "@/components/ui"; +import React, { useState } from "react"; +import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, Badge, Button } from "@/components/ui"; +import { Pencil } from "lucide-react"; import type { NamespaceResourceInfo } from "@/lib/tauriCommands"; +import { getResourceYamlCmd } from "@/lib/tauriCommands"; +import { EditResourceModal } from "./EditResourceModal"; interface NamespaceListProps { items: NamespaceResourceInfo[]; @@ -14,21 +17,46 @@ function statusVariant(status: string): "success" | "destructive" | "secondary" return "secondary"; } -export function NamespaceList({ items }: NamespaceListProps) { +export function NamespaceList({ items, clusterId }: NamespaceListProps) { + const [editState, setEditState] = useState<{ + open: boolean; + name: string; + yaml: string; + } | null>(null); + const [editError, setEditError] = useState(null); + + const openEdit = async (ns: NamespaceResourceInfo) => { + setEditError(null); + try { + // Namespaces are cluster-scoped — pass empty string for namespace param + const yaml = await getResourceYamlCmd(clusterId, "namespaces", "", ns.name); + setEditState({ open: true, name: ns.name, yaml }); + } catch (err) { + setEditError(err instanceof Error ? err.message : String(err)); + } + }; + return (
+ {editError && ( +
+ {editError} +
+ )} + Name Status Age + Actions {items.length === 0 ? ( - + No namespaces found @@ -40,11 +68,35 @@ export function NamespaceList({ items }: NamespaceListProps) { {ns.status} {ns.age} + + + )) )}
+ + {editState && ( + setEditState(null)} + /> + )}
); }