fix: address PR review findings
Some checks failed
PR Review Automation / review (pull_request) Successful in 2m58s
Test / frontend-typecheck (pull_request) Successful in 1m49s
Test / frontend-tests (pull_request) Successful in 1m43s
Test / rust-fmt-check (pull_request) Has been cancelled
Test / rust-clippy (pull_request) Has been cancelled
Test / rust-tests (pull_request) Has been cancelled

- Add separate onDelete handler for PortForwardList (Stop vs Delete actions)
- Add namespace validation in PortForwardForm (required field)
- Update KubernetesPage to pass onDelete handler to PortForwardList
This commit is contained in:
Shaun Arman 2026-06-06 12:55:23 -05:00
parent f5fb9bd0e2
commit aefe935de5
3 changed files with 26 additions and 4 deletions

View File

@ -41,7 +41,7 @@ export function PortForwardForm({ isOpen, onClose, onStart }: PortForwardFormPro
e.preventDefault(); e.preventDefault();
setError(""); setError("");
if (!clusterId || !pod || !containerPort) { if (!clusterId || !namespace || !pod || !containerPort) {
setError("All fields are required"); setError("All fields are required");
return; return;
} }

View File

@ -7,16 +7,23 @@ import { stopPortForwardCmd } from "@/lib/tauriCommands";
interface PortForwardListProps { interface PortForwardListProps {
portForwards: PortForwardResponse[]; portForwards: PortForwardResponse[];
onStart: () => void; onStart: () => void;
onStop: (session_id: string) => Promise<void>; onStop: (id: string) => Promise<void>;
onDelete: (id: string) => Promise<void>;
} }
export function PortForwardList({ portForwards, onStart, onStop }: PortForwardListProps) { export function PortForwardList({ portForwards, onStart, onStop, onDelete }: PortForwardListProps) {
const handleStop = async (id: string) => { const handleStop = async (id: string) => {
if (window.confirm("Are you sure you want to stop this port forward?")) { if (window.confirm("Are you sure you want to stop this port forward?")) {
await onStop(id); await onStop(id);
} }
}; };
const handleDelete = async (id: string) => {
if (window.confirm("Are you sure you want to delete this port forward? This cannot be undone.")) {
await onDelete(id);
}
};
const getStatusColor = (status: string) => { const getStatusColor = (status: string) => {
switch (status.toLowerCase()) { switch (status.toLowerCase()) {
case "active": case "active":
@ -102,7 +109,7 @@ export function PortForwardList({ portForwards, onStart, onStop }: PortForwardLi
<Button <Button
variant="destructive" variant="destructive"
size="sm" size="sm"
onClick={() => handleStop(pf.id)} onClick={() => handleDelete(pf.id)}
> >
<Trash2 className="w-4 h-4" /> <Trash2 className="w-4 h-4" />
</Button> </Button>

View File

@ -12,6 +12,10 @@ import {
stopPortForwardCmd, stopPortForwardCmd,
} from "@/lib/tauriCommands"; } from "@/lib/tauriCommands";
const deletePortForwardCmd = async (id: string): Promise<void> => {
await stopPortForwardCmd(id);
};
export function KubernetesPage() { export function KubernetesPage() {
const [clusters, setClusters] = useState<ClusterInfo[]>([]); const [clusters, setClusters] = useState<ClusterInfo[]>([]);
const [portForwards, setPortForwards] = useState<PortForwardResponse[]>([]); const [portForwards, setPortForwards] = useState<PortForwardResponse[]>([]);
@ -59,6 +63,16 @@ export function KubernetesPage() {
} }
}; };
const handleDeletePortForward = async (id: string) => {
try {
await stopPortForwardCmd(id);
setPortForwards((prev) => prev.filter((pf) => pf.id !== id));
} catch (err) {
console.error("Failed to delete port forward:", err);
alert("Failed to delete port forward");
}
};
const handleAddCluster = (cluster: ClusterInfo) => { const handleAddCluster = (cluster: ClusterInfo) => {
setClusters((prev) => [...prev, cluster]); setClusters((prev) => [...prev, cluster]);
}; };
@ -98,6 +112,7 @@ export function KubernetesPage() {
portForwards={portForwards} portForwards={portForwards}
onStart={() => setIsStartPortForwardOpen(true)} onStart={() => setIsStartPortForwardOpen(true)}
onStop={handleStopPortForward} onStop={handleStopPortForward}
onDelete={handleDeletePortForward}
/> />
</div> </div>