P1: - utils/storage.ts、theme.ts、validate.ts + index 统一出口 - request/store/useTheme 接入 storage;清零 confirm/alert - PipelineManager、TerminalAuditTab 拆分子模块(<700行红线) P2: - api/monitor、api/deploy 子目录化 - hooks/api 扩展:servers/pipelines/alerts/audit/sessionCommands - PipelineManager、AuditOperationsTab 接入 TanStack Query
2 lines
67 KiB
JavaScript
2 lines
67 KiB
JavaScript
import{i as Me,ac as Ge,j as e,L as H,Q as ae,V as U,w as le,au as Y,av as Ee,r as o,B as v,D as Be,a as Le,b as Te,c as Fe,C as Z,t as N,m as We,N as he,S as ye,G as ue,W as Oe,o as de,f as Qe}from"./index-HuRw9UhJ.js";import{I as f}from"./input-C9Xfv8um.js";import{p as T}from"./pipeline-CRmSOJEC.js";import{u as Je,q as Ie,a as Ke}from"./unwrap-s5xDIyKq.js";import{u as ce}from"./useMutation-ChnF9A9K.js";import{C as He,a as Ue}from"./card-B2Wqa0sK.js";import{B as D}from"./badge-CeS-g-Od.js";import{C as ee}from"./circle-x-BVvXVx7p.js";import{B as Xe}from"./box-DPoVh2_c.js";import{C as me}from"./circle-stop-CNrDSTTb.js";import{F as _e}from"./file-text-BqORyhNh.js";import{A as K}from"./arrow-right-C1YbOgFu.js";import{P as Ye}from"./play-BXdOitsb.js";import{H as Ze}from"./history-CLAzTAyT.js";import{T as $e}from"./trash-2-Cf9-88KL.js";import{T as ea}from"./textarea-Bzol9o6k.js";import{L as h}from"./label-DvRDtaMA.js";import{S as se,a as te,b as oe,c as re,d as L}from"./select-KDzbUQs3.js";import{d as aa}from"./config-J-uY34Cv.js";import{c as na}from"./credential-snjgV65G.js";import{T as sa}from"./tag-DcJS0iSd.js";import{P as xe}from"./plus-BVwIGPvl.js";import{S as ta}from"./search-CcKEpJIn.js";import{L as oa}from"./layers-DZGQE4Gb.js";import{C as ra}from"./code-CQ7c-p8-.js";import"./index-DwvHXNyF.js";import"./chevron-up-GXrRy2ul.js";const ia=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],la=Me("package",ia);const pa=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]],ca=Me("workflow",pa);function da(n={page:1,page_size:100}){return Je({queryKey:Ie.pipelines(n),queryFn:async()=>{const p=await T.getPipelines(n);return Ke(p)},staleTime:2e4})}function ma(){const n=Ge(),p=()=>n.invalidateQueries({queryKey:["pipelines"]}),P=ce({mutationFn:d=>T.triggerByCode(d),onSuccess:p}),b=ce({mutationFn:d=>T.deletePipeline(d),onSuccess:p}),j=ce({mutationFn:({code:d,runId:y})=>T.stopRunByCode(d,y)});return{triggerMutation:P,deleteMutation:b,stopRunMutation:j,invalidate:p}}function xa(n){return n.toLowerCase().replace(/[^a-z0-9]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")||`pipeline-${Date.now()}`}function ga(n){switch(n){case"success":return e.jsxs(D,{"code-path":"src/components/deploy/pipeline-helpers.tsx:49:9",variant:"outline",className:"border-emerald-500/30 text-emerald-400 bg-emerald-500/10",children:[e.jsx(ae,{"code-path":"src/components/deploy/pipeline-helpers.tsx:50:11",className:"h-3 w-3 mr-1"}),"成功"]});case"failed":return e.jsxs(D,{"code-path":"src/components/deploy/pipeline-helpers.tsx:56:9",variant:"outline",className:"border-red-500/30 text-red-400 bg-red-500/10",children:[e.jsx(ee,{"code-path":"src/components/deploy/pipeline-helpers.tsx:57:11",className:"h-3 w-3 mr-1"}),"失败"]});case"running":return e.jsxs(D,{"code-path":"src/components/deploy/pipeline-helpers.tsx:63:9",variant:"outline",className:"border-blue-500/30 text-blue-400 bg-blue-500/10 animate-pulse",children:[e.jsx(H,{"code-path":"src/components/deploy/pipeline-helpers.tsx:64:11",className:"h-3 w-3 mr-1 animate-spin"}),"运行中"]});default:return e.jsx(D,{"code-path":"src/components/deploy/pipeline-helpers.tsx:70:9",variant:"outline",className:"border-[var(--dg-border)] text-[var(--dg-text-secondary)]",children:"从未运行"})}}const ie=[{key:"checkout",label:"代码检出",icon:U,color:"#6366F1",order:1,needs:["repo"],desc:"从 Git 仓库拉取代码"},{key:"build",label:"构建",icon:Xe,color:"#F59E0B",order:2,needs:[],desc:"编译/打包项目"},{key:"test",label:"测试",icon:ae,color:"#10B981",order:3,needs:[],desc:"运行单元/集成测试"},{key:"image",label:"镜像打包",icon:le,color:"#06B6D4",order:4,needs:["registry"],desc:"Docker 构建 & 推送"},{key:"deploy",label:"部署",icon:Y,color:"#EF4444",order:5,needs:[],desc:"部署到目标环境"},{key:"verify",label:"验证",icon:Ee,color:"#3B82F6",order:6,needs:[],desc:"部署后健康检查"}].sort((n,p)=>n.order-p.order);function ge(n){if(!n)return"-";if(n<60)return`${n}s`;const p=Math.floor(n/60),P=n%60;return P>0?`${p}分${P}秒`:`${p}分`}function ha(n){if(!n)return[];try{const p=typeof n=="string"?JSON.parse(n):n;return Array.isArray(p)?p:[]}catch{return[]}}function ya({pipeline:n}){const[p,P]=o.useState(null),[b,j]=o.useState(!1),d=n.code||n.id,y=async()=>{if(d){j(!0);try{const l=await T.getQueue(d);P(l?.data||l)}catch{P(null)}finally{j(!1)}}};o.useEffect(()=>{y();const l=setInterval(y,1e4);return()=>clearInterval(l)},[d]);const M=async l=>{try{await T.removeFromQueue(d,l),N.success("已取消"),y()}catch{N.error("取消失败")}},w=p?.running||0,u=p?.queued||0,C=p?.queue_ids||[],R=n.max_executors||2,t=p?.pending_runs||[];return b&&!p||w===0&&u===0?null:e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:69:5",className:"px-4 py-2 space-y-2",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:70:7",className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:71:9",className:"text-[var(--dg-text-secondary)]",children:"构建执行状态"}),e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:72:9",className:"font-bold text-[var(--dg-text-primary)]",children:[w,"/",R]}),u>0&&e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:74:11",className:"text-[var(--dg-text-secondary)] ml-2",children:["构建队列 ",e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:75:18",className:"font-bold text-amber-400",children:["(",u,")"]})]})]}),u>0&&t.length>0&&e.jsx("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:81:9",className:"space-y-1",children:t.map(l=>e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:83:13",className:"flex items-center justify-between bg-[var(--dg-bg-tertiary)] rounded px-3 py-1.5",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:84:15",className:"flex items-center gap-2 text-xs",children:[e.jsx(Z,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:85:17",className:"h-3 w-3 text-amber-400"}),e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:86:17",className:"text-[var(--dg-text-secondary)] font-mono",children:["#",String(l.build_number??l.id??"")]}),e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:87:17",className:"text-[var(--dg-text-secondary)]",children:String(l.branch||"-")}),e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:88:17",className:"text-[var(--dg-text-secondary)] opacity-50",children:String(l.triggered_by||"-")})]}),e.jsxs(v,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:90:15",variant:"ghost",size:"sm",className:"h-6 text-xs text-red-400 hover:text-red-300",onClick:()=>M(l.id),children:[e.jsx(ee,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:91:17",className:"h-3 w-3 mr-1"}),"取消"]})]},l.id))}),u>0&&t.length===0&&C.length>0&&e.jsx("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:99:9",className:"space-y-1",children:C.map(l=>e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:101:13",className:"flex items-center justify-between bg-[var(--dg-bg-tertiary)] rounded px-3 py-1.5",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:102:15",className:"flex items-center gap-2 text-xs",children:[e.jsx(Z,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:103:17",className:"h-3 w-3 text-amber-400"}),e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:104:17",className:"text-[var(--dg-text-muted)] font-mono",children:["Run #",l]})]}),e.jsxs(v,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:106:15",variant:"ghost",size:"sm",className:"h-6 text-xs text-red-400 hover:text-red-300",onClick:()=>M(l),children:[e.jsx(ee,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:107:17",className:"h-3 w-3 mr-1"}),"取消"]})]},l))})]})}function ua({pipeline:n,pipelineRuns:p,isLoadingRuns:P,onStopRun:b}){const[j,d]=o.useState(!1),[y,M]=o.useState(null),[w,u]=o.useState([]),C=n.code||n.id,R=async t=>{M(t),d(!0);try{const l=await T.getRunLog(C,t.id);u(l?.logs||[])}catch{u([])}};return e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:136:5",className:"border-t border-[var(--dg-border)]",children:[e.jsx(ya,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:137:7",pipeline:n}),P?e.jsx("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:140:9",className:"flex items-center justify-center py-6",children:e.jsx(H,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:141:11",className:"h-5 w-5 animate-spin text-[var(--dg-text-secondary)]"})}):p.length===0?e.jsx("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:144:9",className:"py-6 text-center text-[var(--dg-text-secondary)] text-sm",children:"暂无执行记录"}):e.jsxs("table",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:146:9",className:"w-full text-sm",children:[e.jsx("thead",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:147:11",className:"border-b border-[var(--dg-border)]",children:e.jsxs("tr",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:148:13",className:"bg-[var(--dg-bg-tertiary)]",children:[e.jsx("th",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:149:15",className:"px-4 py-2 text-left text-xs font-medium text-[var(--dg-text-secondary)]",children:"#"}),e.jsx("th",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:150:15",className:"px-4 py-2 text-left text-xs font-medium text-[var(--dg-text-secondary)]",children:"状态"}),e.jsx("th",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:151:15",className:"px-4 py-2 text-left text-xs font-medium text-[var(--dg-text-secondary)]",children:"触发人"}),e.jsx("th",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:152:15",className:"px-4 py-2 text-left text-xs font-medium text-[var(--dg-text-secondary)]",children:"耗时"}),e.jsx("th",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:153:15",className:"px-4 py-2 text-left text-xs font-medium text-[var(--dg-text-secondary)]",children:"时间"}),e.jsx("th",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:154:15",className:"px-4 py-2 text-right text-xs font-medium text-[var(--dg-text-secondary)]",children:"操作"})]})}),e.jsx("tbody",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:157:11",children:p.map(t=>e.jsxs("tr",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:159:15",className:"border-b border-[var(--dg-border)] hover:bg-[var(--dg-bg-tertiary)]/50",children:[e.jsxs("td",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:160:17",className:"px-4 py-2 font-medium text-[var(--dg-text-primary)]",children:["#",String(t.build_number??t.id??"")]}),e.jsx("td",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:161:17",className:"px-4 py-2",children:t.status==="success"?e.jsxs(D,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:163:21",className:"bg-emerald-500/20 text-emerald-400 border-emerald-500/30 text-[11px]",children:[e.jsx(ae,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:164:23",className:"h-3 w-3 mr-0.5"}),"成功"]}):t.status==="failed"?e.jsxs(D,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:167:21",className:"bg-red-500/20 text-red-400 border-red-500/30 text-[11px]",children:[e.jsx(ee,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:168:23",className:"h-3 w-3 mr-0.5"}),"失败"]}):t.status==="running"?e.jsxs(D,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:171:21",className:"bg-blue-500/20 text-blue-400 border-blue-500/30 text-[11px]",children:[e.jsx(H,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:172:23",className:"h-3 w-3 animate-spin mr-0.5"}),"执行中"]}):t.status==="cancelled"?e.jsxs(D,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:175:21",className:"bg-yellow-500/20 text-yellow-400 border-yellow-500/30 text-[11px]",children:[e.jsx(me,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:176:23",className:"h-3 w-3 mr-0.5"}),"已停止"]}):e.jsx(D,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:179:21",variant:"secondary",className:"text-[11px]",children:String(t.status)})}),e.jsx("td",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:182:17",className:"px-4 py-2 text-[var(--dg-text-secondary)] text-xs",children:String(t.triggered_by||"admin")}),e.jsx("td",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:183:17",className:"px-4 py-2 text-[var(--dg-text-secondary)] text-xs",children:ge(t.duration)}),e.jsx("td",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:184:17",className:"px-4 py-2 text-[var(--dg-text-secondary)] text-xs",children:t.created_at?new Date(t.created_at).toLocaleString("zh-CN"):"-"}),e.jsx("td",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:187:17",className:"px-4 py-2 text-right",children:e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:188:19",className:"flex items-center justify-end gap-1",children:[e.jsxs(v,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:189:21",variant:"ghost",size:"sm",className:"h-7 text-xs text-blue-400 hover:text-blue-300",onClick:()=>R(t),children:[e.jsx(_e,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:190:23",className:"h-3.5 w-3.5 mr-1"}),"日志"]}),(t.status==="running"||t.status==="pending")&&e.jsxs(v,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:193:23",variant:"ghost",size:"sm",className:"h-7 text-xs text-red-400 hover:text-red-300",onClick:()=>b(t.id),children:[e.jsx(me,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:194:25",className:"h-3.5 w-3.5 mr-1"}),"停止"]})]})})]},t.id))})]}),e.jsx(Be,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:205:7",open:j,onOpenChange:d,children:e.jsxs(Le,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:206:9",className:"max-w-3xl max-h-[85vh] overflow-y-auto bg-[var(--dg-bg-primary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]",children:[e.jsx(Te,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:207:11",children:e.jsxs(Fe,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:208:13",className:"flex items-center gap-2",children:[e.jsx(_e,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:209:15",className:"h-5 w-5"}),"执行日志 #",String(y?.build_number??y?.id??"")]})}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:212:11",className:"space-y-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:213:13",className:"flex flex-wrap gap-3 text-sm text-[var(--dg-text-secondary)]",children:[e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:214:15",children:["触发方式: ",String(y?.triggered_by||"manual")]}),e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:215:15",children:["分支: ",String(y?.branch||"-")]}),e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:216:15",children:["耗时: ",ge(y?.duration)]})]}),e.jsx("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:218:13",className:"bg-slate-950 rounded-md p-3 max-h-[50vh] overflow-y-auto font-mono text-xs",children:w.length===0?e.jsx("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:220:17",className:"text-slate-500 py-4 text-center",children:"暂无日志"}):w.map((t,l)=>e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:223:19",className:"flex gap-2 py-0.5",children:[e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:224:21",className:"text-slate-500 shrink-0",children:["[",t.time,"]"]}),e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:225:21",className:t.level==="error"?"text-red-400":t.level==="warn"?"text-yellow-400":t.level==="success"?"text-green-400":"text-slate-300",children:[t.level==="success"?"✓":t.level==="error"?"✗":t.level==="warn"?"!":">"," ",t.message]})]},l))})]})]})})]})}function Pa({pipeline:n,isExpanded:p,isLoadingRuns:P,pipelineRuns:b,onToggleExpand:j,onTrigger:d,onStopRunning:y,onDelete:M,onStopRun:w}){const u=We(),C=ha(n.stages),R=n.repo,t=n.registry,l=n.environment,z=n.code||n.id;return e.jsx(He,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:61:5",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] overflow-hidden",children:e.jsxs(Ue,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:62:7",className:"p-0",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:63:9",className:"px-4 py-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:64:11",className:"flex items-start justify-between",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:65:13",className:"flex-1 min-w-0",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:66:15",className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h3",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:67:17",className:"font-semibold text-[var(--dg-text-primary)]",children:String(n.name)}),n.run_count>0&&e.jsxs(D,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:69:19",variant:"outline",className:"text-[11px] text-[var(--dg-text-secondary)] border-[var(--dg-border)]",children:["#",String(n.run_count)]}),ga(n.last_status),l&&e.jsx(D,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:75:19",style:{backgroundColor:`${l.color}20`,color:l.color},className:"text-xs",children:String(l.display_name)}),n.job_name&&e.jsx(D,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:83:19",variant:"secondary",className:"text-xs font-mono opacity-60",children:String(n.job_name)})]}),e.jsx("p",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:86:15",className:"text-xs text-[var(--dg-text-secondary)] mt-1 line-clamp-1",children:String(n.description||"暂无描述")}),(n.last_run_branch||n.last_commit_id||n.last_image_tag)&&e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:91:17",className:"flex items-center gap-1 mt-1.5 text-xs font-mono",children:[n.last_run_branch&&e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:93:21",className:"flex items-center gap-0.5 text-indigo-400",children:[e.jsx(U,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:94:23",className:"h-3 w-3"}),String(n.last_run_branch)]}),n.last_run_branch&&n.last_commit_id&&e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:98:21",className:"text-[var(--dg-text-secondary)] opacity-50 text-[10px] mx-0.5",children:"+"}),n.last_commit_id&&e.jsx("code",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:101:21",className:"text-amber-400 bg-amber-400/10 px-1 py-0.5 rounded text-[11px]",children:String(n.last_commit_id).slice(0,8)}),(n.last_run_branch||n.last_commit_id)&&n.last_image_tag&&e.jsx(K,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:106:21",className:"h-3 w-3 text-[var(--dg-text-secondary)] opacity-40 mx-0.5"}),n.last_image_tag&&e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:109:21",className:"flex items-center gap-0.5 text-cyan-400",children:[e.jsx(la,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:110:23",className:"h-3 w-3"}),e.jsx("code",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:111:23",className:"bg-cyan-400/10 px-1 py-0.5 rounded text-[11px]",children:String(n.last_image_tag)})]}),n.last_duration>0&&e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:115:21",className:"flex items-center gap-0.5 ml-auto text-[var(--dg-text-secondary)] opacity-50",children:[e.jsx(Z,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:116:23",className:"h-3 w-3"}),ge(n.last_duration)]})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:121:15",className:"flex items-center gap-3 mt-1.5 text-xs text-[var(--dg-text-secondary)] opacity-60",children:[e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:122:17",className:"flex items-center gap-1",children:[e.jsx(U,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:123:19",className:"h-3 w-3"}),n.deploy_mode==="tag"?"Tag发版":String(n.branch||"main")]}),e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:126:17",className:"flex items-center gap-1",children:(n.deploy_target||"ssh")==="k8s"?e.jsxs(e.Fragment,{children:[e.jsx(he,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:128:23",className:"h-3 w-3"}),"Kubernetes"]}):e.jsxs(e.Fragment,{children:[e.jsx(ye,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:130:23",className:"h-3 w-3"}),"SSH 主机"]})}),R&&e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:133:26",className:"flex items-center gap-1",children:[e.jsx(ue,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:133:68",className:"h-3 w-3"}),String(R.name)]}),t&&e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:134:30",className:"flex items-center gap-1",children:[e.jsx(le,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:134:72",className:"h-3 w-3"}),String(t.name)]}),n.last_run_at&&e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:136:19",children:[e.jsx(Z,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:136:25",className:"h-3 w-3 inline mr-0.5"}),new Date(n.last_run_at).toLocaleString("zh-CN")]})]})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:140:13",className:"flex items-center gap-1 ml-4 shrink-0",children:[n.last_status==="running"?e.jsxs(v,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:142:17",variant:"destructive",size:"sm",className:"h-8",onClick:y,children:[e.jsx(me,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:143:19",className:"h-3.5 w-3.5 mr-1"}),"停止"]}):e.jsxs(v,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:146:17",variant:"default",size:"sm",className:"h-8",onClick:d,children:[e.jsx(Ye,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:147:19",className:"h-3.5 w-3.5 mr-1"}),"执行"]}),e.jsx(v,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:150:15",variant:"outline",size:"sm",className:"h-8",onClick:()=>u(`/pipelines/${z}`),children:"编辑"}),e.jsxs(v,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:151:15",variant:"outline",size:"sm",className:"h-8",onClick:()=>u(`/pipelines/${z}/runs`),children:[e.jsx(Ze,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:152:17",className:"h-3.5 w-3.5 mr-1"}),"记录"]}),e.jsx(v,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:154:15",variant:"ghost",size:"sm",className:"h-8",onClick:j,children:p?e.jsx(Oe,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:155:31",className:"h-4 w-4"}):e.jsx(de,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:155:69",className:"h-4 w-4"})}),e.jsx(v,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:157:15",variant:"ghost",size:"icon",className:"h-8 w-8 text-red-500",onClick:M,children:e.jsx($e,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:158:17",className:"h-4 w-4"})})]})]}),C.length>0&&e.jsx("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:164:13",className:"flex items-center mt-2.5",children:C.map((g,E)=>{const W=ie.find(A=>A.label===g.name);let _="";if(n.last_run_stages)try{const A=typeof n.last_run_stages=="string"?JSON.parse(n.last_run_stages):n.last_run_stages,X=Array.isArray(A)?A.find(J=>J.name===g.name||J.type===W?.key):null;_=String(X?.status||"")}catch{}const F=_==="success"||_==="completed",V=_==="running"||_==="in_progress",q=_==="failed"||_==="error",$=q?"#EF4444":V?"#3B82F6":F?"#10B981":"#6B7280",O=q?"#EF444428":V?"#3B82F628":F?"#10B98128":"#6B728018",Q=q?e.jsx(ee,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:186:19",className:"h-3 w-3"}):V?e.jsx(H,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:188:19",className:"h-3 w-3 animate-spin"}):F?e.jsx(ae,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:190:19",className:"h-3 w-3"}):e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:192:19",className:"text-[10px] opacity-40",children:"○"});return e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:195:19",className:"flex items-center",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:196:21",className:"flex items-center gap-1.5 px-2.5 py-1.5 text-[11px] font-semibold border shadow-sm",style:{backgroundColor:O,borderColor:`${$}70`,color:$,borderRadius:E===0?"8px 0 0 8px":E===C.length-1?"0 8px 8px 0":"0"},children:[Q,String(g.name)]}),E<C.length-1&&e.jsx("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:208:23",className:"flex items-center justify-center w-5 h-5 -mx-px z-10",children:e.jsx(de,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:209:25",className:"h-3.5 w-3.5",style:{color:`${$}CC`}})})]},E)})})]}),p&&e.jsx(ua,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:220:11",pipeline:n,pipelineRuns:b,isLoadingRuns:P,onStopRun:w})]})})}function va({open:n,onOpenChange:p,onCreated:P}){const[b,j]=o.useState(""),[d,y]=o.useState(""),[M,w]=o.useState(""),[u,C]=o.useState(""),[R,t]=o.useState("main"),[l,z]=o.useState(""),[g,E]=o.useState(["checkout","build","image","deploy"]),[W,_]=o.useState("branch"),[F,V]=o.useState("ssh"),[q,$]=o.useState(""),[O,Q]=o.useState(!1),[A,X]=o.useState([]),[J,ne]=o.useState([]),[s,r]=o.useState(""),[i,B]=o.useState(""),[k,S]=o.useState("manual"),[Pe,ve]=o.useState(""),[je,be]=o.useState(""),[Ne,pe]=o.useState(""),[Ce,fe]=o.useState(""),[G,I]=o.useState([]),[De,we]=o.useState(""),[ke,Se]=o.useState(2),[Ae,ze]=o.useState([]),Re=o.useCallback(async()=>{try{const[a,c]=await Promise.all([aa.getEnvironments().catch(()=>({list:[]})),na.list({page_size:100}).catch(()=>({list:[]}))]);ze(Array.isArray(a?.list)?a.list:[]);const x=c?.list||[];X(x.filter(m=>m.secret_type==="api")),ne(x.filter(m=>m.secret_type==="docker"))}catch{}},[]);o.useEffect(()=>{n&&Re()},[n,Re]);const Ve=()=>{j(""),y(""),w(""),C(""),t("main"),z(""),E(["checkout","build","image","deploy"]),_("branch"),V("ssh"),$(""),r(""),B(""),S("manual"),ve(""),be(""),pe(""),fe(""),I([]),we(""),Se(2)},qe=async()=>{if(!b.trim()){N.error("请输入流水线名称");return}if(g.includes("checkout")&&!u.trim()){N.error("代码检出阶段需要填写 Git URL");return}if(g.includes("image")&&!i){N.error("镜像打包阶段需要关联 Docker 凭证");return}Q(!0);try{const a=g.map(x=>ie.find(m=>m.key===x)?.label||x),c=JSON.stringify(a.map((x,m)=>({id:`stage-${m+1}`,name:x,type:g[m]||"custom",tasks:[]})));await T.createPipeline({name:b,code:xa(b),job_name:d||void 0,description:M,source:u,branch:R,dockerfile:l,type:"deploy",stages:c,deploy_mode:W,deploy_target:F,environment_id:q?Number(q):null,repo_id:null,registry_id:null,git_credential_id:s?Number(s):null,registry_credential_id:i?Number(i):null,trigger_mode:k,watch_branches:Pe||void 0,exclude_branch:je||void 0,cron_expr:Ne||void 0,webhook_token:Ce||void 0,variables:G.length>0?JSON.stringify(G):void 0,cache_paths:De||void 0,max_executors:ke}),N.success("流水线已创建"),p(!1),Ve(),P()}catch{N.error("创建失败")}finally{Q(!1)}};return e.jsx(Be,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:153:5",open:n,onOpenChange:p,children:e.jsxs(Le,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:154:7",className:"max-w-2xl max-h-[85vh] overflow-y-auto bg-[var(--dg-bg-primary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]",children:[e.jsx(Te,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:155:9",children:e.jsxs(Fe,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:156:11",className:"flex items-center gap-2",children:[e.jsx(Y,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:156:60",className:"h-5 w-5"}),"新建流水线"]})}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:158:9",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:159:11",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:160:13",className:"space-y-1",children:[e.jsxs(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:161:15",children:["名称 ",e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:161:25",className:"text-red-400",children:"*"})]}),e.jsx(f,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:162:15",value:b,onChange:a=>j(a.target.value),placeholder:"例如: demo-jar 后端部署",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] h-9"})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:164:13",className:"space-y-1",children:[e.jsxs(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:165:15",children:["Job 名称 ",e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:165:29",className:"text-xs text-[var(--dg-text-secondary)]",children:"(Webhook URL)"})]}),e.jsx(f,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:166:15",value:d,onChange:a=>y(a.target.value),placeholder:"cex-admin-server",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] h-9 font-mono text-sm"}),d&&e.jsxs("p",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:167:30",className:"text-[10px] text-[var(--dg-text-secondary)] opacity-60",children:["Webhook: POST .../webhook/job/",e.jsx("b",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:167:130",children:d})]})]})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:170:11",className:"space-y-1",children:[e.jsx(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:171:13",children:"描述"}),e.jsx(ea,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:172:13",value:M,onChange:a=>w(a.target.value),placeholder:"流水线描述...",rows:2,className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]"})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:175:11",className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:176:13",className:"space-y-1",children:[e.jsx(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:177:15",children:"部署模式"}),e.jsx("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:178:15",className:"flex gap-1 bg-[var(--dg-bg-secondary)] rounded-lg p-1 border border-[var(--dg-border)]",children:[{key:"branch",label:"分支",icon:U},{key:"tag",label:"Tag 发版",icon:sa}].map(a=>{const c=W===a.key;return e.jsxs("button",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:185:21",onClick:()=>_(a.key),className:`flex-1 flex items-center justify-center gap-1 px-2 py-1.5 rounded-md text-xs font-medium transition-all ${c?"bg-blue-500 text-white":"text-[var(--dg-text-secondary)] hover:text-[var(--dg-text-primary)]"}`,children:[e.jsx(a.icon,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:192:23",className:"h-3.5 w-3.5"}),a.label]},a.key)})})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:198:13",className:"space-y-1",children:[e.jsx(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:199:15",children:"部署目标"}),e.jsx("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:200:15",className:"flex gap-1 bg-[var(--dg-bg-secondary)] rounded-lg p-1 border border-[var(--dg-border)]",children:[{key:"ssh",label:"SSH 主机",icon:ye},{key:"k8s",label:"Kubernetes 集群",icon:he}].map(a=>{const c=F===a.key;return e.jsxs("button",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:207:21",onClick:()=>V(a.key),className:`flex-1 flex items-center justify-center gap-1 px-2 py-1.5 rounded-md text-xs font-medium transition-all ${c?"bg-green-500 text-white":"text-[var(--dg-text-secondary)] hover:text-[var(--dg-text-primary)]"}`,children:[e.jsx(a.icon,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:214:23",className:"h-3.5 w-3.5"}),a.label]},a.key)})})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:220:13",className:"space-y-1",children:[e.jsx(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:221:15",children:"环境分组"}),e.jsxs(se,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:222:15",value:String(q),onValueChange:a=>$(a==="__none"?"":a),children:[e.jsx(te,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:223:17",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] h-9",children:e.jsx(oe,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:223:102",placeholder:"选择环境"})}),e.jsxs(re,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:224:17",children:[e.jsx(L,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:225:19",value:"__none",children:"不指定"}),Ae.map(a=>e.jsx(L,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:227:21",value:String(a.id),children:e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:228:23",className:"flex items-center gap-1.5",children:[e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:229:25",className:"w-2 h-2 rounded-full inline-block",style:{backgroundColor:a.color}}),String(a.display_name)]})},a.id))]})]})]})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:239:11",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:240:13",className:"space-y-1",children:[e.jsxs(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:241:15",children:["Git URL ",g.includes("checkout")&&e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:241:70",className:"text-red-400",children:"*"})]}),e.jsx(f,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:242:15",value:u,onChange:a=>C(a.target.value),placeholder:"https://gitee.com/user/repo.git",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] h-9 font-mono text-xs"})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:244:13",className:"space-y-1",children:[e.jsx(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:245:15",children:"分支 / Tag"}),e.jsx(f,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:246:15",value:R,onChange:a=>t(a.target.value),placeholder:W==="tag"?"v1.0.0":"main",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] h-9"})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:248:13",className:"space-y-1",children:[e.jsxs(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:249:15",children:["Git 凭证 ",e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:249:29",className:"text-xs text-[var(--dg-text-secondary)] opacity-60",children:"(API Token)"})]}),e.jsxs(se,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:250:15",value:String(s),onValueChange:a=>r(a==="__none"?"":a),children:[e.jsx(te,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:251:17",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] h-9",children:e.jsx(oe,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:251:102",placeholder:"选择凭证"})}),e.jsxs(re,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:252:17",children:[e.jsx(L,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:253:19",value:"__none",children:"不关联"}),A.map(a=>e.jsx(L,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:255:21",value:String(a.id),children:e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:256:23",className:"flex items-center gap-1.5",children:[e.jsx(ue,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:257:25",className:"h-3 w-3 opacity-60"}),String(a.name)," ",a.summary&&e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:257:96",className:"text-[10px] opacity-50",children:["(",String(a.summary),")"]})]})},a.id))]})]}),!s&&g.includes("checkout")&&e.jsx("p",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:263:78",className:"text-xs text-amber-400",children:"建议关联凭证"})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:265:13",className:"space-y-1",children:[e.jsxs(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:266:15",children:["镜像仓库凭证 ",g.includes("image")&&e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:266:66",className:"text-red-400",children:"*"})]}),e.jsxs(se,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:267:15",value:String(i),onValueChange:a=>B(a==="__none"?"":a),children:[e.jsx(te,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:268:17",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] h-9",children:e.jsx(oe,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:268:102",placeholder:"选择 Docker 凭证"})}),e.jsxs(re,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:269:17",children:[e.jsx(L,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:270:19",value:"__none",children:"不关联"}),J.map(a=>e.jsx(L,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:272:21",value:String(a.id),children:e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:273:23",className:"flex items-center gap-1.5",children:[e.jsx(le,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:274:25",className:"h-3 w-3 opacity-60"}),String(a.name)," ",a.summary&&e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:274:100",className:"text-[10px] opacity-50",children:["(",String(a.summary),")"]})]})},a.id))]})]}),!i&&g.includes("image")&&e.jsx("p",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:280:80",className:"text-xs text-amber-400",children:"需要关联 Docker 凭证"})]})]}),i&&d&&e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:285:13",className:"p-2.5 rounded-md bg-blue-500/5 border border-blue-500/20 text-xs text-[var(--dg-text-secondary)]",children:[e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:286:15",className:"text-blue-400",children:"镜像命名:"}),e.jsxs("code",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:287:15",className:"text-[var(--dg-text-primary)]",children:["{registry}","/","{namespace}","/","{","{JOB_BASE_NAME}","}",":","{","{tag}","}"]}),e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:288:15",className:"ml-2 opacity-60",children:"例:"}),e.jsxs("code",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:289:15",className:"opacity-60",children:["harbor.ast1001.com/test/",d,":latest"]})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:292:11",className:"space-y-1",children:[e.jsx(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:293:13",children:"Dockerfile 路径"}),e.jsx(f,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:294:13",value:l,onChange:a=>z(a.target.value),placeholder:"jar/Dockerfile",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] h-9 font-mono text-xs"})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:297:11",className:"space-y-2",children:[e.jsxs(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:298:13",children:["发布流程 ",e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:298:25",className:"text-xs text-[var(--dg-text-secondary)] opacity-70 ml-1",children:"按顺序选择阶段"})]}),e.jsx("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:299:13",className:"flex flex-wrap gap-2",children:ie.map(a=>{const c=g.includes(a.key);return e.jsxs(D,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:303:19",className:`cursor-pointer transition-all text-xs px-3 py-1.5 ${c?"border-current":"border-[var(--dg-border)] opacity-50 hover:opacity-80"}`,style:c?{backgroundColor:`${a.color}20`,color:a.color,borderColor:a.color}:{},onClick:()=>E(c?g.filter(x=>x!==a.key):[...g,a.key]),title:a.desc,children:[e.jsx(a.icon,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:310:21",className:"h-3 w-3 mr-1"}),a.label," ",a.needs.includes("repo")?"🔗":"",a.needs.includes("registry")?"📦":""]},a.key)})}),g.length>0&&e.jsx("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:316:15",className:"flex items-center mt-2",children:g.map((a,c)=>{const x=ie.find(m=>m.key===a);return e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:320:21",className:"flex items-center",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:321:23",className:"flex items-center gap-1 px-2 py-1 text-[11px] font-medium border",style:{backgroundColor:`${x.color}20`,borderColor:`${x.color}40`,color:x.color,borderRadius:c===0?"6px 0 0 6px":c===g.length-1?"0 6px 6px 0":"0"},children:[e.jsx(x.icon,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:330:25",className:"h-3 w-3"}),x.label]}),c<g.length-1&&e.jsx("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:333:25",className:"flex items-center justify-center w-4 h-5 -mx-px z-10",children:e.jsx(de,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:334:27",className:"h-3 w-3",style:{color:x.color}})})]},c)})})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:344:11",className:"border-t border-[var(--dg-border)] pt-4",children:[e.jsx(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:345:13",className:"mb-2 block",children:"触发方式"}),e.jsx("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:346:13",className:"flex gap-1 bg-[var(--dg-bg-secondary)] rounded-lg p-1 border border-[var(--dg-border)]",children:[{key:"manual",label:"手动",desc:"手动触发执行"},{key:"git_push",label:"代码推送",desc:"Git Push 自动触发"},{key:"cron",label:"定时",desc:"Cron 定时执行"},{key:"webhook",label:"Webhook",desc:"外部 Webhook 调用"}].map(a=>{const c=k===a.key;return e.jsx("button",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:355:19",onClick:()=>S(a.key),className:`flex-1 flex flex-col items-center gap-0.5 px-2 py-2 rounded-md text-xs font-medium transition-all ${c?"bg-blue-500 text-white":"text-[var(--dg-text-secondary)] hover:text-[var(--dg-text-primary)]"}`,title:a.desc,children:a.label},a.key)})}),k==="git_push"&&e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:370:15",className:"mt-3 space-y-2 p-3 rounded-md bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)]",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:371:17",className:"space-y-1",children:[e.jsxs(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:372:19",className:"text-xs",children:["监听分支 ",e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:372:51",className:"text-[var(--dg-text-secondary)] opacity-60",children:"(逗号分隔,支持 * 通配)"})]}),e.jsx(f,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:373:19",value:Pe,onChange:a=>ve(a.target.value),placeholder:"release/*, main",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] h-8 font-mono text-xs"})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:375:17",className:"space-y-1",children:[e.jsxs(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:376:19",className:"text-xs",children:["排除分支 ",e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:376:51",className:"text-[var(--dg-text-secondary)] opacity-60",children:"(不触发构建)"})]}),e.jsx(f,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:377:19",value:je,onChange:a=>be(a.target.value),placeholder:"wip/*, draft/*",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] h-8 font-mono text-xs"})]})]}),k==="cron"&&e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:383:15",className:"mt-3 space-y-2 p-3 rounded-md bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)]",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:384:17",className:"space-y-1",children:[e.jsxs(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:385:19",className:"text-xs",children:["Cron 表达式 ",e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:385:55",className:"text-[var(--dg-text-secondary)] opacity-60",children:"(标准 5 位)"})]}),e.jsx(f,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:386:19",value:Ne,onChange:a=>pe(a.target.value),placeholder:"0 2 * * *",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] h-8 font-mono text-xs"})]}),e.jsx("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:388:17",className:"flex flex-wrap gap-1.5",children:[{expr:"*/5 * * * *",label:"每5分钟"},{expr:"0 * * * *",label:"每小时"},{expr:"0 2 * * *",label:"每天2点"},{expr:"0 0 * * 0",label:"每周日"}].map(a=>e.jsx(D,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:395:21",variant:"outline",className:"cursor-pointer text-[10px] hover:bg-blue-500/10",onClick:()=>pe(a.expr),children:a.label},a.expr))})]}),k==="webhook"&&e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:404:15",className:"mt-3 space-y-2 p-3 rounded-md bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)]",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:405:17",className:"space-y-1",children:[e.jsxs(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:406:19",className:"text-xs",children:["Webhook Token ",e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:406:60",className:"text-[var(--dg-text-secondary)] opacity-60",children:"(签名验证,可选)"})]}),e.jsx(f,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:407:19",value:Ce,onChange:a=>fe(a.target.value),placeholder:"随机字符串",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] h-8 font-mono text-xs"})]}),e.jsxs("p",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:409:17",className:"text-[10px] text-[var(--dg-text-secondary)] opacity-60",children:["Webhook URL: ",e.jsxs("code",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:410:32",className:"text-[var(--dg-blue)]",children:["POST /api/v1/webhook/pipeline/","{code}"]})]})]})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:416:11",className:"border-t border-[var(--dg-border)] pt-4",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:417:13",className:"flex items-center justify-between mb-2",children:[e.jsxs(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:418:15",children:["环境变量 ",e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:418:27",className:"text-xs text-[var(--dg-text-secondary)] opacity-60",children:["($","{VAR_NAME}"," 引用)"]})]}),e.jsxs(v,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:419:15",variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>I([...G,{key:"",value:"",desc:""}]),children:[e.jsx(xe,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:420:17",className:"h-3 w-3 mr-1"}),"添加变量"]})]}),G.length===0?e.jsx("p",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:424:15",className:"text-xs text-[var(--dg-text-muted)] py-2",children:'暂无变量,点击"添加变量"新增'}):e.jsx("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:426:15",className:"space-y-2",children:G.map((a,c)=>e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:428:19",className:"grid grid-cols-12 gap-2 items-start p-2 rounded-md bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)]",children:[e.jsx(f,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:429:21",value:a.key,onChange:x=>{const m=[...G];m[c]={...m[c],key:x.target.value},I(m)},placeholder:"变量名",className:"col-span-3 h-8 text-xs font-mono bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]"}),e.jsx(f,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:439:21",value:a.value,onChange:x=>{const m=[...G];m[c]={...m[c],value:x.target.value},I(m)},placeholder:"变量值",className:"col-span-4 h-8 text-xs font-mono bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]"}),e.jsx(f,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:449:21",value:a.desc,onChange:x=>{const m=[...G];m[c]={...m[c],desc:x.target.value},I(m)},placeholder:"说明",className:"col-span-4 h-8 text-xs bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]"}),e.jsx(v,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:459:21",variant:"ghost",size:"icon",className:"col-span-1 h-8 w-8 text-red-400",onClick:()=>I(G.filter((x,m)=>m!==c)),children:e.jsx($e,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:460:23",className:"h-3.5 w-3.5"})})]},c))})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:468:11",className:"border-t border-[var(--dg-border)] pt-4",children:[e.jsxs(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:469:13",className:"mb-2 block",children:["构建缓存 ",e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:469:48",className:"text-xs text-[var(--dg-text-secondary)] opacity-60",children:"(加速后续构建)"})]}),e.jsx(f,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:470:13",value:De,onChange:a=>we(a.target.value),placeholder:"node_modules, .m2, target",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] h-8 text-xs font-mono"}),e.jsx("p",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:471:13",className:"text-[10px] text-[var(--dg-text-secondary)] opacity-50 mt-1",children:"多个路径用逗号分隔,相同的 Key 会命中已有缓存"})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:474:11",className:"border-t border-[var(--dg-border)] pt-4",children:[e.jsxs(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:475:13",className:"mb-2 block",children:["并发执行数 ",e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:475:49",className:"text-xs text-[var(--dg-text-secondary)] opacity-60",children:"(Number of executors)"})]}),e.jsx("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:476:13",className:"flex items-center gap-2",children:e.jsxs(se,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:477:15",value:String(ke),onValueChange:a=>Se(Number(a)),children:[e.jsx(te,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:478:17",className:"w-32 h-8 text-xs bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsx(oe,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:479:19"})}),e.jsxs(re,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:481:17",children:[e.jsx(L,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:482:19",value:"1",children:"1 — 串行"}),e.jsx(L,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:483:19",value:"2",children:"2"}),e.jsx(L,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:484:19",value:"3",children:"3"}),e.jsx(L,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:485:19",value:"4",children:"4"}),e.jsx(L,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:486:19",value:"5",children:"5"})]})]})}),e.jsx("p",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:490:13",className:"text-[10px] text-[var(--dg-text-secondary)] opacity-50 mt-1",children:"设为 1 则按顺序串行执行,默认 2 可并发构建"})]})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:493:9",className:"flex justify-end gap-2 mt-4 pt-4 border-t border-[var(--dg-border)]",children:[e.jsx(v,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:494:11",variant:"outline",onClick:()=>p(!1),children:"取消"}),e.jsxs(v,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:495:11",onClick:qe,disabled:O,children:[O?e.jsx(H,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:496:23",className:"h-4 w-4 animate-spin mr-1"}):e.jsx(Y,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:496:75",className:"h-4 w-4 mr-1"}),O?"创建中...":"创建流水线"]})]})]})})}function Ia(){const[n,p]=o.useState(""),{data:P=[],isLoading:b,refetch:j}=da(),{triggerMutation:d,deleteMutation:y,stopRunMutation:M}=ma(),[w,u]=o.useState({}),[C,R]=o.useState({}),[t,l]=o.useState({}),[z,g]=o.useState("all"),[E,W]=o.useState({}),[_,F]=o.useState(!1),V=Qe(),q=[{key:"all",label:"全部",icon:oa,color:"#6B7280"},{key:"production",label:"生产",icon:Ee,color:"#EF4444"},{key:"testing",label:"测试",icon:ae,color:"#F59E0B"},{key:"staging",label:"预发布",icon:ue,color:"#8B5CF6"},{key:"development",label:"开发",icon:ra,color:"#3B82F6"}];o.useEffect(()=>{P.forEach(s=>{const r=s.id;s.last_status==="running"&&!E[r]&&T.getRuns(s.code).then(i=>{const k=(i?.list||[]).find(S=>S.status==="running"||S.status==="pending");k&&W(S=>({...S,[r]:k}))}).catch(()=>{})})},[P,E]);const $=async(s,r)=>{l(i=>({...i,[s]:!0}));try{const i=await T.getRuns(r);R(B=>({...B,[s]:i?.list||[]}))}catch{R(i=>({...i,[s]:[]}))}finally{l(i=>({...i,[s]:!1}))}},O=(s,r)=>{w[s]?u(i=>({...i,[s]:!1})):($(s,r),u(i=>({...i,[s]:!0})))},Q=async(s,r)=>{try{await d.mutateAsync(r),N.success("已触发"),$(s,r),j()}catch{N.error("触发失败")}},A=async(s,r,i)=>{if(await V({title:"停止运行",description:"确定要停止此运行吗?",variant:"destructive"}))try{await M.mutateAsync({code:r,runId:i}),N.success("已停止"),$(s,r),W(k=>{const S={...k};return delete S[s],S})}catch{N.error("停止失败")}},X=async(s,r)=>{const i=E[s];if(!i){try{const k=((await T.getRuns(r))?.list||[]).find(S=>S.status==="running"||S.status==="pending");k?await A(s,r,k.id):N.error("未找到运行中的任务")}catch{N.error("停止失败")}return}await A(s,r,i.id)},J=async s=>{if(await V({title:"删除流水线",description:`确定删除「${s.name}」?`,variant:"destructive"}))try{await y.mutateAsync(s.id),N.success("已删除"),j()}catch{N.error("删除失败")}},ne=P.filter(s=>{const r=String(s.name||"").toLowerCase().includes(n.toLowerCase())||String(s.description||"").toLowerCase().includes(n.toLowerCase()),i=s.environment,B=z==="all"||(i?.type||"")===z;return r&&B});return e.jsxs("div",{"code-path":"src/components/deploy/PipelineManager.tsx:157:5",className:"space-y-5",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineManager.tsx:158:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineManager.tsx:159:9",children:[e.jsx("h1",{"code-path":"src/components/deploy/PipelineManager.tsx:160:11",className:"text-2xl font-bold text-[var(--dg-text-primary)]",children:"流水线"}),e.jsx("p",{"code-path":"src/components/deploy/PipelineManager.tsx:161:11",className:"text-sm text-[var(--dg-text-secondary)] mt-1",children:"CI/CD 构建 · 部署 · 发布一体化"})]}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineManager.tsx:163:9",className:"flex items-center gap-2",children:[e.jsxs(v,{"code-path":"src/components/deploy/PipelineManager.tsx:164:11",variant:"outline",className:"border-[var(--dg-border)] text-[var(--dg-text-secondary)]",onClick:()=>j(),children:[e.jsx(Z,{"code-path":"src/components/deploy/PipelineManager.tsx:165:13",className:`h-4 w-4 mr-2 ${b?"animate-spin":""}`}),"刷新"]}),e.jsxs(v,{"code-path":"src/components/deploy/PipelineManager.tsx:167:11",onClick:()=>F(!0),children:[e.jsx(xe,{"code-path":"src/components/deploy/PipelineManager.tsx:167:52",className:"h-4 w-4 mr-2"}),"新建流水线"]})]})]}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineManager.tsx:172:7",className:"flex items-stretch gap-3 px-4 py-3 rounded-lg bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)]",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineManager.tsx:173:9",className:"flex-1 space-y-1.5",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineManager.tsx:174:11",className:"flex items-center gap-1.5",children:[e.jsx(U,{"code-path":"src/components/deploy/PipelineManager.tsx:175:13",className:"h-3 w-3 text-indigo-400"}),e.jsx("span",{"code-path":"src/components/deploy/PipelineManager.tsx:176:13",className:"text-[10px] font-semibold text-indigo-400",children:"构建"}),e.jsx(K,{"code-path":"src/components/deploy/PipelineManager.tsx:177:13",className:"h-2.5 w-2.5 text-[var(--dg-text-secondary)] opacity-30"}),e.jsx(Y,{"code-path":"src/components/deploy/PipelineManager.tsx:178:13",className:"h-3 w-3 text-red-400"}),e.jsx("span",{"code-path":"src/components/deploy/PipelineManager.tsx:179:13",className:"text-[10px] font-semibold text-red-400",children:"部署"}),e.jsx(K,{"code-path":"src/components/deploy/PipelineManager.tsx:180:13",className:"h-2.5 w-2.5 text-[var(--dg-text-secondary)] opacity-30"}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineManager.tsx:181:13",className:"flex items-center gap-1 px-2 py-0.5 rounded bg-blue-400/10 border border-blue-400/20",children:[e.jsx(ye,{"code-path":"src/components/deploy/PipelineManager.tsx:182:15",className:"h-3 w-3 text-blue-400"}),e.jsx("span",{"code-path":"src/components/deploy/PipelineManager.tsx:183:15",className:"text-[10px] font-medium text-blue-400",children:"SSH 主机"})]})]}),e.jsx("p",{"code-path":"src/components/deploy/PipelineManager.tsx:186:11",className:"text-[9px] text-[var(--dg-text-secondary)] opacity-40 pl-1",children:"传统主机 SCP 部署 · 无需镜像仓库"})]}),e.jsx("div",{"code-path":"src/components/deploy/PipelineManager.tsx:188:9",className:"w-px bg-[var(--dg-border)]"}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineManager.tsx:189:9",className:"flex-1 space-y-1.5",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineManager.tsx:190:11",className:"flex items-center gap-1.5",children:[e.jsx(U,{"code-path":"src/components/deploy/PipelineManager.tsx:191:13",className:"h-3 w-3 text-indigo-400"}),e.jsx("span",{"code-path":"src/components/deploy/PipelineManager.tsx:192:13",className:"text-[10px] font-semibold text-indigo-400",children:"构建"}),e.jsx(K,{"code-path":"src/components/deploy/PipelineManager.tsx:193:13",className:"h-2.5 w-2.5 text-[var(--dg-text-secondary)] opacity-30"}),e.jsx(le,{"code-path":"src/components/deploy/PipelineManager.tsx:194:13",className:"h-3 w-3 text-cyan-400"}),e.jsx("span",{"code-path":"src/components/deploy/PipelineManager.tsx:195:13",className:"text-[10px] font-semibold text-cyan-400",children:"镜像仓库"}),e.jsx(K,{"code-path":"src/components/deploy/PipelineManager.tsx:196:13",className:"h-2.5 w-2.5 text-[var(--dg-text-secondary)] opacity-30"}),e.jsx(Y,{"code-path":"src/components/deploy/PipelineManager.tsx:197:13",className:"h-3 w-3 text-red-400"}),e.jsx("span",{"code-path":"src/components/deploy/PipelineManager.tsx:198:13",className:"text-[10px] font-semibold text-red-400",children:"部署"}),e.jsx(K,{"code-path":"src/components/deploy/PipelineManager.tsx:199:13",className:"h-2.5 w-2.5 text-[var(--dg-text-secondary)] opacity-30"}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineManager.tsx:200:13",className:"flex items-center gap-1 px-2 py-0.5 rounded bg-emerald-400/10 border border-emerald-400/20",children:[e.jsx(he,{"code-path":"src/components/deploy/PipelineManager.tsx:201:15",className:"h-3 w-3 text-emerald-400"}),e.jsx("span",{"code-path":"src/components/deploy/PipelineManager.tsx:202:15",className:"text-[10px] font-medium text-emerald-400",children:"Kubernetes"})]})]}),e.jsx("p",{"code-path":"src/components/deploy/PipelineManager.tsx:205:11",className:"text-[9px] text-[var(--dg-text-secondary)] opacity-40 pl-1",children:"容器化部署 · 需镜像仓库推送"})]}),e.jsx("span",{"code-path":"src/components/deploy/PipelineManager.tsx:207:9",className:"self-center ml-2 text-[10px] text-[var(--dg-text-secondary)] opacity-30 tracking-wide whitespace-nowrap",children:"全流程可视化"})]}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineManager.tsx:210:7",className:"flex items-center gap-4",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineManager.tsx:211:9",className:"relative max-w-md flex-1",children:[e.jsx(ta,{"code-path":"src/components/deploy/PipelineManager.tsx:212:11",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-[var(--dg-text-secondary)]"}),e.jsx(f,{"code-path":"src/components/deploy/PipelineManager.tsx:213:11",placeholder:"搜索流水线...",value:n,onChange:s=>p(s.target.value),className:"pl-10 bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"})]}),e.jsx("div",{"code-path":"src/components/deploy/PipelineManager.tsx:220:9",className:"flex items-center gap-1 bg-[var(--dg-bg-secondary)] rounded-lg p-1 border border-[var(--dg-border)]",children:q.map(s=>{const r=z===s.key,i=s.icon;return e.jsxs("button",{"code-path":"src/components/deploy/PipelineManager.tsx:225:15",onClick:()=>g(s.key),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-all ${r?"text-white shadow-sm":"text-[var(--dg-text-secondary)] hover:text-[var(--dg-text-primary)]"}`,style:r?{backgroundColor:s.color}:{},children:[e.jsx(i,{"code-path":"src/components/deploy/PipelineManager.tsx:233:17",className:"h-3.5 w-3.5"}),s.label]},s.key)})})]}),b?e.jsx("div",{"code-path":"src/components/deploy/PipelineManager.tsx:241:9",className:"flex items-center justify-center py-12",children:e.jsx(H,{"code-path":"src/components/deploy/PipelineManager.tsx:242:11",className:"h-6 w-6 text-[var(--dg-text-secondary)] animate-spin"})}):ne.length===0?e.jsxs("div",{"code-path":"src/components/deploy/PipelineManager.tsx:245:9",className:"text-center py-16 text-[var(--dg-text-secondary)]",children:[e.jsx(ca,{"code-path":"src/components/deploy/PipelineManager.tsx:246:11",className:"h-10 w-10 mx-auto mb-3 opacity-30"}),e.jsx("p",{"code-path":"src/components/deploy/PipelineManager.tsx:247:11",className:"text-sm",children:"暂无流水线"}),e.jsxs(v,{"code-path":"src/components/deploy/PipelineManager.tsx:248:11",variant:"outline",className:"mt-4",onClick:()=>F(!0),children:[e.jsx(xe,{"code-path":"src/components/deploy/PipelineManager.tsx:249:13",className:"h-4 w-4 mr-1"}),"创建第一个流水线"]})]}):e.jsx("div",{"code-path":"src/components/deploy/PipelineManager.tsx:253:9",className:"space-y-3",children:ne.map(s=>{const r=s.id,i=s.code||s.id;return e.jsx(Pa,{"code-path":"src/components/deploy/PipelineManager.tsx:258:15",pipeline:s,isExpanded:!!w[r],isLoadingRuns:!!t[r],pipelineRuns:C[r]||[],onToggleExpand:()=>O(r,i),onTrigger:()=>Q(r,i),onStopRunning:()=>X(r,i),onDelete:()=>J(s),onStopRun:B=>A(r,i,B)},r)})}),e.jsx(va,{"code-path":"src/components/deploy/PipelineManager.tsx:275:7",open:_,onOpenChange:F,onCreated:j})]})}export{Ia as PipelineManager};
|