11import { memo , useCallback , useMemo , useState , type CSSProperties } from "react" ;
2- import { AlertTriangle , Container , ImageOff , RotateCw , ServerCrash , Timer } from "lucide-react" ;
2+ import { AlertTriangle , Container , FileText , ImageOff , RotateCw , ServerCrash , Timer } from "lucide-react" ;
33import type { HealthState , ResourceRow } from "../types/kube" ;
44import { StatusDot } from "./status" ;
55
@@ -10,7 +10,15 @@ type PodTriageBucket = {
1010 tone : Exclude < HealthState , "healthy" | "syncing" > ;
1111} ;
1212
13- export function PodTriageRail ( { pods, onSelect } : { pods : ResourceRow [ ] ; onSelect : ( id : string ) => void } ) {
13+ export function PodTriageRail ( {
14+ onOpenLogs,
15+ onSelect,
16+ pods,
17+ } : {
18+ onOpenLogs : ( id : string ) => void ;
19+ onSelect : ( id : string ) => void ;
20+ pods : ResourceRow [ ] ;
21+ } ) {
1422 const [ activeBucketId , setActiveBucketId ] = useState < PodTriageBucket [ "id" ] | null > ( null ) ;
1523 const buckets = useMemo ( ( ) => podTriageBuckets ( pods ) , [ pods ] ) ;
1624 const activeBucket = buckets . find ( ( bucket ) => bucket . id === activeBucketId && bucket . count > 0 ) ?? null ;
@@ -51,7 +59,7 @@ export function PodTriageRail({ pods, onSelect }: { pods: ResourceRow[]; onSelec
5159 </ div >
5260 < div className = "pod-triage-items" >
5361 { visiblePods . map ( ( pod ) => (
54- < PodTriageButton key = { pod . id } pod = { pod } onSelect = { onSelect } />
62+ < PodTriageButton key = { pod . id } pod = { pod } onOpenLogs = { onOpenLogs } onSelect = { onSelect } />
5563 ) ) }
5664 </ div >
5765 </ div >
@@ -87,26 +95,40 @@ function TriageBucket({
8795}
8896
8997const PodTriageButton = memo ( function PodTriageButton ( {
98+ onOpenLogs,
9099 onSelect,
91100 pod,
92101} : {
102+ onOpenLogs : ( id : string ) => void ;
93103 onSelect : ( id : string ) => void ;
94104 pod : ResourceRow ;
95105} ) {
96106 const handleSelect = useCallback ( ( ) => onSelect ( pod . id ) , [ onSelect , pod . id ] ) ;
107+ const handleOpenLogs = useCallback ( ( ) => onOpenLogs ( pod . id ) , [ onOpenLogs , pod . id ] ) ;
97108 const triageTone = pod . status === "healthy" && pod . restarts > 0 ? "warning" : pod . status ;
98109 const diagnostic = pod . diagnostic || ( pod . restarts > 0 ? `${ pod . restarts } restarts` : pod . status ) ;
99110
100111 return (
101- < button className = { `pod-triage-item ${ triageTone } ` } type = "button" onClick = { handleSelect } >
102- < StatusDot state = { triageTone } />
103- < span >
104- < strong title = { pod . name } > { pod . name } </ strong >
105- < small title = { pod . namespace } > { pod . namespace } </ small >
106- </ span >
107- < em title = { diagnostic } > { diagnostic } </ em >
108- < small > { pod . restarts } r</ small >
109- </ button >
112+ < div className = { `pod-triage-item ${ triageTone } ` } >
113+ < button className = "pod-triage-open" type = "button" onClick = { handleSelect } >
114+ < StatusDot state = { triageTone } />
115+ < span >
116+ < strong title = { pod . name } > { pod . name } </ strong >
117+ < small title = { pod . namespace } > { pod . namespace } </ small >
118+ </ span >
119+ < em title = { diagnostic } > { diagnostic } </ em >
120+ < small > { pod . restarts } r</ small >
121+ </ button >
122+ < button
123+ aria-label = { `Open logs for ${ pod . name } ` }
124+ className = "pod-triage-log"
125+ title = "Open logs"
126+ type = "button"
127+ onClick = { handleOpenLogs }
128+ >
129+ < FileText size = { 13 } />
130+ </ button >
131+ </ div >
110132 ) ;
111133} ) ;
112134
0 commit comments