// deployment-view/helpers.tsx — 时间线 / 信息面板辅助组件 // Logan.Li import { Fragment } from 'react'; import { formatK8sTime, formatDuration, elapsedSeconds, STATUS_COLORS, } from '../k8s-yaml-utils'; import type { PodItem } from './types'; import type { JsonData } from '@/types/common'; export interface PodStage { label: string; ts?: string; color: string; } // Pod 条件时间线提取 // Logan.Li export function getPodTimeline(pod: PodItem) { const cond: JsonData[] = (pod as JsonData).conditions || (pod as JsonData).pod_conditions || []; const find = (t: string) => cond.find((c: JsonData) => (c.type || c.Type) === t); const ts = (c: JsonData) => c?.lastTransitionTime || c?.LastTransitionTime || c?.last_transition_time; return { scheduled: ts(find('PodScheduled') || {}), initialized: ts(find('Initialized') || {}), containersReady: ts(find('ContainersReady') || {}), ready: ts(find('Ready') || {}), startTime: pod.start_time || (pod as JsonData).startTime, }; } // 启动阶段列表(列表/详情共用) // Logan.Li export function getPodStages(pod: PodItem): PodStage[] { const tl = getPodTimeline(pod); return [ { label: '已调度', ts: tl.scheduled, color: STATUS_COLORS.blue }, { label: '已初始化', ts: tl.initialized, color: STATUS_COLORS.orange }, { label: '容器已就绪', ts: tl.containersReady, color: STATUS_COLORS.green }, { label: '容器组已就绪', ts: tl.ready, color: STATUS_COLORS.green }, ]; } // 信息面板单项 // Logan.Li export function InfoItem({ label, value }: { label: string; value: React.ReactNode }) { return (
{label}