// 发布详情弹窗(流水线进度 + 构建日志 + 重新部署) // Logan.Li import { useState } from 'react'; import { cn } from '@/lib/utils'; import { Badge } from '@/components/ui/badge'; import { Button } from '@/components/ui/button'; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '@/components/ui/dialog'; import { Rocket, CheckCircle, Loader2, RotateCcw } from 'lucide-react'; import { releaseApi } from '@/api'; import { toast } from 'sonner'; import { PIPELINE_STEPS } from './releaseHelpers'; import type { JsonData } from '@/types/common'; interface ReleaseDetailDialogProps { release: JsonData | null; open: boolean; onOpenChange: (open: boolean) => void; onSuccess?: () => void; } export function ReleaseDetailDialog({ release, open, onOpenChange, onSuccess }: ReleaseDetailDialogProps) { const [submitting, setSubmitting] = useState(false); // 重新触发部署 // Logan.Li const handleRedeploy = async () => { if (!release) return; try { setSubmitting(true); await releaseApi.deployRelease(release.id); toast.success('已重新触发部署'); onOpenChange(false); onSuccess?.(); } catch { toast.error('重新部署失败'); } finally { setSubmitting(false); } }; return ( {release?.app_name} {release?.version} 环境: {release?.environment}
{/* Pipeline Steps */}

发布进度

{PIPELINE_STEPS.map((step, index) => (
{step.status === 'success' ? ( ) : step.status === 'running' ? ( ) : ( {index + 1} )}
{step.name} {step.duration}
))}
{/* Build Logs */}

构建日志

[10:00:00] Starting pipeline for {release?.app_name}...

[10:00:15] Checkout code from branch {release?.branch}

[10:00:30] Installing dependencies...

[10:01:15] Dependencies installed successfully

[10:01:15] Running code analysis...

[10:01:45] Code analysis passed

[10:01:45] Running unit tests...

[10:04:00] All tests passed (156/156)

[10:04:00] Building Docker image...

[10:07:30] Image built successfully

[10:07:30] Pushing image to registry...

[10:08:50] Image pushed successfully

[10:08:50] Deploying to Kubernetes...

[10:10:00] Deployment in progress...

{release?.status === 'failed' && ( )}
); }