tftsr-devops_investigation/src/components/Kubernetes/ServiceList.tsx
Shaun Arman 8b227c1837
Some checks failed
Test / frontend-tests (pull_request) Successful in 1m26s
Test / frontend-typecheck (pull_request) Successful in 1m35s
PR Review Automation / review (pull_request) Successful in 5m6s
Test / rust-fmt-check (pull_request) Failing after 11m23s
Test / rust-clippy (pull_request) Successful in 13m2s
Test / rust-tests (pull_request) Successful in 14m47s
fix(kube): resolve automated PR review blockers and warnings
Blockers:
- Replace serde_yaml::from_str with serde_json::from_str in all 6
  parse_*_json functions (parse_namespaces, parse_pods, parse_services,
  parse_deployments, parse_statefulsets, parse_daemonsets). Update
  .as_sequence() → .as_array(), .as_mapping() → .as_object(), and
  mapping iterator patterns throughout. Explicitly type serde_yaml::Value
  in extract_context/extract_server_url which legitimately parse YAML.

Warnings:
- Add containers: Vec<String> to PodInfo struct; parse from
  spec.containers[].name in parse_pods_json
- Fix PodList.tsx to use selectedPod.containers instead of [selectedPod.name]
- Fix exec_pod: add optional shell param with allowlist validation
  (sh/bash/ash/dash); correct arg ordering — -c container now placed
  before -- separator
- Handle empty namespace with --all-namespaces in all 5 list commands
- Fix dialog overflow: overflow-hidden → overflow-y-auto on inner div
- Memoize namespace options with useMemo in ResourceBrowser

Lint cleanup (all pre-existing, surfaced by eslint config fix):
- Deduplicate eslint.config.js (was doubled to 272 lines); move ignores
  to standalone global object; allow console.log in cli section
- Remove stale .eslintignore (migrated to eslint.config.js)
- Remove unused Card/CardTitle imports from Kubernetes list components
- Rename unused props to _clusterId/_namespace in DaemonSetList,
  ServiceList, StatefulSetList
- Fix useEffect/useCallback missing deps in Triage and LogUpload
- Remove debug console.log from App.tsx provider auto-test
- Rename unused hover prop to _hover in TableRow (ui/index.tsx)
- Add #[allow(unused_variables)] to Phase 3 stub Tauri commands
- Restore get_pod_logs, scale_deployment, restart_deployment,
  delete_resource, exec_pod to lib.rs handler registration (were
  accidentally dropped in Phase 3 expansion)

All checks pass: cargo clippy -D warnings, tsc --noEmit,
eslint --max-warnings 0, 331 Rust tests, 98 frontend tests.
2026-06-06 23:55:44 -05:00

81 lines
2.7 KiB
TypeScript

import React from "react";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui";
import { Badge } from "@/components/ui";
import type { ServiceInfo } from "@/lib/tauriCommands";
interface ServiceListProps {
services: ServiceInfo[];
clusterId: string;
namespace: string;
}
export function ServiceList({ services, clusterId: _clusterId, namespace: _namespace }: ServiceListProps) {
const getServiceTypeColor = (type: string) => {
switch (type.toLowerCase()) {
case "clusterip":
return "bg-blue-500";
case "nodeport":
return "bg-purple-500";
case "loadbalancer":
return "bg-green-500";
case "externalname":
return "bg-gray-500";
default:
return "bg-gray-500";
}
};
return (
<div className="overflow-x-auto">
<Table>
<TableHeader>
<TableRow>
<TableHead>Name</TableHead>
<TableHead>Type</TableHead>
<TableHead>Cluster IP</TableHead>
<TableHead>External IP</TableHead>
<TableHead>Ports</TableHead>
<TableHead>Age</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{services.length === 0 ? (
<TableRow>
<TableCell colSpan={6} className="text-center text-muted-foreground">
No services found
</TableCell>
</TableRow>
) : (
services.map((service) => (
<TableRow key={`${service.name}-${service.namespace}`}>
<TableCell className="font-medium">{service.name}</TableCell>
<TableCell>
<Badge className={`${getServiceTypeColor(service.type)} text-white`}>
{service.type}
</Badge>
</TableCell>
<TableCell className="font-mono text-sm">{service.cluster_ip}</TableCell>
<TableCell className="font-mono text-sm">
{service.external_ip || "N/A"}
</TableCell>
<TableCell>
<div className="space-y-1">
{service.ports.map((port) => (
<div key={`${port.port}-${port.protocol}`} className="text-sm">
{port.name ? `${port.name}: ` : ""}
{port.port}/{port.protocol}
{port.target_port && `${port.target_port}`}
</div>
))}
</div>
</TableCell>
<TableCell className="text-muted-foreground">{service.age}</TableCell>
</TableRow>
))
)}
</TableBody>
</Table>
</div>
);
}