From 3afa97b517ec29d14dfe04f42319673fb9a6aaf1 Mon Sep 17 00:00:00 2001 From: Shaun Arman Date: Tue, 9 Jun 2026 20:37:57 -0500 Subject: [PATCH] feat(kube): add YAML edit action to NamespaceList Namespaces had a read-only table with no actions. Adds an edit button per row that fetches the namespace YAML via getResourceYamlCmd (cluster-scoped, empty namespace param) and opens EditResourceModal. --- src/components/Kubernetes/NamespaceList.tsx | 60 +++++++++++++++++++-- 1 file changed, 56 insertions(+), 4 deletions(-) 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)} + /> + )}
); }