28 lines
247 KiB
JavaScript
28 lines
247 KiB
JavaScript
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PodFileBrowser-B-U8iHmY.js","assets/vendor-codemirror-B1SGo4xl.js","assets/index-Dungj95X.js","assets/vendor-icons-DmqcWdzX.js","assets/index-GY9Szy-F.css","assets/use-toast-DNZLibQY.js","assets/index-drGq01ok.js","assets/k8s-yaml-utils-4KZB_Bq_.js","assets/select-CiTqGGhE.js","assets/index-5FEebgvX.js","assets/vendor-xterm-20M9KZE1.js","assets/vendor-xterm-DXOU9pbP.css","assets/badge-CGJlVD3L.js"])))=>i.map(i=>d[i]);
|
||
import{j as e,r as d}from"./vendor-codemirror-B1SGo4xl.js";import{B as v,ab as Os,ac as $s,ad as _s,ag as bt,f as dt,r as Ls,u as zs,L as yt,s as Ws,o as is,i as ps,ah as Gs,g as Vs}from"./index-Dungj95X.js";import{C as U,a as Y,b as he,c as ue}from"./card-BIfzBCEy.js";import{B as ae}from"./badge-CGJlVD3L.js";import{k as K}from"./index-drGq01ok.js";import{u as Me}from"./use-toast-DNZLibQY.js";import{c as vt,m as Fs,h as Us,p as ms,i as Gt,Y as kt,P as Ys,a as qs}from"./PodFileBrowser-B-U8iHmY.js";import{I as f}from"./input-CXoUQQLm.js";import{e as Vt,a as Ft,f as Pt,S as Ce,s as Ks}from"./k8s-yaml-utils-4KZB_Bq_.js";import{E as Js,n as Xs}from"./EventTable-BaH7H8dT.js";import{Q as xs,f as hs,r as us,H as bs,bb as Qs,F as At,o as Zs,T as be,L as ve,N as Ae,E as en,A as ys,b as vs,n as tn,k as Ue,P as te,aw as sn,s as Tt,bc as nn,aO as ks,bd as gt,$ as it,g as on,be as an,a4 as gs,j as js,as as rn,am as fs,aj as cn,z as Ns,R as Ye,D as tt,b4 as ln,h as Mt,aY as dn,aX as pn,G as mn,M as xn,p as wt,y as Ct,d as Ut,J as jt,X as Ss,ae as Yt,l as ws,a as hn,m as qt,aI as Kt,bf as un,ao as bn}from"./vendor-icons-DmqcWdzX.js";import{T as Ge,a as Ve,b as Ee,c as ce,d as Fe,e as le}from"./table-B2F10oba.js";import{L as H}from"./label-CMpUoC87.js";import{T as st}from"./textarea-BxfjmLq5.js";import{S as nt,a as ot,b as at,c as rt,d as fe}from"./select-CiTqGGhE.js";import{S as Ht}from"./switch-Bxiq4EHp.js";import{R as Cs,c as yn}from"./ResourceVisualEditor-BN2gGuH7.js";import{C as Jt}from"./code-snippet-block-E9P2jHS4.js";import"./vendor-xterm-20M9KZE1.js";import"./index-5FEebgvX.js";const vn=t=>Array.isArray(t)?t:t?.list||t?.items||t?.data||[];function kn(t,s){return Object.keys(s).length===0?!1:Object.entries(s).every(([a,o])=>t[a]===o)}function gn(t,s,a){const o=new Set;for(const n of a){const c=n.name||n.metadata?.name||"";if(!c)continue;const r=n.spec?.selector||n.selector||{};(c===t||kn(s,r))&&o.add(c)}return[...o].sort()}async function jn(t,s,a){const o=await K.getResourceYaml(t,s,"deployments",a),{manifest:n}=await vt(o),c=n?.spec?.selector?.matchLabels||n?.spec?.template?.metadata?.labels||{},r=await K.getNamespaceServices(t,s).catch(()=>[]),i=gn(a,c,vn(r)),k=[];if(n)k.push(await Fs(n));else{const{yaml:l}=await vt(o);l.trim()&&k.push(l)}for(const l of i)try{const x=await K.getResourceYaml(t,s,"services",l),{yaml:S}=await vt(x);S.trim()&&k.push(S)}catch{}return k.join(`
|
||
---
|
||
`)}async function fn(t,s,a){const{manifests:o}=await Us(a);if(o.length===0)throw new Error("YAML 内容为空或解析失败");for(const n of o){const c=String(n.kind||"").toLowerCase(),r=String(n.metadata?.name||"").trim();if(!c||!r)throw new Error("每个 YAML 文档必须包含 kind 和 metadata.name");const i=await ms(n);if(c==="deployment"){await K.updateResourceYaml(t,s,"deployments",r,i);continue}if(c==="service"){await K.applyYAML(t,i);continue}throw new Error(`不支持的资源类型: ${n.kind}(仅支持 Deployment / Service)`)}}function Nn(t){const s=t.conditions||t.pod_conditions||[],a=n=>s.find(c=>(c.type||c.Type)===n),o=n=>n?.lastTransitionTime||n?.LastTransitionTime||n?.last_transition_time;return{scheduled:o(a("PodScheduled")||{}),initialized:o(a("Initialized")||{}),containersReady:o(a("ContainersReady")||{}),ready:o(a("Ready")||{}),startTime:t.start_time||t.startTime}}function Sn(t){const s=Nn(t);return[{label:"已调度",ts:s.scheduled,color:Ce.blue},{label:"已初始化",ts:s.initialized,color:Ce.orange},{label:"容器已就绪",ts:s.containersReady,color:Ce.green},{label:"容器组已就绪",ts:s.ready,color:Ce.green}]}function Re({label:t,value:s}){return e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:43:5",children:[e.jsx("p",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:44:7",className:"text-xs text-[var(--dg-text-muted)] mb-1",children:t}),e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:45:7",className:"text-sm text-[var(--dg-text-primary)]",children:s})]})}function Es({pod:t}){const s=Sn(t),a=Vt(s[0]?.ts,s[s.length-1]?.ts);return e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:92:5",className:"rounded-lg bg-[var(--dg-bg-tertiary)]/60 px-4 py-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:93:7",className:"flex items-center justify-between mb-3",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:94:9",className:"text-xs text-[var(--dg-text-muted)]",children:"启动时间线"}),a!=null&&e.jsxs("span",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:96:11",className:"text-[11px] text-[var(--dg-text-muted)]",children:["总耗时 ",e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:97:17",className:"font-mono text-[var(--dg-text-secondary)]",children:Ft(a)})]})]}),e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:101:7",className:"flex items-start gap-0 overflow-x-auto",children:s.map((o,n)=>{const c=s[n-1],r=Vt(c?.ts,o.ts),i=!!o.ts;return e.jsxs(d.Fragment,{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:107:13",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:108:15",className:"flex flex-col min-w-[108px]",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:109:17",className:"flex items-center gap-2",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:110:19",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-[10px] font-semibold",style:{background:i?`${o.color}22`:"var(--dg-bg-secondary)",color:i?o.color:"var(--dg-text-muted)",border:`1px solid ${i?`${o.color}55`:"var(--dg-border)"}`},children:n+1}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:120:19",className:"text-xs font-medium",style:{color:i?o.color:"var(--dg-text-muted)"},children:o.label})]}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:124:17",className:"mt-1.5 pl-7 text-[11px] font-mono text-[var(--dg-text-muted)]",children:o.ts?Pt(o.ts):"—"})]}),n<s.length-1&&e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:129:17",className:"flex flex-col items-center justify-center px-1 pt-2.5 min-w-[48px]",children:[e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:130:19",className:"h-px w-full",style:{background:i&&s[n+1]?.ts?o.color:"var(--dg-border)"}}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:134:19",className:"mt-1 text-[10px] text-[var(--dg-text-muted)]",children:r!=null?Ft(r):""})]})]},o.label)})})]})}function wn({clusterCode:t,pods:s,onShowPodLogs:a,onShowPodTerminal:o,onShowPodYaml:n,onShowPodFileBrowser:c,onDeletePod:r,expandedPod:i,setExpandedPod:k}){return s.length===0?e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:24:12",className:"text-center text-[var(--dg-text-muted)] py-12",children:"暂无容器组"}):e.jsx(U,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:28:5",className:"dg-card overflow-hidden",children:e.jsxs(Y,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:29:7",className:"p-0 overflow-x-auto",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:31:9",className:"grid grid-cols-[28px_minmax(140px,1fr)_72px_100px_96px_48px_56px_88px] gap-2 min-w-[740px] px-4 py-2.5 border-b border-[var(--dg-border)] bg-[var(--dg-bg-tertiary)]/40 text-[11px] font-medium text-[var(--dg-text-muted)] uppercase tracking-wide",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:32:11"}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:33:11",children:"名称"}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:34:11",children:"状态"}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:35:11",children:"节点"}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:36:11",children:"IP"}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:37:11",className:"text-center",children:"重启"}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:38:11",children:"Age"}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:39:11",className:"text-right",children:"操作"})]}),e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:42:9",className:"divide-y divide-[var(--dg-border)]",children:s.map(l=>{const x=i===l.name,S=l.node_name||l.node,C=Ks(l.status),y=l.containers;return e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:50:15",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:52:17",className:`grid grid-cols-[28px_minmax(140px,1fr)_72px_100px_96px_48px_56px_88px] gap-2 min-w-[740px] items-center px-4 py-3 transition-colors ${x?"bg-[var(--dg-bg-tertiary)]/30":"hover:bg-[var(--dg-bg-tertiary)]/20"}`,children:[e.jsx(v,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:57:19",variant:"ghost",size:"icon",className:"h-6 w-6 text-[var(--dg-text-muted)]",onClick:()=>k(x?null:l.name),children:x?e.jsx(xs,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:63:33",className:"h-4 w-4"}):e.jsx(hs,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:63:71",className:"h-4 w-4"})}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:66:19",className:"font-mono text-sm text-[var(--dg-text-primary)] truncate",title:l.name,children:l.name}),e.jsx(ae,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:70:19",className:"w-fit text-[11px] font-normal",style:{background:`${C}18`,color:C,border:`1px solid ${C}33`},children:l.status||"Unknown"}),e.jsx("button",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:77:19",className:"text-xs text-[var(--dg-blue)] hover:underline truncate text-left",title:S,onClick:()=>S&&window.open(`/kubernetes/${t}/nodes/${S}`,"_blank"),children:S||"—"}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:85:19",className:"text-xs font-mono text-[var(--dg-text-muted)] truncate",children:l.ip||l.pod_ip||"—"}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:89:19",className:`text-xs text-center font-mono ${(l.restart_count||0)>0?"text-amber-400":"text-[var(--dg-text-muted)]"}`,children:l.restart_count||0}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:93:19",className:"text-xs text-[var(--dg-text-muted)] whitespace-nowrap",children:l.age||"—"}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:97:19",className:"flex items-center justify-end gap-0.5 shrink-0 w-[88px]",children:[e.jsx(v,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:98:21",variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0 text-emerald-400",title:"终端",onClick:()=>o(l),children:e.jsx(us,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:99:23",className:"h-3.5 w-3.5"})}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:101:21",variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0 text-amber-400",title:"文件",onClick:()=>c(l),children:e.jsx(bs,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:102:23",className:"h-3.5 w-3.5"})}),e.jsxs(Os,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:104:21",children:[e.jsx($s,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:105:23",asChild:!0,children:e.jsx(v,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:106:25",variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0 text-[var(--dg-text-muted)] hover:text-[var(--dg-blue)]",title:"更多","aria-label":"更多",children:e.jsx(Qs,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:113:27",className:"h-3.5 w-3.5"})})}),e.jsxs(_s,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:116:23",align:"end",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:[e.jsxs(bt,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:117:25",onClick:()=>a(l),className:"text-[var(--dg-text-primary)]",children:[e.jsx(At,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:118:27",className:"h-3.5 w-3.5 mr-2"})," 日志"]}),e.jsxs(bt,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:120:25",onClick:()=>n(l),className:"text-[var(--dg-text-primary)]",children:[e.jsx(Zs,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:121:27",className:"h-3.5 w-3.5 mr-2"})," YAML"]}),e.jsxs(bt,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:123:25",onClick:()=>r?.(l),className:"text-red-400 focus:text-red-400",children:[e.jsx(be,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:124:27",className:"h-3.5 w-3.5 mr-2"})," 删除"]})]})]})]})]}),x&&e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:133:19",className:"px-4 pb-4 pt-1 space-y-3 bg-[var(--dg-bg-tertiary)]/20",children:[e.jsx(Es,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:134:21",pod:l}),y&&y.length>0&&e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:136:23",children:[e.jsx("p",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:137:25",className:"text-xs text-[var(--dg-text-muted)] mb-2",children:"容器"}),e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:138:25",className:"grid grid-cols-1 md:grid-cols-2 gap-2",children:y.map((b,w)=>e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:140:29",className:"rounded-md border border-[var(--dg-border)] bg-[var(--dg-bg-secondary)] px-3 py-2.5 text-xs",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:141:31",className:"flex items-center justify-between gap-2",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:142:33",className:"font-medium text-[var(--dg-text-primary)]",children:b.name}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:143:33",className:b.ready?"text-emerald-400":"text-[var(--dg-text-muted)]",children:b.ready?"Ready":"Pending"})]}),e.jsx("p",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:147:31",className:"text-[var(--dg-text-muted)] mt-1 truncate",title:b.image,children:b.image}),b.resources&&e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:149:33",className:"mt-1.5 flex gap-4 text-[var(--dg-text-muted)]",children:[e.jsxs("span",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:150:35",children:["CPU ",b.resources?.requests?.cpu||"0"," / ",b.resources?.limits?.cpu||"—"]}),e.jsxs("span",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:151:35",children:["内存 ",b.resources?.requests?.memory||"0"," / ",b.resources?.limits?.memory||"—"]})]})]},w))})]})]})]},l.name)})})]})})}function Cn({services:t,ingresses:s,loading:a}){return a==="services"?e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:12:12",className:"flex items-center justify-center py-12",children:e.jsx(ve,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:12:68",className:"h-6 w-6 animate-spin text-[var(--dg-text-muted)]"})}):e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:15:5",className:"space-y-6",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:17:7",children:[e.jsxs("h3",{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:18:9",className:"text-sm font-semibold text-[var(--dg-text-primary)] mb-3 flex items-center gap-2",children:[e.jsx(Ae,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:19:11",className:"h-4 w-4 text-[var(--dg-blue)]"}),"关联 Service"]}),t.length===0?e.jsx("p",{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:22:11",className:"text-sm text-[var(--dg-text-muted)] py-4",children:"暂无匹配的 Service(Deployment 选择器未关联任何 Service)"}):e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:24:11",className:"overflow-x-auto",children:e.jsxs(Ge,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:25:13",children:[e.jsx(Ve,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:26:15",children:e.jsxs(Ee,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:27:17",className:"border-[var(--dg-border)]",children:[e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:28:19",className:"text-[var(--dg-text-muted)]",children:"名称"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:29:19",className:"text-[var(--dg-text-muted)]",children:"类型"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:30:19",className:"text-[var(--dg-text-muted)]",children:"ClusterIP"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:31:19",className:"text-[var(--dg-text-muted)]",children:"端口"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:32:19",className:"text-[var(--dg-text-muted)]",children:"Selector"})]})}),e.jsx(Fe,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:35:15",children:t.map(o=>e.jsxs(Ee,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:37:19",className:"border-[var(--dg-border)]",children:[e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:38:21",className:"font-medium text-[var(--dg-text-primary)]",children:o.name}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:39:21",children:e.jsx(ae,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:39:32",variant:"outline",className:"text-xs",children:o.type})}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:40:21",className:"font-mono text-sm text-[var(--dg-text-muted)]",children:o.clusterIP}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:41:21",className:"text-sm text-[var(--dg-text-muted)]",children:o.ports.join(", ")}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:42:21",className:"text-xs text-[var(--dg-text-muted)]",children:Object.entries(o.selector).map(([n,c])=>e.jsxs("code",{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:44:25",className:"mr-1 bg-[var(--dg-bg-tertiary)] px-1 rounded",children:[n,"=",c]},n))})]},o.name))})]})})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:56:7",children:[e.jsxs("h3",{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:57:9",className:"text-sm font-semibold text-[var(--dg-text-primary)] mb-3 flex items-center gap-2",children:[e.jsx(en,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:58:11",className:"h-4 w-4 text-[var(--dg-purple)]"}),"关联 Ingress"]}),s.length===0?e.jsx("p",{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:61:11",className:"text-sm text-[var(--dg-text-muted)] py-4",children:"暂无匹配的 Ingress"}):e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:63:11",className:"overflow-x-auto",children:e.jsxs(Ge,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:64:13",children:[e.jsx(Ve,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:65:15",children:e.jsxs(Ee,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:66:17",className:"border-[var(--dg-border)]",children:[e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:67:19",className:"text-[var(--dg-text-muted)]",children:"名称"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:68:19",className:"text-[var(--dg-text-muted)]",children:"Class"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:69:19",className:"text-[var(--dg-text-muted)]",children:"Host"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:70:19",className:"text-[var(--dg-text-muted)]",children:"路径"})]})}),e.jsx(Fe,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:73:15",children:s.map(o=>e.jsxs(Ee,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:75:19",className:"border-[var(--dg-border)]",children:[e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:76:21",className:"font-medium text-[var(--dg-text-primary)]",children:o.name}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:77:21",className:"text-sm text-[var(--dg-text-muted)]",children:o.className}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:78:21",className:"text-sm text-[var(--dg-text-muted)]",children:o.hosts.join(", ")}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:79:21",className:"text-xs text-[var(--dg-text-muted)]",children:o.rules.flatMap(n=>(n.http?.paths||n.paths||[]).map(c=>c.path||"/")).join(", ")})]},o.name))})]})})]})]})}function En({events:t,loading:s}){return e.jsx(Js,{"code-path":"src/components/kubernetes/deployment-view/EventsTab.tsx:7:5",events:t,loading:s,emptyText:"暂无事件"})}function Dn({hpas:t,cronHpas:s,loading:a,replicas:o}){return a==="scale"?e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:13:12",className:"flex items-center justify-center py-12",children:e.jsx(ve,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:13:68",className:"h-6 w-6 animate-spin text-[var(--dg-text-muted)]"})}):e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:17:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:19:7",className:"flex items-center gap-2 px-2",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:20:9",className:"text-sm text-[var(--dg-text-muted)]",children:"当前副本:"}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:21:9",className:"text-sm font-bold text-[var(--dg-text-primary)]",children:o}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:22:9",className:"text-xs text-[var(--dg-text-muted)]",children:"(可通过 Tab 栏右侧 +/- 手动调整)"})]}),e.jsxs(U,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:26:7",className:"dg-card",children:[e.jsx(he,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:27:9",className:"pb-2",children:e.jsxs(ue,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:27:38",className:"text-sm flex items-center gap-2",children:[e.jsx(ys,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:27:93",className:"h-4 w-4 text-[var(--dg-orange)]"}),"HPA — 水平自动伸缩"]})}),e.jsx(Y,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:28:9",children:t.length===0?e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:30:13",className:"text-sm text-[var(--dg-text-muted)] py-4",children:["未关联 HPA — ",e.jsx(v,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:31:25",variant:"link",className:"h-auto p-0 text-[var(--dg-blue)] text-sm",children:"创建 HPA"})]}):e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:34:13",className:"overflow-x-auto",children:e.jsxs(Ge,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:35:15",children:[e.jsx(Ve,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:36:17",children:e.jsxs(Ee,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:37:19",className:"border-[var(--dg-border)]",children:[e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:38:21",className:"text-[var(--dg-text-muted)]",children:"名称"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:39:21",className:"text-[var(--dg-text-muted)]",children:"最小/最大"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:40:21",className:"text-[var(--dg-text-muted)]",children:"指标"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:41:21",className:"text-[var(--dg-text-muted)]",children:"当前负载"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:42:21",className:"text-[var(--dg-text-muted)]",children:"状态"})]})}),e.jsx(Fe,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:45:17",children:t.map((n,c)=>{const r=n.spec?.minReplicas??n.minReplicas??1,i=n.spec?.maxReplicas??n.maxReplicas??10,k=n.spec?.metrics||n.metrics||[],l=n.status?.currentReplicas??n.currentReplicas??0,C=(n.status?.conditions||n.conditions||[]).find(y=>y.type==="AbleToScale")?.status==="True";return e.jsxs(Ee,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:55:23",className:"border-[var(--dg-border)]",children:[e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:56:25",className:"font-medium text-[var(--dg-text-primary)]",children:n.name||n.metadata?.name}),e.jsxs(le,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:57:25",className:"text-sm text-[var(--dg-text-secondary)] font-mono",children:[r," → ",i]}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:58:25",className:"text-xs text-[var(--dg-text-muted)]",children:k.map((y,b)=>{const w=y.resource||y.object?.metric?.name||"",P=y.resource?.target?.averageUtilization||y.resource?.target?.averageValue||y.resource?.target?.type||"-";return e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:62:36",children:[w?.name||w,": ",P,y.resource?.target?.averageUtilization?"%":""]},b)})}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:65:25",className:"text-sm font-mono text-[var(--dg-text-secondary)]",children:l}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:66:25",children:e.jsx(ae,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:67:27",className:C?"bg-[var(--dg-green)]/20 text-[var(--dg-green)]":"bg-[var(--dg-red)]/20 text-[var(--dg-red)]",children:C?"正常":"异常"})})]},n.name||c)})})]})})})]}),e.jsxs(U,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:82:7",className:"dg-card",children:[e.jsx(he,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:83:9",className:"pb-2",children:e.jsxs(ue,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:83:38",className:"text-sm flex items-center gap-2",children:[e.jsx(vs,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:83:93",className:"h-4 w-4 text-[var(--dg-blue)]"}),"CronHPA — 定时伸缩"]})}),e.jsx(Y,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:84:9",children:s.length===0?e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:86:13",className:"text-sm text-[var(--dg-text-muted)] py-4",children:["未关联 CronHPA — ",e.jsx(v,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:87:29",variant:"link",className:"h-auto p-0 text-[var(--dg-blue)] text-sm",children:"创建 CronHPA"})]}):e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:90:13",className:"overflow-x-auto",children:e.jsxs(Ge,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:91:15",children:[e.jsx(Ve,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:92:17",children:e.jsxs(Ee,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:93:19",className:"border-[var(--dg-border)]",children:[e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:94:21",className:"text-[var(--dg-text-muted)]",children:"名称"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:95:21",className:"text-[var(--dg-text-muted)]",children:"目标副本"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:96:21",className:"text-[var(--dg-text-muted)]",children:"调度规则"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:97:21",className:"text-[var(--dg-text-muted)]",children:"时区"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:98:21",className:"text-[var(--dg-text-muted)]",children:"状态"})]})}),e.jsx(Fe,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:101:17",children:s.map((n,c)=>{const r=n.spec?.jobs||n.jobs||[],i=n.spec?.timezone||"UTC";return e.jsxs(Ee,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:106:23",className:"border-[var(--dg-border)]",children:[e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:107:25",className:"font-medium text-[var(--dg-text-primary)]",children:n.name||n.metadata?.name}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:108:25",className:"text-sm text-[var(--dg-text-secondary)]",children:r.map(k=>k.targetSize||k.targetReplicas||"?").join(", ")}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:111:25",className:"text-xs font-mono text-[var(--dg-text-muted)]",children:r.map(k=>k.schedule||"?").join(", ")}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:112:25",className:"text-xs text-[var(--dg-text-muted)]",children:i}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:113:25",children:e.jsx(ae,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:114:27",className:"bg-[var(--dg-green)]/20 text-[var(--dg-green)]",children:"已启用"})})]},n.name||c)})})]})})})]})]})}function Pn({revisions:t,rollbackLoading:s,onRollback:a}){return t.length===0?e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:13:12",className:"text-center text-[var(--dg-text-muted)] py-12",children:"暂无历史版本"}):e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:16:5",className:"overflow-x-auto",children:e.jsxs(Ge,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:17:7",children:[e.jsx(Ve,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:18:9",children:e.jsxs(Ee,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:19:11",className:"border-[var(--dg-border)]",children:[e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:20:13",className:"text-[var(--dg-text-muted)] w-24",children:"Revision"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:21:13",className:"text-[var(--dg-text-muted)]",children:"镜像"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:22:13",className:"text-[var(--dg-text-muted)] w-24",children:"状态"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:23:13",className:"text-[var(--dg-text-muted)] w-40",children:"更新时间"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:24:13",className:"text-[var(--dg-text-muted)] w-24",children:"操作"})]})}),e.jsx(Fe,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:27:9",children:t.map((o,n)=>{const c=o.revision??o.revision_number??o.number??n+1,r=n===0;return e.jsxs(Ee,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:32:15",className:"border-[var(--dg-border)]",children:[e.jsxs(le,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:33:17",className:"font-mono text-[var(--dg-text-primary)]",children:["#",c]}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:34:17",className:"text-xs font-mono text-[var(--dg-text-muted)] max-w-[300px] truncate",children:o.image||o.images?.[0]||"-"}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:35:17",children:r?e.jsx(ae,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:37:23",className:"bg-[var(--dg-green)]/20 text-[var(--dg-green)] border-[var(--dg-green)]/30",children:"当前"}):e.jsx(ae,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:38:23",variant:"outline",className:"text-[var(--dg-text-muted)]",children:"历史"})}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:40:17",className:"text-xs text-[var(--dg-text-muted)]",children:Pt(o.created_at||o.time)}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:41:17",children:e.jsxs(v,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:42:19",variant:"ghost",size:"sm",className:"h-7 text-amber-400",disabled:r||s!==null,onClick:()=>a(o),children:[s===c?e.jsx(ve,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:43:53",className:"h-3 w-3 animate-spin mr-1"}):e.jsx(tn,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:43:105",className:"h-3 w-3 mr-1"}),"回滚"]})})]},c)})})]})})}function An(t){const{clusterCode:s,namespace:a,deployment:o,pods:n,revisions:c,onRefresh:r}=t,{toast:i}=Me(),k=dt(),[l,x]=d.useState("pods"),[S,C]=d.useState(null),[y,b]=d.useState(null),[w,P]=d.useState(o?.replicas||0),[I,M]=d.useState(!1),[F,V]=d.useState([]),[X,q]=d.useState([]),[W,Q]=d.useState([]),[$,Z]=d.useState(""),[N,_]=d.useState([]),[J,ee]=d.useState([]),me=o?.ready_replicas??o?.readyReplicas??0,ye=o?.replicas??0,ge=me===ye&&ye>0;d.useEffect(()=>{l==="services"&&(Z("services"),Promise.all([K.getNamespaceServices(s,a).catch(()=>[]),K.getNamespaceIngresses(s,a).catch(()=>[])]).then(([u,A])=>{const L=B=>Array.isArray(B)?B:B?.list||B?.items||B?.data||[],m=L(u),g=L(A),j=o?.spec?.selector?.matchLabels||o?.spec?.template?.metadata?.labels||{},O=m.filter(B=>{const de=B.spec?.selector||B.selector||{};return Object.keys(de).length===0?!1:Object.entries(de).every(([De,Se])=>j[De]===Se)}).map(B=>({name:B.name||B.metadata?.name,type:B.spec?.type||B.type||"ClusterIP",clusterIP:B.spec?.clusterIP||B.cluster_ip||"<none>",ports:(B.spec?.ports||B.ports||[]).map(de=>`${de.port}${de.targetPort?":"+de.targetPort:""}/${de.protocol||"TCP"}`),selector:B.spec?.selector||B.selector||{},age:B.age||""})),xe=new Set(O.map(B=>B.name)),se=g.filter(B=>(B.spec?.rules||B.rules||[]).some(De=>(De.http?.paths||De.paths||[]).some(Se=>{const Ie=Se.backend?.service?.name||Se.backendService||"";return xe.has(Ie)}))).map(B=>({name:B.name||B.metadata?.name,className:B.spec?.ingressClassName||B.ingressClass||"-",hosts:(B.spec?.rules||B.rules||[]).map(de=>de.host).filter(Boolean),rules:B.spec?.rules||B.rules||[],age:B.age||""}));V(O),q(se)}).catch(()=>{}).finally(()=>Z("")))},[l,s,a,o]),d.useEffect(()=>{l==="events"&&(Z("events"),K.getEvents(s,a,void 0).then(u=>{const A=Array.isArray(u)?u:u?.list||u?.items||u?.data||[],L=o?.name||"",m=A.filter(g=>{const j=String(g.object||"");if(!L||!j)return!1;if(j.endsWith(`/${L}`))return!0;const O=j.split("/").pop()||"";return O===L||O.startsWith(`${L}-`)}).map(g=>Xs(g));Q(m)}).catch(()=>{}).finally(()=>Z("")))},[l,s,a,o?.name]),d.useEffect(()=>{l==="scale"&&(Z("scale"),Promise.all([K.getHPAs(s,a).catch(()=>[]),Promise.resolve([])]).then(([u])=>{const L=(g=>Array.isArray(g)?g:g?.list||g?.items||g?.data||[])(u),m=o?.name||"";_(L.filter(g=>(g.scaleTargetRef?.name||g.targetRef?.name||"")===m)),ee([])}).catch(()=>{}).finally(()=>Z("")))},[l,s,a,o?.name]);const R=async u=>{const A=u.revision??u.revision_number??u.number;if(await k({title:"回滚版本",description:`确认回滚到修订版本 #${A}?`,confirmText:"回滚",variant:"destructive"})){b(A);try{await K.rollbackDeployment(s,a,o.name,Number(A)),i({title:"回滚已下发",description:`正在回滚到 #${A}`}),r()}catch(m){i({title:"回滚失败",description:m?.message||String(m),variant:"destructive"})}finally{b(null)}}},p=async()=>{M(!0);try{await K.scaleDeployment(s,a,o.name,w),i({title:"伸缩已提交",description:`副本数 → ${w}`}),r()}catch(u){i({title:"伸缩失败",description:u?.message||String(u),variant:"destructive"})}finally{M(!1)}},h=[{key:"pods",label:"容器组",icon:Ue,count:n.length},{key:"services",label:"访问方式",icon:Ae,count:F.length},{key:"events",label:"事件",icon:ys,count:W.length},{key:"scale",label:"容器伸缩",icon:te},{key:"history",label:"历史版本",icon:sn,count:c.length}];return e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentView.tsx:178:5",className:"space-y-4",children:[e.jsx(U,{"code-path":"src/components/kubernetes/DeploymentView.tsx:180:7",className:"dg-card",children:e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentView.tsx:181:9",className:"p-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentView.tsx:182:11",className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3 text-sm",children:[e.jsx(Re,{"code-path":"src/components/kubernetes/DeploymentView.tsx:183:13",label:"状态",value:e.jsx(ae,{"code-path":"src/components/kubernetes/DeploymentView.tsx:184:15",style:{background:`${ge?Ce.green:Ce.orange}22`,color:ge?Ce.green:Ce.orange,border:`1px solid ${ge?Ce.green:Ce.orange}44`},children:ge?"Running":"Updating"})}),e.jsx(Re,{"code-path":"src/components/kubernetes/DeploymentView.tsx:188:13",label:"副本",value:e.jsxs("span",{"code-path":"src/components/kubernetes/DeploymentView.tsx:188:41",className:"font-mono",children:[me,"/",ye]})}),e.jsx(Re,{"code-path":"src/components/kubernetes/DeploymentView.tsx:189:13",label:"策略",value:o?.strategy||"RollingUpdate"}),n[0]&&e.jsxs(e.Fragment,{children:[e.jsx(Re,{"code-path":"src/components/kubernetes/DeploymentView.tsx:192:17",label:"所在节点",value:e.jsx("button",{"code-path":"src/components/kubernetes/DeploymentView.tsx:193:19",className:"text-[var(--dg-blue)] hover:underline",onClick:()=>window.open(`/kubernetes/${s}/nodes/${n[0].node_name||n[0].node}`,"_blank"),children:n[0].node_name||n[0].node||"-"})}),e.jsx(Re,{"code-path":"src/components/kubernetes/DeploymentView.tsx:197:17",label:"容器组 IP",value:e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentView.tsx:197:49",className:"font-mono",children:n[0].ip||n[0].pod_ip||"-"})})]}),e.jsx(Re,{"code-path":"src/components/kubernetes/DeploymentView.tsx:200:13",label:"创建时间",value:Pt(o?.created_at||o?.creationTimestamp)})]}),n.length===1&&e.jsx("div",{"code-path":"src/components/kubernetes/DeploymentView.tsx:203:13",className:"mt-3 pt-3 border-t border-[var(--dg-border)]",children:e.jsx(Es,{"code-path":"src/components/kubernetes/DeploymentView.tsx:204:15",pod:n[0]})})]})}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentView.tsx:211:7",className:"flex items-center gap-0.5 border-b border-[var(--dg-border)] overflow-x-auto",children:[h.map(u=>e.jsxs("button",{"code-path":"src/components/kubernetes/DeploymentView.tsx:213:11",className:`flex items-center gap-1.5 px-4 py-2.5 text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${l===u.key?"border-[var(--dg-blue)] text-[var(--dg-blue)]":"border-transparent text-[var(--dg-text-muted)] hover:text-[var(--dg-text-secondary)]"}`,onClick:()=>x(u.key),children:[e.jsx(u.icon,{"code-path":"src/components/kubernetes/DeploymentView.tsx:222:13",className:"h-4 w-4"}),u.label,u.key==="pods"&&e.jsx(ae,{"code-path":"src/components/kubernetes/DeploymentView.tsx:224:34",className:"ml-1 text-[10px] px-1.5 py-0 bg-[var(--dg-bg-tertiary)] text-[var(--dg-text-muted)]",children:u.count})]},u.key)),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentView.tsx:227:9",className:"ml-auto flex items-center gap-1 pr-2 shrink-0",children:[e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentView.tsx:228:11",variant:"ghost",size:"icon",className:"h-7 w-7 text-[var(--dg-text-muted)] hover:text-[var(--dg-text-primary)]",disabled:I||w<=0,onClick:()=>P(u=>Math.max(0,u-1)),children:e.jsx(Tt,{"code-path":"src/components/kubernetes/DeploymentView.tsx:231:13",className:"h-4 w-4"})}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentView.tsx:233:11",type:"number",min:0,value:w,onChange:u=>P(Math.max(0,Number(u.target.value))),className:"w-16 h-7 text-center text-sm font-bold bg-slate-800 border-slate-700 text-slate-200"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentView.tsx:238:11",variant:"ghost",size:"icon",className:"h-7 w-7 text-[var(--dg-text-muted)] hover:text-[var(--dg-text-primary)]",disabled:I,onClick:()=>P(u=>u+1),children:e.jsx(te,{"code-path":"src/components/kubernetes/DeploymentView.tsx:241:13",className:"h-4 w-4"})}),w!==ye&&e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentView.tsx:244:13",size:"sm",className:"h-7 text-xs bg-[var(--dg-blue)] hover:bg-[var(--dg-blue-hover)]",disabled:I,onClick:p,children:I?e.jsx(ve,{"code-path":"src/components/kubernetes/DeploymentView.tsx:246:31",className:"h-3 w-3 animate-spin"}):"应用"})]})]}),l==="pods"&&e.jsx(wn,{"code-path":"src/components/kubernetes/DeploymentView.tsx:253:26",...t,onDeletePod:t.onDeletePod,expandedPod:S,setExpandedPod:C}),l==="services"&&e.jsx(Cn,{"code-path":"src/components/kubernetes/DeploymentView.tsx:254:30",services:F,ingresses:X,loading:$,namespace:a}),l==="events"&&e.jsx(En,{"code-path":"src/components/kubernetes/DeploymentView.tsx:255:28",events:W,loading:$}),l==="scale"&&e.jsx(Dn,{"code-path":"src/components/kubernetes/DeploymentView.tsx:257:9",hpas:N,cronHpas:J,loading:$,replicas:ye}),l==="history"&&e.jsx(Pn,{"code-path":"src/components/kubernetes/DeploymentView.tsx:264:29",revisions:c,rollbackLoading:y,onRollback:R})]})}const Ds="_create";function It(t){return t===Ds}async function pt(t,s,a,o){const n=String(o?.metadata?.name||"").trim();if(!n)throw new Error("Deployment 名称不能为空");const c=await ms(o);return It(a)?await K.applyYAML(t,c):await K.updateResourceYaml(t,s,"deployments",n,c),n}function Ze(t){return!t||typeof t!="object"?[]:Object.entries(t).map(([s,a])=>({key:s,value:String(a)}))}function Oe(t){const s={};for(const{key:a,value:o}of t){const n=a.trim();n&&(s[n]=o)}return s}function Tn({clusterCode:t,namespace:s,deploymentName:a,manifest:o,onSaved:n,onCancel:c,isCreate:r=!1}){const{toast:i}=Me(),[k,l]=d.useState(!1),[x,S]=d.useState(!o),[C,y]=d.useState(o||{}),[b,w]=d.useState(o?.metadata?.name||""),[P,I]=d.useState(1),[M,F]=d.useState([]),[V,X]=d.useState([]),[q,W]=d.useState([]),[Q,$]=d.useState([]);d.useEffect(()=>{const m=o;if(!m){S(!1);return}y(m),w(m?.metadata?.name||""),I(m?.spec?.replicas??1),F(Ze(m?.metadata?.labels)),X(Ze(m?.metadata?.annotations)),W(Ze(m?.spec?.selector?.matchLabels)),$(Ze(m?.spec?.template?.metadata?.labels)),S(!1)},[o]);const Z=(m,g)=>{F(j=>j.map((O,xe)=>xe===m?{...O,...g}:O))},N=()=>F(m=>[...m,{key:"",value:""}]),_=m=>F(g=>g.filter((j,O)=>O!==m)),J=(m,g)=>{X(j=>j.map((O,xe)=>xe===m?{...O,...g}:O))},ee=()=>X(m=>[...m,{key:"",value:""}]),me=m=>X(g=>g.filter((j,O)=>O!==m)),ye=(m,g)=>{W(j=>j.map((O,xe)=>xe===m?{...O,...g}:O))},ge=()=>W(m=>[...m,{key:"",value:""}]),R=m=>W(g=>g.filter((j,O)=>O!==m)),p=(m,g)=>{$(j=>j.map((O,xe)=>xe===m?{...O,...g}:O))},h=()=>$(m=>[...m,{key:"",value:""}]),u=m=>$(g=>g.filter((j,O)=>O!==m)),A=()=>{const m=Oe(q);$(g=>{const j={...Oe(g),...m};return Object.entries(j).map(([O,xe])=>({key:O,value:xe}))}),i({title:"已同步",description:"Selector 标签已合并到 Pod 模板标签"})},L=async()=>{l(!0);try{const m=JSON.parse(JSON.stringify(C));m.spec=m.spec||{},m.spec.replicas=P;const g=Oe(M);if(m.metadata=m.metadata||{},r){const B=b.trim();if(!B)throw new Error("名称不能为空");m.metadata.name=B,m.metadata.namespace=s}m.metadata.labels=Object.keys(g).length>0?g:void 0;const j=Oe(V);m.metadata.annotations=Object.keys(j).length>0?j:void 0;const O=Oe(q);Object.keys(O).length>0&&(m.spec.selector=m.spec.selector||{},m.spec.selector.matchLabels=O);const xe=Oe(Q);m.spec.template=m.spec.template||{},m.spec.template.metadata=m.spec.template.metadata||{},Object.keys(xe).length>0?m.spec.template.metadata.labels=xe:delete m.spec.template.metadata.labels;const se=await pt(t,s,a,m);i({title:r?"创建成功":"基本信息已保存",description:r?`${se} 已创建`:`${se} 更新已提交`}),n(m)}catch(m){i({title:"保存失败",description:m?.message||String(m),variant:"destructive"})}finally{l(!1)}};return x?e.jsx(U,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:139:7",className:"bg-slate-900 border-slate-800",children:e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:140:9",className:"p-12 text-center",children:[e.jsx(ve,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:141:11",className:"h-6 w-6 animate-spin mx-auto text-slate-500"}),e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:142:11",className:"text-slate-500 mt-3 text-sm",children:"加载中..."})]})}):o?e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:159:5",className:"space-y-4",children:[e.jsxs(U,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:161:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:162:9",className:"pb-3",children:e.jsxs(ue,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:163:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(nn,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:164:13",className:"h-4 w-4 text-blue-400"}),"副本数 (Replicas)"]})}),e.jsx(Y,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:168:9",className:"pt-0",children:e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:169:11",className:"flex items-center gap-3",children:[e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:170:13",type:"number",min:0,value:P,onChange:m=>I(Math.max(0,Number(m.target.value)||0)),className:"w-32 bg-slate-800 border-slate-700 text-slate-200"}),e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:177:13",className:"text-xs text-slate-500",children:"期望运行的 Pod 实例数量"})]})})]}),e.jsxs(U,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:183:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:184:9",className:"pb-3",children:e.jsxs(ue,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:185:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(ks,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:186:13",className:"h-4 w-4 text-slate-500"}),r?"基本标识":"基本标识(只读)"]})}),e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:190:9",className:"pt-0 grid grid-cols-2 gap-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:191:11",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:192:13",className:"text-slate-400 text-xs",children:"名称 (name)"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:193:13",value:r?b:a,readOnly:!r,onChange:m=>r&&w(m.target.value),className:`mt-1 font-mono text-sm ${r?"bg-slate-800 border-slate-700 text-slate-200":"bg-slate-950 border-slate-800 text-slate-500 cursor-not-allowed"}`})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:200:11",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:201:13",className:"text-slate-400 text-xs",children:"命名空间 (namespace)"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:202:13",value:s,readOnly:!0,className:"mt-1 bg-slate-950 border-slate-800 text-slate-500 font-mono text-sm cursor-not-allowed"})]})]})]}),e.jsxs(U,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:209:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:210:9",className:"pb-3",children:e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:211:11",className:"flex items-center justify-between",children:[e.jsxs(ue,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:212:13",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(gt,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:213:15",className:"h-4 w-4 text-emerald-400"}),"标签 (Labels)",e.jsx(ae,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:215:15",variant:"outline",className:"border-slate-700 text-slate-500 text-[10px]",children:M.length})]}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:217:13",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:N,children:[e.jsx(te,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:218:15",className:"h-3 w-3 mr-1"}),"新增"]})]})}),e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:222:9",className:"pt-0 space-y-1.5",children:[M.length===0&&e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:223:35",className:"text-[11px] text-slate-600",children:"无标签"}),M.map((m,g)=>e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:225:13",className:"grid grid-cols-[1fr_1.4fr_auto] gap-2",children:[e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:226:15",value:m.key,placeholder:"app",onChange:j=>Z(g,{key:j.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:229:15",value:m.value,placeholder:"nginx",onChange:j=>Z(g,{value:j.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:232:15",variant:"ghost",size:"icon",className:"h-8 w-8 text-red-400 hover:text-red-300",onClick:()=>_(g),children:e.jsx(be,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:233:48",className:"h-3.5 w-3.5"})})]},g))]})]}),e.jsxs(U,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:240:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:241:9",className:"pb-3",children:e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:242:11",className:"flex items-center justify-between",children:[e.jsxs(ue,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:243:13",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(gt,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:244:15",className:"h-4 w-4 text-amber-400"}),"选择器 (Selector)",e.jsx(ae,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:246:15",variant:"outline",className:"border-amber-700/50 text-amber-500 text-[10px]",children:"⚠️ 需与模板标签一致"})]}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:248:13",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:ge,children:[e.jsx(te,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:249:15",className:"h-3 w-3 mr-1"}),"新增"]})]})}),e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:253:9",className:"pt-0 space-y-1.5",children:[e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:254:11",className:"text-[11px] text-amber-500/70 mb-1",children:"Selector 决定哪些 Pod 归属此 Deployment。修改时必须确保与 Pod Template Labels 匹配,否则 Deployment 将无法管理 Pod。"}),q.length===0&&e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:255:43",className:"text-[11px] text-slate-600",children:"无选择器"}),q.map((m,g)=>e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:257:13",className:"grid grid-cols-[1fr_1.4fr_auto] gap-2",children:[e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:258:15",value:m.key,placeholder:"app",onChange:j=>ye(g,{key:j.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:261:15",value:m.value,placeholder:"nginx",onChange:j=>ye(g,{value:j.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:264:15",variant:"ghost",size:"icon",className:"h-8 w-8 text-red-400 hover:text-red-300",onClick:()=>R(g),children:e.jsx(be,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:265:51",className:"h-3.5 w-3.5"})})]},g))]})]}),e.jsxs(U,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:272:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:273:9",className:"pb-3",children:e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:274:11",className:"flex items-center justify-between",children:[e.jsxs(ue,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:275:13",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(gt,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:276:15",className:"h-4 w-4 text-cyan-400"}),"Pod 模板标签 (template.metadata.labels)"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:279:13",className:"flex gap-1",children:[e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:280:15",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:A,children:"从 Selector 同步"}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:283:15",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:h,children:[e.jsx(te,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:284:17",className:"h-3 w-3 mr-1"}),"新增"]})]})]})}),e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:289:9",className:"pt-0 space-y-1.5",children:[e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:290:11",className:"text-[11px] text-slate-600 mb-1",children:"Pod 模板标签必须包含 Selector 全部键值,否则 Deployment 无法管理 Pod"}),Q.length===0&&e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:291:43",className:"text-[11px] text-slate-600",children:"无模板标签"}),Q.map((m,g)=>e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:293:13",className:"grid grid-cols-[1fr_1.4fr_auto] gap-2",children:[e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:294:15",value:m.key,placeholder:"app",onChange:j=>p(g,{key:j.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:297:15",value:m.value,placeholder:"nginx",onChange:j=>p(g,{value:j.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:300:15",variant:"ghost",size:"icon",className:"h-8 w-8 text-red-400 hover:text-red-300",onClick:()=>u(g),children:e.jsx(be,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:301:56",className:"h-3.5 w-3.5"})})]},g))]})]}),e.jsxs(U,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:308:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:309:9",className:"pb-3",children:e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:310:11",className:"flex items-center justify-between",children:[e.jsxs(ue,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:311:13",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(At,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:312:15",className:"h-4 w-4 text-purple-400"}),"注解 (Annotations)",e.jsx(ae,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:314:15",variant:"outline",className:"border-slate-700 text-slate-500 text-[10px]",children:V.length})]}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:316:13",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:ee,children:[e.jsx(te,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:317:15",className:"h-3 w-3 mr-1"}),"新增"]})]})}),e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:321:9",className:"pt-0 space-y-1.5",children:[V.length===0&&e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:322:40",className:"text-[11px] text-slate-600",children:"无注解"}),V.map((m,g)=>e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:324:13",className:"grid grid-cols-[1fr_1.4fr_auto] gap-2",children:[e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:325:15",value:m.key,placeholder:"deployment.kubernetes.io/revision",onChange:j=>J(g,{key:j.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:328:15",value:m.value,placeholder:"1",onChange:j=>J(g,{value:j.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:331:15",variant:"ghost",size:"icon",className:"h-8 w-8 text-red-400 hover:text-red-300",onClick:()=>me(g),children:e.jsx(be,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:332:53",className:"h-3.5 w-3.5"})})]},g))]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:339:7",className:"sticky bottom-0 bg-slate-950/80 backdrop-blur border-t border-slate-800 p-3 flex items-center justify-between",children:[e.jsxs("p",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:340:9",className:"text-[11px] text-slate-500",children:["保存将通过 ",e.jsx("code",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:341:17",className:"text-slate-400",children:"PUT application/yaml"})," 提交(自动剥离 status/managedFields 等只读字段)"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:343:9",className:"flex gap-2",children:[e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:344:11",variant:"outline",className:"border-slate-700 text-slate-400",onClick:c,children:"取消"}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:345:11",className:"bg-blue-600 hover:bg-blue-700",disabled:k,onClick:L,children:[k?e.jsx(ve,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:346:23",className:"h-4 w-4 animate-spin mr-1"}):e.jsx(it,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:346:75",className:"h-4 w-4 mr-1"}),"保存"]})]})]})]}):e.jsx(U,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:150:7",className:"bg-slate-900 border-slate-800",children:e.jsx(Y,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:151:9",className:"p-8 text-center text-slate-500",children:"未获取到 manifest 数据,请使用 YAML 编辑模式直接修改。"})})}function Xt(t){const s=n=>{if(!n)return null;let c="none";return n.httpGet?c="httpGet":n.tcpSocket?c="tcpSocket":n.exec&&(c="exec"),{type:c,httpPath:n.httpGet?.path||"",httpPort:n.httpGet?.port??"",httpHost:n.httpGet?.host||"",tcpPort:n.tcpSocket?.port??"",execCommand:Array.isArray(n.exec?.command)?n.exec.command.join(`
|
||
`):n.exec?.command||"",initialDelaySeconds:n.initialDelaySeconds,periodSeconds:n.periodSeconds,timeoutSeconds:n.timeoutSeconds,successThreshold:n.successThreshold,failureThreshold:n.failureThreshold}},a=n=>{if(!n)return{type:"none"};let c="none";return n.exec?c="exec":n.httpGet?c="httpGet":n.tcpSocket&&(c="tcpSocket"),{type:c,execCommand:Array.isArray(n.exec?.command)?n.exec.command.join(`
|
||
`):"",httpPath:n.httpGet?.path||"",httpPort:n.httpGet?.port??"",tcpPort:n.tcpSocket?.port??""}},o=t.securityContext;return{name:t.name||"",image:t.image||"",imagePullPolicy:t.imagePullPolicy||"",command:Array.isArray(t.command)?t.command:[],args:Array.isArray(t.args)?t.args:[],workingDir:t.workingDir||"",env:(Array.isArray(t.env)?t.env:[]).map(n=>({name:n.name||"",value:n.value??""})),ports:(Array.isArray(t.ports)?t.ports:[]).map(n=>({name:n.name||"",containerPort:n.containerPort??"",protocol:n.protocol||"TCP"})),resources:{requests:t.resources?.requests||{},limits:t.resources?.limits||{}},livenessProbe:s(t.livenessProbe),readinessProbe:s(t.readinessProbe),startupProbe:s(t.startupProbe),lifecycle:t.lifecycle?{postStart:t.lifecycle.postStart?a(t.lifecycle.postStart):void 0,preStop:t.lifecycle.preStop?a(t.lifecycle.preStop):void 0}:null,securityContext:o?{runAsUser:o.runAsUser,runAsGroup:o.runAsGroup,runAsNonRoot:o.runAsNonRoot,privileged:o.privileged,readOnlyRootFilesystem:o.readOnlyRootFilesystem,allowPrivilegeEscalation:o.allowPrivilegeEscalation,capabilitiesAdd:o.capabilities?.add||[],capabilitiesDrop:o.capabilities?.drop||[]}:null,volumeMounts:(Array.isArray(t.volumeMounts)?t.volumeMounts:[]).map(n=>({name:n.name||"",mountPath:n.mountPath||"",subPath:n.subPath||"",readOnly:n.readOnly||!1}))}}function Qt(t=""){return{name:t,image:"",imagePullPolicy:"IfNotPresent",command:[],args:[],workingDir:"",env:[],ports:[],resources:{},livenessProbe:null,readinessProbe:null,startupProbe:null,lifecycle:null,securityContext:null,volumeMounts:[]}}function ft(t){if(!t||t.type==="none"||!t.type)return;const s={};if(t.type==="httpGet")s.httpGet={},t.httpPath&&(s.httpGet.path=t.httpPath),t.httpPort!==""&&t.httpPort!=null&&(s.httpGet.port=typeof t.httpPort=="number"?t.httpPort:Number(t.httpPort)),t.httpHost&&(s.httpGet.host=t.httpHost);else if(t.type==="tcpSocket")s.tcpSocket={},t.tcpPort!==""&&t.tcpPort!=null&&(s.tcpSocket.port=typeof t.tcpPort=="number"?t.tcpPort:Number(t.tcpPort));else if(t.type==="exec"){const a=(t.execCommand||"").split(`
|
||
`).map(o=>o.trim()).filter(Boolean);a.length&&(s.exec={command:a})}return t.initialDelaySeconds!=null&&(s.initialDelaySeconds=t.initialDelaySeconds),t.periodSeconds!=null&&(s.periodSeconds=t.periodSeconds),t.timeoutSeconds!=null&&(s.timeoutSeconds=t.timeoutSeconds),t.successThreshold!=null&&(s.successThreshold=t.successThreshold),t.failureThreshold!=null&&(s.failureThreshold=t.failureThreshold),Object.keys(s).length>0?s:void 0}function Zt(t){if(!(!t||t.type==="none"||!t.type)){if(t.type==="exec"){const s=(t.execCommand||"").split(`
|
||
`).map(a=>a.trim()).filter(Boolean);return s.length?{exec:{command:s}}:void 0}if(t.type==="httpGet"){const s={httpGet:{}};return t.httpPath&&(s.httpGet.path=t.httpPath),t.httpPort!==""&&t.httpPort!=null&&(s.httpGet.port=Number(t.httpPort)),s}if(t.type==="tcpSocket"){const s={tcpSocket:{}};return t.tcpPort!==""&&t.tcpPort!=null&&(s.tcpSocket.port=Number(t.tcpPort)),s}}}function es(t){const s={name:t.name};t.image&&(s.image=t.image),t.imagePullPolicy&&(s.imagePullPolicy=t.imagePullPolicy),t.workingDir&&(s.workingDir=t.workingDir),t.command.length>0&&(s.command=t.command),t.args.length>0&&(s.args=t.args),t.env.length>0&&(s.env=t.env.filter(l=>l.name.trim()).map(l=>{const x={name:l.name};return l.value!=null&&(x.value=l.value),x})),t.ports.length>0&&(s.ports=t.ports.filter(l=>l.containerPort!=="").map(l=>{const x={containerPort:typeof l.containerPort=="number"?l.containerPort:Number(l.containerPort)};return l.name&&(x.name=l.name),l.protocol&&(x.protocol=l.protocol),x}));const a=t.resources.requests,o=t.resources.limits,n=a&&Object.values(a).some(l=>l&&l.trim()),c=o&&Object.values(o).some(l=>l&&l.trim());(n||c)&&(s.resources={},n&&(s.resources.requests={},a.cpu?.trim()&&(s.resources.requests.cpu=a.cpu),a.memory?.trim()&&(s.resources.requests.memory=a.memory)),c&&(s.resources.limits={},o.cpu?.trim()&&(s.resources.limits.cpu=o.cpu),o.memory?.trim()&&(s.resources.limits.memory=o.memory)));const r=ft(t.livenessProbe);r&&(s.livenessProbe=r);const i=ft(t.readinessProbe);i&&(s.readinessProbe=i);const k=ft(t.startupProbe);if(k&&(s.startupProbe=k),t.lifecycle){const l={},x=Zt(t.lifecycle.postStart);x&&(l.postStart=x);const S=Zt(t.lifecycle.preStop);S&&(l.preStop=S),Object.keys(l).length>0&&(s.lifecycle=l)}if(t.securityContext){const l=t.securityContext,x={};l.runAsUser!==""&&l.runAsUser!=null&&(x.runAsUser=Number(l.runAsUser)),l.runAsGroup!==""&&l.runAsGroup!=null&&(x.runAsGroup=Number(l.runAsGroup)),l.runAsNonRoot!=null&&(x.runAsNonRoot=l.runAsNonRoot),l.privileged!=null&&(x.privileged=l.privileged),l.readOnlyRootFilesystem!=null&&(x.readOnlyRootFilesystem=l.readOnlyRootFilesystem),l.allowPrivilegeEscalation!=null&&(x.allowPrivilegeEscalation=l.allowPrivilegeEscalation);const S=(l.capabilitiesAdd||[]).filter(Boolean),C=(l.capabilitiesDrop||[]).filter(Boolean);(S.length||C.length)&&(x.capabilities={},S.length&&(x.capabilities.add=S),C.length&&(x.capabilities.drop=C)),Object.keys(x).length>0&&(s.securityContext=x)}return t.volumeMounts.length>0&&(s.volumeMounts=t.volumeMounts.filter(l=>l.name.trim()&&l.mountPath.trim()).map(l=>{const x={name:l.name,mountPath:l.mountPath};return l.subPath&&(x.subPath=l.subPath),l.readOnly&&(x.readOnly=!0),x})),s}function ts(t){return t.join(`
|
||
`)}function ss(t){return t.split(`
|
||
`).map(s=>s.trim()).filter(Boolean)}function Mn({container:t,onUpdate:s}){const a=t,o="flex items-center gap-1.5 text-xs font-semibold text-slate-300 mb-2";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:36:7",className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:37:9",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:38:11",className:"text-slate-400 text-xs",children:"容器名称"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:39:11",value:a.name,onChange:n=>s({name:n.target.value}),placeholder:"my-app",className:"mt-1 bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:43:9",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:44:11",className:"text-slate-400 text-xs",children:"容器镜像"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:45:11",value:a.image,onChange:n=>s({image:n.target.value}),placeholder:"nginx:1.25",className:"mt-1 bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:49:9",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:50:11",className:"text-slate-400 text-xs",children:"镜像拉取策略"}),e.jsxs(nt,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:51:11",value:a.imagePullPolicy||"__none",onValueChange:n=>s({imagePullPolicy:n==="__none"?"":n}),children:[e.jsx(ot,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:52:13",className:"mt-1 bg-slate-800 border-slate-700 text-slate-200 text-xs h-8",children:e.jsx(at,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:53:15"})}),e.jsxs(rt,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:55:13",className:"bg-slate-900 border-slate-700",children:[e.jsx(fe,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:56:15",value:"__none",className:"text-slate-400",children:"不设置(默认 IfNotPresent)"}),e.jsx(fe,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:57:15",value:"Always",className:"text-slate-200",children:"Always"}),e.jsx(fe,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:58:15",value:"IfNotPresent",className:"text-slate-200",children:"IfNotPresent"}),e.jsx(fe,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:59:15",value:"Never",className:"text-slate-200",children:"Never"})]})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:63:9",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:64:11",className:"text-slate-400 text-xs",children:"工作目录 (workingDir)"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:65:11",value:a.workingDir||"",onChange:n=>s({workingDir:n.target.value}),placeholder:"/app",className:"mt-1 bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:72:7",className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:73:9",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:74:11",className:"text-slate-400 text-xs",children:"启动命令 (command) — 每行一个"}),e.jsx(st,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:75:11",value:ts(a.command),placeholder:`/bin/sh
|
||
-c`,onChange:n=>s({command:ss(n.target.value)}),className:"mt-1 bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs min-h-[60px]"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:79:9",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:80:11",className:"text-slate-400 text-xs",children:"启动参数 (args) — 每行一个"}),e.jsx(st,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:81:11",value:ts(a.args),placeholder:`--config=/etc/app.yaml
|
||
--debug`,onChange:n=>s({args:ss(n.target.value)}),className:"mt-1 bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs min-h-[60px]"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:88:7",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:89:9",className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:90:11",className:o,children:[e.jsx(us,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:90:39",className:"h-3.5 w-3.5 text-cyan-400"})," 环境变量"]}),e.jsxs(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:91:11",size:"sm",variant:"outline",className:"h-6 border-slate-700 text-slate-300 text-[11px]",onClick:()=>s({env:[...a.env,{name:"",value:""}]}),children:[e.jsx(te,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:93:13",className:"h-3 w-3 mr-1"}),"新增"]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:96:9",className:"space-y-1.5",children:[a.env.map((n,c)=>e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:98:13",className:"grid grid-cols-[1fr_1.4fr_auto] gap-2",children:[e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:99:15",value:n.name,placeholder:"KEY",onChange:r=>{const i=[...a.env];i[c]={...n,name:r.target.value},s({env:i})},className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:102:15",value:n.value||"",placeholder:"value",onChange:r=>{const i=[...a.env];i[c]={...n,value:r.target.value},s({env:i})},className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:105:15",variant:"ghost",size:"icon",className:"h-8 w-8 text-red-400",onClick:()=>s({env:a.env.filter((r,i)=>i!==c)}),children:e.jsx(be,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:107:17",className:"h-3.5 w-3.5"})})]},c)),a.env.length===0&&e.jsx("p",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:111:34",className:"text-[11px] text-slate-600",children:"无环境变量"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:116:7",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:117:9",className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:118:11",className:o,children:[e.jsx(Ae,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:118:39",className:"h-3.5 w-3.5 text-indigo-400"})," 端口"]}),e.jsxs(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:119:11",size:"sm",variant:"outline",className:"h-6 border-slate-700 text-slate-300 text-[11px]",onClick:()=>s({ports:[...a.ports,{name:"",containerPort:"",protocol:"TCP"}]}),children:[e.jsx(te,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:121:13",className:"h-3 w-3 mr-1"}),"新增"]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:124:9",className:"space-y-1.5",children:[a.ports.map((n,c)=>e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:126:13",className:"grid grid-cols-[1fr_1fr_100px_auto] gap-2",children:[e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:127:15",value:n.name||"",placeholder:"http",onChange:r=>{const i=[...a.ports];i[c]={...n,name:r.target.value},s({ports:i})},className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:130:15",type:"number",value:n.containerPort,placeholder:"8080",onChange:r=>{const i=[...a.ports];i[c]={...n,containerPort:r.target.value},s({ports:i})},className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsxs(nt,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:133:15",value:n.protocol||"TCP",onValueChange:r=>{const i=[...a.ports];i[c]={...n,protocol:r},s({ports:i})},children:[e.jsx(ot,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:134:17",className:"bg-slate-800 border-slate-700 text-slate-200 text-xs h-8",children:e.jsx(at,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:135:19"})}),e.jsxs(rt,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:137:17",className:"bg-slate-900 border-slate-700",children:[e.jsx(fe,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:138:19",value:"TCP",className:"text-slate-200",children:"TCP"}),e.jsx(fe,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:139:19",value:"UDP",className:"text-slate-200",children:"UDP"}),e.jsx(fe,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:140:19",value:"SCTP",className:"text-slate-200",children:"SCTP"})]})]}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:143:15",variant:"ghost",size:"icon",className:"h-8 w-8 text-red-400",onClick:()=>s({ports:a.ports.filter((r,i)=>i!==c)}),children:e.jsx(be,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:145:17",className:"h-3.5 w-3.5"})})]},c)),a.ports.length===0&&e.jsx("p",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:149:36",className:"text-[11px] text-slate-600",children:"无端口暴露"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:154:7",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:155:9",className:o,children:[e.jsx(on,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:155:37",className:"h-3.5 w-3.5 text-amber-400"})," 资源 (requests / limits)"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:156:9",className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:157:11",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:158:13",className:"text-[11px] text-slate-500",children:"CPU 请求"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:159:13",value:a.resources.requests?.cpu||"",placeholder:"100m",onChange:n=>s({resources:{...a.resources,requests:{...a.resources.requests,cpu:n.target.value}}}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:163:11",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:164:13",className:"text-[11px] text-slate-500",children:"CPU 上限"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:165:13",value:a.resources.limits?.cpu||"",placeholder:"500m",onChange:n=>s({resources:{...a.resources,limits:{...a.resources.limits,cpu:n.target.value}}}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:169:11",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:170:13",className:"text-[11px] text-slate-500",children:"内存请求"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:171:13",value:a.resources.requests?.memory||"",placeholder:"128Mi",onChange:n=>s({resources:{...a.resources,requests:{...a.resources.requests,memory:n.target.value}}}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:175:11",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:176:13",className:"text-[11px] text-slate-500",children:"内存上限"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:177:13",value:a.resources.limits?.memory||"",placeholder:"512Mi",onChange:n=>s({resources:{...a.resources,limits:{...a.resources.limits,memory:n.target.value}}}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:185:7",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:186:9",className:o,children:[e.jsx(an,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:186:37",className:"h-3.5 w-3.5 text-rose-400"})," 健康检查 (Probes)"]}),e.jsx("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:187:9",className:"space-y-2",children:["livenessProbe","readinessProbe","startupProbe"].map(n=>e.jsx(Hn,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:189:13",label:{livenessProbe:"存活探针 (liveness)",readinessProbe:"就绪探针 (readiness)",startupProbe:"启动探针 (startup)"}[n],probe:a[n],onChange:c=>s({[n]:c})},n))})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:199:7",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:200:9",className:o,children:[e.jsx(gs,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:200:37",className:"h-3.5 w-3.5 text-yellow-400"})," 生命周期回调 (Lifecycle)"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:201:9",className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsx(ns,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:202:11",label:"启动后 (postStart)",handler:a.lifecycle?.postStart,onChange:n=>s({lifecycle:{...a.lifecycle,postStart:n}})}),e.jsx(ns,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:204:11",label:"终止前 (preStop)",handler:a.lifecycle?.preStop,onChange:n=>s({lifecycle:{...a.lifecycle,preStop:n}})})]}),!a.lifecycle&&e.jsxs(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:208:11",size:"sm",variant:"outline",className:"h-6 border-slate-700 text-slate-300 text-[11px] mt-1",onClick:()=>s({lifecycle:{postStart:{type:"none"},preStop:{type:"none"}}}),children:[e.jsx(te,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:210:13",className:"h-3 w-3 mr-1"}),"启用生命周期回调"]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:216:7",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:217:9",className:o,children:[e.jsx(js,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:217:37",className:"h-3.5 w-3.5 text-emerald-400"})," 安全上下文 (SecurityContext)"]}),a.securityContext?e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:219:11",className:"space-y-2 border border-slate-800 rounded-md p-3 bg-slate-950/30",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:220:13",className:"grid grid-cols-2 md:grid-cols-3 gap-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:221:15",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:222:17",className:"text-[11px] text-slate-500",children:"runAsUser"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:223:17",type:"number",value:a.securityContext.runAsUser??"",placeholder:"1000",onChange:n=>s({securityContext:{...a.securityContext,runAsUser:n.target.value===""?void 0:Number(n.target.value)}}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:227:15",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:228:17",className:"text-[11px] text-slate-500",children:"runAsGroup"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:229:17",type:"number",value:a.securityContext.runAsGroup??"",placeholder:"1000",onChange:n=>s({securityContext:{...a.securityContext,runAsGroup:n.target.value===""?void 0:Number(n.target.value)}}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:233:15",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:234:17",className:"text-[11px] text-slate-500",children:"Capabilities Add (逗号分隔)"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:235:17",value:(a.securityContext.capabilitiesAdd||[]).join(","),placeholder:"NET_ADMIN",onChange:n=>s({securityContext:{...a.securityContext,capabilitiesAdd:n.target.value.split(",").map(c=>c.trim()).filter(Boolean)}}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:239:15",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:240:17",className:"text-[11px] text-slate-500",children:"Capabilities Drop (逗号分隔)"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:241:17",value:(a.securityContext.capabilitiesDrop||[]).join(","),placeholder:"ALL",onChange:n=>s({securityContext:{...a.securityContext,capabilitiesDrop:n.target.value.split(",").map(c=>c.trim()).filter(Boolean)}}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:246:13",className:"flex items-center gap-4 flex-wrap",children:[e.jsx(et,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:247:15",label:"runAsNonRoot",value:!!a.securityContext.runAsNonRoot,onChange:n=>s({securityContext:{...a.securityContext,runAsNonRoot:n}})}),e.jsx(et,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:249:15",label:"privileged",value:!!a.securityContext.privileged,onChange:n=>s({securityContext:{...a.securityContext,privileged:n}})}),e.jsx(et,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:251:15",label:"readOnlyRootFilesystem",value:!!a.securityContext.readOnlyRootFilesystem,onChange:n=>s({securityContext:{...a.securityContext,readOnlyRootFilesystem:n}})}),e.jsx(et,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:253:15",label:"allowPrivilegeEscalation",value:a.securityContext.allowPrivilegeEscalation??!1,onChange:n=>s({securityContext:{...a.securityContext,allowPrivilegeEscalation:n}})})]}),e.jsxs(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:256:13",size:"sm",variant:"ghost",className:"h-6 text-red-400 text-[11px]",onClick:()=>s({securityContext:null}),children:[e.jsx(be,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:258:15",className:"h-3 w-3 mr-1"}),"移除安全上下文"]})]}):e.jsxs(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:262:11",size:"sm",variant:"outline",className:"h-6 border-slate-700 text-slate-300 text-[11px]",onClick:()=>s({securityContext:{runAsNonRoot:!1,privileged:!1}}),children:[e.jsx(te,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:264:13",className:"h-3 w-3 mr-1"}),"启用安全上下文"]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:270:7",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:271:9",className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:272:11",className:o,children:[e.jsx(rn,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:272:39",className:"h-3.5 w-3.5 text-teal-400"})," 卷挂载 (VolumeMounts)"]}),e.jsxs(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:273:11",size:"sm",variant:"outline",className:"h-6 border-slate-700 text-slate-300 text-[11px]",onClick:()=>s({volumeMounts:[...a.volumeMounts,{name:"",mountPath:"",subPath:"",readOnly:!1}]}),children:[e.jsx(te,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:275:13",className:"h-3 w-3 mr-1"}),"新增"]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:278:9",className:"space-y-1.5",children:[a.volumeMounts.map((n,c)=>e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:280:13",className:"grid grid-cols-[1fr_1fr_1fr_60px_auto] gap-2 items-center",children:[e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:281:15",value:n.name,placeholder:"volume 名称",onChange:r=>{const i=[...a.volumeMounts];i[c]={...n,name:r.target.value},s({volumeMounts:i})},className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:284:15",value:n.mountPath,placeholder:"/data",onChange:r=>{const i=[...a.volumeMounts];i[c]={...n,mountPath:r.target.value},s({volumeMounts:i})},className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:287:15",value:n.subPath||"",placeholder:"subPath (可选)",onChange:r=>{const i=[...a.volumeMounts];i[c]={...n,subPath:r.target.value},s({volumeMounts:i})},className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsxs("label",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:290:15",className:"flex items-center gap-1 text-[10px] text-slate-500 cursor-pointer",children:[e.jsx(Ht,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:291:17",checked:!!n.readOnly,onCheckedChange:r=>{const i=[...a.volumeMounts];i[c]={...n,readOnly:r},s({volumeMounts:i})}}),"RO"]}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:295:15",variant:"ghost",size:"icon",className:"h-8 w-8 text-red-400",onClick:()=>s({volumeMounts:a.volumeMounts.filter((r,i)=>i!==c)}),children:e.jsx(be,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:297:17",className:"h-3.5 w-3.5"})})]},c)),a.volumeMounts.length===0&&e.jsx("p",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:301:43",className:"text-[11px] text-slate-600",children:"无卷挂载"})]})]})]})}function Hn({label:t,probe:s,onChange:a}){const o=!!s,n=s||{type:"httpGet"},c=r=>a({...n,...r});return e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:315:5",className:"border border-slate-800 rounded-md p-2.5 bg-slate-950/30",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:316:7",className:"flex items-center justify-between mb-2",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:317:9",className:"text-xs text-slate-300 font-medium",children:t}),e.jsx(Ht,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:318:9",checked:o,onCheckedChange:r=>a(r?{type:"httpGet",httpPath:"/",httpPort:8080,initialDelaySeconds:10,periodSeconds:10}:null)})]}),o&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:323:11",className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:324:13",className:"text-[10px] text-slate-500 w-8",children:"类型"}),e.jsxs(nt,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:325:13",value:n.type||"httpGet",onValueChange:r=>c({type:r}),children:[e.jsx(ot,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:326:15",className:"bg-slate-800 border-slate-700 text-slate-200 text-xs h-7 flex-1",children:e.jsx(at,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:327:17"})}),e.jsxs(rt,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:329:15",className:"bg-slate-900 border-slate-700",children:[e.jsx(fe,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:330:17",value:"httpGet",className:"text-slate-200",children:"HTTP GET"}),e.jsx(fe,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:331:17",value:"tcpSocket",className:"text-slate-200",children:"TCP Socket"}),e.jsx(fe,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:332:17",value:"exec",className:"text-slate-200",children:"Exec 命令"})]})]})]}),n.type==="httpGet"&&e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:337:13",className:"grid grid-cols-3 gap-2 mb-2",children:[e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:338:15",value:n.httpPath||"",placeholder:"/healthz",onChange:r=>c({httpPath:r.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:341:15",type:"number",value:n.httpPort??"",placeholder:"8080",onChange:r=>c({httpPort:r.target.value===""?void 0:Number(r.target.value)}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:344:15",value:n.httpHost||"",placeholder:"host (可选)",onChange:r=>c({httpHost:r.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"})]}),n.type==="tcpSocket"&&e.jsx("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:350:13",className:"mb-2",children:e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:351:15",type:"number",value:n.tcpPort??"",placeholder:"端口",onChange:r=>c({tcpPort:r.target.value===""?void 0:Number(r.target.value)}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"})}),n.type==="exec"&&e.jsx("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:357:13",className:"mb-2",children:e.jsx(st,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:358:15",value:n.execCommand||"",placeholder:"每行一个命令片段,如:\\ncat\\n/tmp/healthy",onChange:r=>c({execCommand:r.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs min-h-[50px]"})}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:363:11",className:"grid grid-cols-5 gap-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:364:13",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:365:15",className:"text-[10px] text-slate-500",children:"延迟(s)"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:366:15",type:"number",value:n.initialDelaySeconds??"",placeholder:"10",onChange:r=>c({initialDelaySeconds:r.target.value===""?void 0:Number(r.target.value)}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:370:13",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:371:15",className:"text-[10px] text-slate-500",children:"间隔(s)"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:372:15",type:"number",value:n.periodSeconds??"",placeholder:"10",onChange:r=>c({periodSeconds:r.target.value===""?void 0:Number(r.target.value)}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:376:13",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:377:15",className:"text-[10px] text-slate-500",children:"超时(s)"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:378:15",type:"number",value:n.timeoutSeconds??"",placeholder:"1",onChange:r=>c({timeoutSeconds:r.target.value===""?void 0:Number(r.target.value)}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:382:13",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:383:15",className:"text-[10px] text-slate-500",children:"成功"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:384:15",type:"number",value:n.successThreshold??"",placeholder:"1",onChange:r=>c({successThreshold:r.target.value===""?void 0:Number(r.target.value)}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:388:13",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:389:15",className:"text-[10px] text-slate-500",children:"失败"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:390:15",type:"number",value:n.failureThreshold??"",placeholder:"3",onChange:r=>c({failureThreshold:r.target.value===""?void 0:Number(r.target.value)}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"})]})]})]})]})}function ns({label:t,handler:s,onChange:a}){const o=s||{type:"none"},n=!o.type||o.type==="none"?"__none":o.type;return e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:406:5",className:"border border-slate-800 rounded-md p-2.5 bg-slate-950/30",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:407:7",className:"text-xs text-slate-300 font-medium block mb-2",children:t}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:408:7",className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:409:9",className:"text-[10px] text-slate-500 w-8",children:"类型"}),e.jsxs(nt,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:410:9",value:n,onValueChange:c=>a({...o,type:c==="__none"?"none":c}),children:[e.jsx(ot,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:411:11",className:"bg-slate-800 border-slate-700 text-slate-200 text-xs h-7 flex-1",children:e.jsx(at,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:412:13"})}),e.jsxs(rt,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:414:11",className:"bg-slate-900 border-slate-700",children:[e.jsx(fe,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:415:13",value:"__none",className:"text-slate-400",children:"不设置"}),e.jsx(fe,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:416:13",value:"exec",className:"text-slate-200",children:"Exec 命令"}),e.jsx(fe,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:417:13",value:"httpGet",className:"text-slate-200",children:"HTTP GET"}),e.jsx(fe,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:418:13",value:"tcpSocket",className:"text-slate-200",children:"TCP Socket"})]})]})]}),o.type==="exec"&&e.jsx(st,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:423:9",value:o.execCommand||"",placeholder:"每行一个命令片段",onChange:c=>a({...o,execCommand:c.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs min-h-[50px]"}),o.type==="httpGet"&&e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:428:9",className:"grid grid-cols-2 gap-2",children:[e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:429:11",value:o.httpPath||"",placeholder:"/shutdown",onChange:c=>a({...o,httpPath:c.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:432:11",type:"number",value:o.httpPort??"",placeholder:"8080",onChange:c=>a({...o,httpPort:c.target.value===""?void 0:Number(c.target.value)}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"})]}),o.type==="tcpSocket"&&e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:438:9",type:"number",value:o.tcpPort??"",placeholder:"端口",onChange:c=>a({...o,tcpPort:c.target.value===""?void 0:Number(c.target.value)}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"})]})}function et({label:t,value:s,onChange:a}){return e.jsxs("label",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:448:5",className:"flex items-center gap-1.5 cursor-pointer",children:[e.jsx(Ht,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:449:7",checked:s,onCheckedChange:a}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:450:7",className:"text-[11px] text-slate-400 font-mono",children:t})]})}function os({title:t,description:s,icon:a,containers:o,accentColor:n,onAdd:c,onRemove:r,onUpdate:i,onDuplicate:k}){const l=dt(),[x,S]=d.useState(new Set([0])),C=w=>{S(P=>{const I=new Set(P);return I.has(w)?I.delete(w):I.add(w),I})},y=n==="blue"?"border-blue-500/30":"border-purple-500/30",b=n==="blue"?"bg-blue-500/5":"bg-purple-500/5";return e.jsxs(U,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:37:5",className:"bg-slate-900 border-slate-800",children:[e.jsxs(he,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:38:7",className:"pb-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:39:9",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:40:11",className:"flex items-center gap-2",children:[a,e.jsx(ue,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:42:13",className:"text-sm text-slate-200",children:t}),e.jsx(ae,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:43:13",variant:"outline",className:"border-slate-700 text-slate-400 text-[10px]",children:o.length})]}),e.jsxs(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:45:11",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:c,children:[e.jsx(te,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:46:13",className:"h-3 w-3 mr-1"}),"新增容器"]})]}),e.jsx("p",{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:49:9",className:"text-[11px] text-slate-600",children:s})]}),e.jsxs(Y,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:51:7",className:"pt-0 space-y-3",children:[o.length===0&&e.jsx("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:53:11",className:"text-center py-6 text-slate-600 text-xs",children:"暂无容器,点击「新增容器」添加"}),o.map((w,P)=>{const I=x.has(P)||o.length===1;return e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:58:13",className:`rounded-lg border ${y} overflow-hidden`,children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:60:15",className:`flex items-center justify-between px-3 py-2 ${b} cursor-pointer`,onClick:()=>C(P),children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:61:17",className:"flex items-center gap-2",children:[I?e.jsx(xs,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:62:29",className:"h-4 w-4 text-slate-500"}):e.jsx(hs,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:62:82",className:"h-4 w-4 text-slate-500"}),e.jsx(Ue,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:63:19",className:`h-4 w-4 ${n==="blue"?"text-blue-400":"text-purple-400"}`}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:64:19",className:"text-sm font-mono text-slate-200 font-semibold",children:w.name||"(未命名)"}),w.image&&e.jsx("code",{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:65:31",className:"text-[10px] text-slate-500 font-mono truncate max-w-[300px]",children:w.image})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:67:17",className:"flex items-center gap-1",onClick:M=>M.stopPropagation(),children:[k&&e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:69:21",variant:"ghost",size:"icon",className:"h-7 w-7 text-slate-500 hover:text-slate-300",title:"复制",onClick:()=>k(P),children:e.jsx(fs,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:71:23",className:"h-3.5 w-3.5"})}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:74:19",variant:"ghost",size:"icon",className:"h-7 w-7 text-red-400 hover:text-red-300",title:"删除",onClick:async()=>{await l({title:"删除容器",description:`确认删除容器「${w.name}」?`,confirmText:"删除",variant:"destructive"})&&r(P)},children:e.jsx(be,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:84:21",className:"h-3.5 w-3.5"})})]})]}),I&&e.jsx("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:90:17",className:"p-3 space-y-4 bg-slate-950/30",children:e.jsx(Mn,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:91:19",container:w,onUpdate:M=>i(P,M)})})]},P)})]})]})}function In({clusterCode:t,namespace:s,deploymentName:a,manifest:o,onSaved:n,onCancel:c}){const{toast:r}=Me(),[i,k]=d.useState(!1),[l,x]=d.useState(!o),[S,C]=d.useState(o||{}),[y,b]=d.useState([]),[w,P]=d.useState([]),[I,M]=d.useState([]);d.useEffect(()=>{if(!o){x(!1);return}C(o);const N=o?.spec?.template?.spec||{};b((Array.isArray(N.containers)?N.containers:[]).map(Xt)),P((Array.isArray(N.initContainers)?N.initContainers:[]).map(Xt)),M((Array.isArray(N.imagePullSecrets)?N.imagePullSecrets:[]).map(_=>_.name||"")),x(!1)},[o]);const F=(N,_)=>{b(J=>J.map((ee,me)=>me===N?{...ee,..._}:ee))},V=()=>{b(N=>[...N,Qt(`container-${N.length+1}`)])},X=N=>{b(_=>_.filter((J,ee)=>ee!==N))},q=N=>{b(_=>{const J=JSON.parse(JSON.stringify(_[N]));J.name=`${J.name}-copy`;const ee=[..._];return ee.splice(N+1,0,J),ee})},W=(N,_)=>{P(J=>J.map((ee,me)=>me===N?{...ee,..._}:ee))},Q=()=>{P(N=>[...N,Qt(`init-${N.length+1}`)])},$=N=>{P(_=>_.filter((J,ee)=>ee!==N))},Z=async()=>{for(const N of[...w,...y]){if(!N.name.trim()){r({title:"保存失败",description:"容器名称不能为空",variant:"destructive"});return}if(!N.image.trim()){r({title:"保存失败",description:`容器 ${N.name} 的镜像不能为空`,variant:"destructive"});return}}k(!0);try{const N=JSON.parse(JSON.stringify(S));N.spec=N.spec||{},N.spec.template=N.spec.template||{},N.spec.template.spec=N.spec.template.spec||{},N.spec.template.spec.containers=y.map(es),N.spec.template.spec.initContainers=w.length>0?w.map(es):void 0,N.spec.template.spec.imagePullSecrets=I.filter(_=>_.trim()).length>0?I.filter(_=>_.trim()).map(_=>({name:_})):void 0,await pt(t,s,a,N),r({title:"容器配置已保存",description:`${a} 更新已提交`}),n(N)}catch(N){r({title:"保存失败",description:N?.message||String(N),variant:"destructive"})}finally{k(!1)}};return l?e.jsx(U,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:113:7",className:"bg-slate-900 border-slate-800",children:e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:114:9",className:"p-12 text-center",children:[e.jsx(ve,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:115:11",className:"h-6 w-6 animate-spin mx-auto text-slate-500"}),e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:116:11",className:"text-slate-500 mt-3 text-sm",children:"加载中..."})]})}):o?e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:132:5",className:"space-y-4",children:[e.jsxs(U,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:134:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:135:9",className:"pb-3",children:e.jsxs(ue,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:136:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(cn,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:137:13",className:"h-4 w-4 text-amber-400"}),"镜像拉取凭证 (imagePullSecrets)",e.jsx(ae,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:139:13",variant:"outline",className:"border-slate-700 text-slate-500 text-[10px]",children:"Pod 级别"})]})}),e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:142:9",className:"pt-0 space-y-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:143:11",className:"flex items-center gap-2 flex-wrap",children:[I.map((N,_)=>e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:145:15",className:"flex items-center gap-1 bg-slate-800 rounded px-2 py-1",children:[e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:146:17",className:"text-xs text-slate-300 font-mono",children:N}),e.jsx("button",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:147:17",onClick:()=>M(J=>J.filter((ee,me)=>me!==_)),className:"text-red-400 hover:text-red-300 ml-1",children:e.jsx(be,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:148:68",className:"h-3 w-3"})})]},_)),I.length===0&&e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:151:47",className:"text-[11px] text-slate-600",children:"无"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:153:11",className:"flex gap-2",children:[e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:154:13",placeholder:"输入 Secret 名称后回车",className:"bg-slate-800 border-slate-700 text-slate-200 text-xs h-8",onKeyDown:N=>{if(N.key==="Enter"){const _=N.target.value.trim();_&&(M(J=>[...J,_]),N.target.value="")}}}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:161:13",size:"sm",variant:"outline",className:"h-8 border-slate-700 text-slate-300 text-xs",onClick:()=>M(N=>[...N,""]),children:[e.jsx(te,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:163:15",className:"h-3 w-3 mr-1"}),"新增"]})]})]})]}),e.jsx(os,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:170:7",title:"初始化容器",description:"在主容器启动前按顺序执行的容器,用于初始化环境",icon:e.jsx(Ns,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:173:15",className:"h-4 w-4 text-purple-400"}),containers:w,accentColor:"purple",onAdd:Q,onRemove:$,onUpdate:W}),e.jsx(os,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:182:7",title:"工作容器",description:"Deployment 运行的主容器,定义应用进程及其运行时配置",icon:e.jsx(Ue,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:185:15",className:"h-4 w-4 text-blue-400"}),containers:y,accentColor:"blue",onAdd:V,onRemove:X,onUpdate:F,onDuplicate:q}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:195:7",className:"sticky bottom-0 bg-slate-950/80 backdrop-blur border-t border-slate-800 p-3 flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:196:9",className:"text-[11px] text-slate-500",children:["共 ",e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:197:13",className:"text-slate-300 font-semibold",children:w.length})," 个初始化容器 +",e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:198:11",className:"text-slate-300 font-semibold ml-1",children:y.length})," 个工作容器"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:200:9",className:"flex gap-2",children:[e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:201:11",variant:"outline",className:"border-slate-700 text-slate-400",onClick:c,children:"取消"}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:202:11",className:"bg-blue-600 hover:bg-blue-700",disabled:i,onClick:Z,children:[i?e.jsx(ve,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:203:23",className:"h-4 w-4 animate-spin mr-1"}):e.jsx(it,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:203:75",className:"h-4 w-4 mr-1"}),"保存"]})]})]})]}):e.jsx(U,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:123:7",className:"bg-slate-900 border-slate-800",children:e.jsx(Y,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:124:9",className:"p-8 text-center text-slate-500",children:"未获取到 manifest 数据,请使用 YAML 编辑模式直接修改。"})})}function Nt(t){const s=Array.isArray(t)?t:t?.list||t?.data||[];return Array.isArray(s)?s.map(a=>String(a?.name||"")).filter(Boolean).sort():[]}function St({label:t,value:s,options:a,loading:o,onChange:n,onRefresh:c,onCreate:r}){const i=s&&!a.includes(s);return e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:36:5",className:"flex items-center gap-2 flex-wrap flex-1 min-w-0",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:37:7",className:"text-[10px] text-slate-500 w-20 shrink-0",children:t}),e.jsxs("select",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:38:7",value:s||"",onChange:k=>n(k.target.value),disabled:o,className:"h-7 flex-1 min-w-[160px] max-w-xs bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-2 font-mono",children:[e.jsx("option",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:44:9",value:"",disabled:!0,children:a.length===0?"暂无资源":"请选择"}),i&&e.jsxs("option",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:45:20",value:s,children:[s,"(未在集群中找到)"]}),a.map(k=>e.jsx("option",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:46:29",value:k,children:k},k))]}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:48:7",type:"button",size:"sm",variant:"outline",className:"h-7 px-2 border-slate-700 text-slate-400 text-xs",onClick:c,disabled:o,children:o?e.jsx(ve,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:49:20",className:"h-3 w-3 animate-spin"}):e.jsx(Ye,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:49:67",className:"h-3 w-3"})}),e.jsxs(v,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:51:7",type:"button",size:"sm",variant:"outline",className:"h-7 px-2 border-slate-700 text-blue-400 text-xs",onClick:r,children:[e.jsx(te,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:52:9",className:"h-3 w-3 mr-0.5"}),"新建"]}),a.length===0&&!i&&e.jsxs("span",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:55:9",className:"text-[10px] text-amber-400/90",children:["命名空间内暂无",t,",请先新建"]})]})}function Bn({vol:t,resources:s,resourcesLoading:a,onChange:o,onRefreshResources:n,onCreateResource:c}){return t.type==="persistentVolumeClaim"?e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:75:7",className:"space-y-2",children:[e.jsx(St,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:76:9",label:"PVC 关联",value:t.pvcName||"",options:s.pvcs,loading:a,onChange:r=>o({pvcName:r}),onRefresh:n,onCreate:()=>c("pvcs")}),e.jsxs("label",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:85:9",className:"flex items-center gap-1.5 text-xs text-slate-400 cursor-pointer whitespace-nowrap pl-[88px]",children:[e.jsx("input",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:86:11",type:"checkbox",checked:!!t.pvcReadOnly,onChange:r=>o({pvcReadOnly:r.target.checked}),className:"accent-blue-500"}),"卷只读"]})]}):t.type==="emptyDir"?e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:94:7",className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:95:9",className:"text-[10px] text-slate-500 w-20 shrink-0",children:"介质"}),e.jsxs("select",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:96:9",value:t.medium||"",onChange:r=>o({medium:r.target.value}),className:"h-7 w-28 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-1.5",children:[e.jsx("option",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:98:11",value:"",children:"默认磁盘"}),e.jsx("option",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:99:11",value:"Memory",children:"Memory"})]}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:101:9",value:t.sizeLimit||"",onChange:r=>o({sizeLimit:r.target.value}),placeholder:"sizeLimit 如 512Mi",className:"h-7 flex-1 min-w-[120px] bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"})]}):t.type==="hostPath"?e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:108:7",className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:109:9",className:"text-[10px] text-slate-500 w-20 shrink-0",children:"主机路径"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:110:9",value:t.path||"",onChange:r=>o({path:r.target.value}),placeholder:"/data/app",className:"h-7 flex-1 min-w-[160px] bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsxs("select",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:112:9",value:t.pathType||"Directory",onChange:r=>o({pathType:r.target.value}),className:"h-7 w-28 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-1.5",children:[e.jsx("option",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:114:11",value:"Directory",children:"Directory"}),e.jsx("option",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:115:11",value:"File",children:"File"}),e.jsx("option",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:116:11",value:"",children:"默认"})]})]}):t.type==="nfs"?e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:123:7",className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:124:9",className:"text-[10px] text-slate-500 w-20 shrink-0",children:"NFS"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:125:9",value:t.nfsServer||"",onChange:r=>o({nfsServer:r.target.value}),placeholder:"Server IP",className:"h-7 w-36 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:127:9",value:t.nfsPath||"",onChange:r=>o({nfsPath:r.target.value}),placeholder:"/export/path",className:"h-7 flex-1 min-w-[120px] bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"})]}):t.type==="configMap"?e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:134:7",className:"space-y-2",children:[e.jsx(St,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:135:9",label:"ConfigMap",value:t.configMapName||"",options:s.configMaps,loading:a,onChange:r=>o({configMapName:r}),onRefresh:n,onCreate:()=>c("configmaps")}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:144:9",className:"flex items-center gap-2 pl-[88px]",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:145:11",className:"text-[10px] text-slate-500 shrink-0",children:"键映射"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:146:11",value:t.cmItems||"",onChange:r=>o({cmItems:r.target.value}),placeholder:"key:path(可选,挂载子项)",className:"h-7 flex-1 max-w-md bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"})]})]}):t.type==="secret"?e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:154:7",className:"space-y-2",children:[e.jsx(St,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:155:9",label:"Secret",value:t.secretName||"",options:s.secrets,loading:a,onChange:r=>o({secretName:r}),onRefresh:n,onCreate:()=>c("secrets")}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:164:9",className:"flex items-center gap-2 pl-[88px]",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:165:11",className:"text-[10px] text-slate-500 shrink-0",children:"键映射"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:166:11",value:t.secItems||"",onChange:r=>o({secItems:r.target.value}),placeholder:"key:path(可选,挂载子项)",className:"h-7 flex-1 max-w-md bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"})]})]}):t.type==="custom"?e.jsx("p",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:173:12",className:"text-[11px] text-amber-400/80",children:"未识别卷类型,保存时将保留原始 YAML 结构"}):null}function ct(t=""){return{containerName:t,mountPath:"",subPath:"",readOnly:!1}}function Rn(t=""){return{volume:{name:"",type:"emptyDir"},mounts:[ct(t)]}}const On=["kube-api-access-","default-token-","kube-"];function Et(t){if(!t||typeof t!="object")return!1;const s=String(t.name||"");return On.some(a=>s.startsWith(a))?!0:!!(t.projected||t.downwardAPI||t.csi||t.ephemeral)}function as(t){const s=t?.trim();if(!s)return;if(s.startsWith("["))try{const o=JSON.parse(s);if(Array.isArray(o))return o.filter(n=>n?.key&&n?.path)}catch{}const a=s.split(",").map(o=>o.trim()).filter(Boolean).map(o=>{const n=o.indexOf(":");return n<=0?null:{key:o.slice(0,n).trim(),path:o.slice(n+1).trim()}}).filter(Boolean);return a.length?a:void 0}function $n(t){if(!t||typeof t!="object")return{name:"",type:"emptyDir"};const s=t.name||"";return t.persistentVolumeClaim?{name:s,type:"persistentVolumeClaim",pvcName:t.persistentVolumeClaim.claimName||"",pvcReadOnly:!!t.persistentVolumeClaim.readOnly}:t.nfs?{name:s,type:"nfs",nfsServer:t.nfs.server||"",nfsPath:t.nfs.path||"",nfsReadOnly:!!t.nfs.readOnly}:t.configMap?{name:s,type:"configMap",configMapName:t.configMap.name||"",cmItems:t.configMap.items?JSON.stringify(t.configMap.items):""}:t.secret?{name:s,type:"secret",secretName:t.secret.secretName||"",secItems:t.secret.items?JSON.stringify(t.secret.items):""}:t.hostPath?{name:s,type:"hostPath",path:t.hostPath.path||"",pathType:t.hostPath.type||""}:t.emptyDir!=null?{name:s,type:"emptyDir",medium:t.emptyDir.medium||"",sizeLimit:t.emptyDir.sizeLimit||""}:Et(t)?{name:s,type:"custom",_raw:t}:{name:s,type:"custom",_raw:t}}function Ps(t){if(t.type==="custom"&&t._raw)return JSON.parse(JSON.stringify(t._raw));const s=t.name?.trim();if(!s)return null;const a={name:s};switch(t.type){case"emptyDir":{const o={};t.medium?.trim()&&(o.medium=t.medium.trim()),t.sizeLimit?.trim()&&(o.sizeLimit=t.sizeLimit.trim()),a.emptyDir=o;break}case"hostPath":{const o={path:t.path?.trim()||"/"};t.pathType?.trim()&&(o.type=t.pathType.trim()),a.hostPath=o;break}case"configMap":{const o=t.configMapName?.trim();if(!o)return null;const n={name:o},c=as(t.cmItems);c&&(n.items=c),a.configMap=n;break}case"secret":{const o=t.secretName?.trim();if(!o)return null;const n={secretName:o},c=as(t.secItems);c&&(n.items=c),a.secret=n;break}case"persistentVolumeClaim":{const o=t.pvcName?.trim();if(!o)return null;const n={claimName:o};t.pvcReadOnly&&(n.readOnly=!0),a.persistentVolumeClaim=n;break}case"nfs":{const o=t.nfsServer?.trim(),n=t.nfsPath?.trim();if(!o||!n)return null;const c={server:o,path:n};t.nfsReadOnly&&(c.readOnly=!0),a.nfs=c;break}default:return null}return a}function _n(t,s){return{containerName:t,volumeName:s.name||"",mountPath:s.mountPath||"",subPath:s.subPath||"",readOnly:!!s.readOnly}}function Ln(t){if(!t.volumeName?.trim()||!t.mountPath?.trim())return null;const s={name:t.volumeName.trim(),mountPath:t.mountPath.trim()};return t.subPath?.trim()&&(s.subPath=t.subPath.trim()),t.readOnly&&(s.readOnly=!0),s}const zn=["/var/run/secrets/kubernetes.io/serviceaccount"];function As(t,s){if(!t)return!1;if(s.has(t.name))return!0;const a=t.mountPath||"";return zn.some(o=>a.startsWith(o))}function Wn(t){const s=t?.spec?.template?.spec||{},a=Array.isArray(s.volumes)?s.volumes:[],o=a.filter(Et),n=a.filter(l=>!Et(l)),c=[...Array.isArray(s.containers)?s.containers:[],...Array.isArray(s.initContainers)?s.initContainers:[]],r=c.map(l=>l.name||"(unnamed)"),i=new Set(o.map(l=>l.name)),k=[];for(const l of c){const x=l.name||"(unnamed)",S=Array.isArray(l.volumeMounts)?l.volumeMounts:[];for(const C of S)As(C,i)||k.push(_n(x,C))}return{volumes:n.map($n),mounts:k,containers:r,passthroughVolumes:o}}function Gn(t){const{volumes:s,mounts:a,containers:o,passthroughVolumes:n}=Wn(t),c=o.find(i=>i!=="(unnamed)")||o[0]||"";return{entries:s.map(i=>{const k=a.filter(l=>l.volumeName===i.name);return{volume:i,mounts:k.length>0?k.map(l=>({containerName:l.containerName,mountPath:l.mountPath,subPath:l.subPath,readOnly:l.readOnly})):[ct(c)]}}),containers:o,passthroughVolumes:n}}function Vn(t){const s=t.map(o=>o.volume),a=[];for(const o of t){const n=o.volume.name.trim();if(n)for(const c of o.mounts)c.mountPath.trim()&&a.push({containerName:c.containerName,volumeName:n,mountPath:c.mountPath.trim(),subPath:c.subPath.trim(),readOnly:c.readOnly})}return{volumes:s,mounts:a}}function Fn(t,s,a,o){const n=JSON.parse(JSON.stringify(t));n.spec=n.spec||{},n.spec.template=n.spec.template||{},n.spec.template.spec=n.spec.template.spec||{};const c=n.spec.template.spec,r=s.map(Ps).filter(Boolean),i=[...o,...r];i.length>0?c.volumes=i:delete c.volumes;const k=new Set(o.map(x=>x.name)),l=x=>{const S=x.name||"(unnamed)",y=(Array.isArray(x.volumeMounts)?x.volumeMounts:[]).filter(P=>As(P,k)),b=a.filter(P=>P.containerName===S).map(Ln).filter(Boolean),w=[...y,...b];w.length>0?x.volumeMounts=w:delete x.volumeMounts};return(c.containers||[]).forEach(l),(c.initContainers||[]).forEach(l),n}const Dt=[{key:"persistentVolumeClaim",label:"存储卷声明",icon:tt,color:"text-emerald-400"},{key:"emptyDir",label:"临时目录(EmptyDir)",icon:ln,color:"text-slate-400"},{key:"hostPath",label:"HostPath",icon:bs,color:"text-amber-400"},{key:"nfs",label:"NFS",icon:Mt,color:"text-purple-400"},{key:"configMap",label:"配置字典",icon:dn,color:"text-blue-400"},{key:"secret",label:"密文",icon:ks,color:"text-rose-400"}],Un=new Set(Dt.map(t=>t.key));function Yn({clusterCode:t,namespace:s,deploymentName:a,manifest:o,onSaved:n,onCancel:c}){const{toast:r}=Me(),[i,k]=d.useState(!1),[l,x]=d.useState(!o),[S,C]=d.useState(o||{}),[y,b]=d.useState([]),[w,P]=d.useState([]),[I,M]=d.useState([]),[F,V]=d.useState({configMaps:[],secrets:[],pvcs:[]}),[X,q]=d.useState(!1),[W,Q]=d.useState(null),$=d.useCallback(async()=>{if(!(!t||!s)){q(!0);try{const[R,p,h]=await Promise.all([K.getNamespaceConfigMaps(t,s).catch(()=>[]),K.getNamespaceSecrets(t,s).catch(()=>[]),K.getPVCs(t,s).catch(()=>[])]);V({configMaps:Nt(R),secrets:Nt(p),pvcs:Nt(h)})}finally{q(!1)}}},[t,s]);d.useEffect(()=>{$()},[$]),d.useEffect(()=>{if(!o){x(!1);return}C(o);const R=Gn(o);b(R.entries),P(R.containers),M(R.passthroughVolumes),x(!1)},[o]);const Z=w.find(R=>R!=="(unnamed)")||w[0]||"",N=(R,p)=>b(h=>h.map((u,A)=>A===R?{...u,volume:{...u.volume,...p}}:u)),_=(R,p,h)=>b(u=>u.map((A,L)=>L!==R?A:{...A,mounts:A.mounts.map((m,g)=>g===p?{...m,...h}:m)})),J=R=>b(p=>p.map((h,u)=>u!==R?h:{...h,mounts:[...h.mounts,ct(Z)]})),ee=(R,p)=>b(h=>h.map((u,A)=>{if(A!==R)return u;const L=u.mounts.filter((m,g)=>g!==p);return{...u,mounts:L.length>0?L:[ct(Z)]}})),me=()=>b(R=>[...R,Rn(Z)]),ye=R=>b(p=>p.filter((h,u)=>u!==R)),ge=async()=>{for(const R of y){if(!R.volume.name.trim()){r({title:"请填写数据卷名称",variant:"destructive"});return}if(!Ps(R.volume)){const h=R.volume.type==="configMap"?"请选择 ConfigMap":R.volume.type==="secret"?"请选择 Secret":R.volume.type==="persistentVolumeClaim"?"请选择 PVC":"的类型必填项";r({title:"数据卷配置不完整",description:`请为「${R.volume.name}」${h}`,variant:"destructive"});return}if(R.mounts.filter(h=>h.mountPath.trim()).length===0){r({title:"请填写挂载路径",description:`数据卷「${R.volume.name}」需至少挂载到一个容器`,variant:"destructive"});return}}k(!0);try{const{volumes:R,mounts:p}=Vn(y),h=Fn(S,R,p,I);await pt(t,s,a,h),r({title:"存储配置已保存",description:`${a} 更新已提交`}),n(h)}catch(R){r({title:"保存失败",description:R?.message||String(R),variant:"destructive"})}finally{k(!1)}};return l?e.jsx(U,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:165:7",className:"bg-slate-900 border-slate-800",children:e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:166:9",className:"p-12 text-center",children:[e.jsx(ve,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:167:11",className:"h-6 w-6 animate-spin mx-auto text-slate-500"}),e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:168:11",className:"text-slate-500 mt-3 text-sm",children:"加载中..."})]})}):o?e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:183:5",className:"space-y-4",children:[W&&e.jsx(Cs,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:185:9",clusterCode:t,namespace:s,resource:W,name:"",isCreate:!0,onClose:()=>Q(null),onSaved:()=>{$(),Q(null)}}),e.jsxs(U,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:195:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:196:9",className:"pb-3",children:e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:197:11",className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:198:13",children:[e.jsxs(ue,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:199:15",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(tt,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:200:17",className:"h-4 w-4 text-emerald-400"}),"数据卷",e.jsx(ae,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:202:17",variant:"outline",className:"border-slate-700 text-slate-400",children:y.length})]}),e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:204:15",className:"text-[11px] text-slate-500 mt-1",children:"定义数据卷,并将其挂载到工作负载的容器中"})]}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:206:13",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs shrink-0",onClick:me,children:[e.jsx(te,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:207:15",className:"h-3 w-3 mr-1"}),"添加数据卷"]})]})}),e.jsx(Y,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:211:9",className:"pt-0 space-y-4",children:y.length===0?e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:213:13",className:"text-center py-10 text-slate-500 text-sm border border-dashed border-slate-800 rounded-lg",children:[e.jsx(tt,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:214:15",className:"h-8 w-8 mx-auto mb-2 text-slate-700"}),"未配置数据卷,点击「添加数据卷」开始"]}):y.map((R,p)=>{const h=R.volume,u=Dt.find(m=>m.key===h.type),A=u?.icon||pn,L=Un.has(h.type)?h.type:"emptyDir";return e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:223:15",className:"bg-slate-950/60 border border-slate-800 rounded-lg",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:225:17",className:"p-3 space-y-2.5 border-b border-slate-800/80",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:226:19",className:"flex items-center gap-2 flex-wrap",children:[e.jsx(A,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:227:21",className:`h-4 w-4 ${u?.color||"text-slate-400"}`}),e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:228:21",className:"text-xs text-slate-400 shrink-0",children:"数据卷名称"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:229:21",value:h.name,onChange:m=>{const g=m.target.value,j={name:g};h.type==="configMap"&&!h.configMapName&&(j.configMapName=g),h.type==="secret"&&!h.secretName&&(j.secretName=g),h.type==="persistentVolumeClaim"&&!h.pvcName&&(j.pvcName=g),N(p,j)},placeholder:"如 app-logs / fluent-bit-config",className:"h-8 w-44 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"}),e.jsx("select",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:243:21",value:L,onChange:m=>{const g=m.target.value,j={type:g};g==="configMap"&&F.configMaps.length===1&&(j.configMapName=F.configMaps[0]),g==="secret"&&F.secrets.length===1&&(j.secretName=F.secrets[0]),g==="persistentVolumeClaim"&&F.pvcs.length===1&&(j.pvcName=F.pvcs[0]),N(p,j)},className:"h-8 min-w-[168px] bg-slate-800 border border-slate-700 rounded-md text-xs text-slate-300 px-2",children:Dt.map(m=>e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:256:25",value:m.key,children:m.label},m.key))}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:259:21",size:"icon",variant:"ghost",className:"h-8 w-8 text-red-400 ml-auto",onClick:()=>ye(p),children:e.jsx(be,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:260:23",className:"h-4 w-4"})})]}),e.jsx(Bn,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:263:19",vol:h,resources:F,resourcesLoading:X,onChange:m=>{const g=y[p]?.volume,j={};g&&!g.name.trim()&&(m.configMapName&&(j.name=m.configMapName),m.secretName&&(j.name=m.secretName),m.pvcName&&(j.name=m.pvcName)),N(p,{...m,...j})},onRefreshResources:$,onCreateResource:Q})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:283:17",className:"px-3 py-2.5 bg-slate-900/40 space-y-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:284:19",className:"flex items-center justify-between gap-2",children:[e.jsxs("p",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:285:21",className:"text-[11px] text-slate-500 flex items-center gap-1.5",children:[e.jsx(Ue,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:286:23",className:"h-3.5 w-3.5 text-blue-400"}),"将上述数据卷挂载到容器"]}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:289:21",size:"sm",variant:"ghost",className:"h-6 px-2 text-[11px] text-slate-400 hover:text-slate-200",onClick:()=>J(p),children:[e.jsx(te,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:290:23",className:"h-3 w-3 mr-0.5"}),"添加挂载"]})]}),R.mounts.map((m,g)=>e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:294:21",className:"space-y-2 rounded-md border border-slate-800/60 bg-slate-950/40 p-2.5",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:295:23",className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("select",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:296:25",value:m.containerName,onChange:j=>_(p,g,{containerName:j.target.value}),className:"h-8 min-w-[140px] max-w-[280px] bg-slate-800 border border-slate-700 rounded-md text-sm text-slate-200 px-2 font-medium truncate",children:[w.length===0&&e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:301:55",value:"",children:"(无容器)"}),w.map(j=>e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:302:51",value:j,children:j},j))]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:304:25",className:"flex items-center gap-1 bg-slate-800 rounded-lg p-0.5 border border-slate-700",children:[e.jsx("button",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:305:27",type:"button",onClick:()=>_(p,g,{readOnly:!0}),className:`px-2.5 py-1 rounded text-xs font-medium transition-all ${m.readOnly?"bg-amber-500/20 text-amber-300":"text-slate-500 hover:text-slate-300"}`,children:"只读"}),e.jsx("button",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:309:27",type:"button",onClick:()=>_(p,g,{readOnly:!1}),className:`px-2.5 py-1 rounded text-xs font-medium transition-all ${m.readOnly?"text-slate-500 hover:text-slate-300":"bg-blue-500/20 text-blue-300"}`,children:"读写"})]}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:314:25",value:m.mountPath,onChange:j=>_(p,g,{mountPath:j.target.value}),placeholder:"挂载路径 /bitcloud/app/.../logs",className:"h-8 flex-1 min-w-[200px] bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"}),R.mounts.length>1&&e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:321:27",size:"icon",variant:"ghost",className:"h-8 w-8 text-red-400/70 shrink-0",onClick:()=>ee(p,g),children:e.jsx(be,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:322:29",className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:326:23",className:"flex items-center gap-2",children:[e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:327:25",className:"text-[11px] text-slate-500 shrink-0",children:"子路径 subPath"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:328:25",value:m.subPath,onChange:j=>_(p,g,{subPath:j.target.value}),placeholder:"如 config.yaml(挂载单文件时填写)",className:"h-7 flex-1 max-w-md bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"})]})]},g))]})]},p)})})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:344:7",className:"flex justify-end gap-2 pt-2",children:[e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:345:9",variant:"outline",className:"border-slate-700 text-slate-400",onClick:c,children:"取消"}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:346:9",className:"bg-blue-600 hover:bg-blue-700",disabled:i,onClick:ge,children:[i?e.jsx(ve,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:347:21",className:"h-4 w-4 animate-spin mr-1"}):e.jsx(it,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:347:73",className:"h-4 w-4 mr-1"}),"保存"]})]})]}):e.jsx(U,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:176:7",className:"bg-slate-900 border-slate-800",children:e.jsx(Y,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:177:9",className:"p-8 text-center text-slate-500",children:"未获取到 manifest 数据,请使用 YAML 编辑模式。"})})}const qn=[{key:"nodeName",label:"节点名称"},{key:"nodeSelector",label:"标签选择器"},{key:"nodeAffinity",label:"节点亲和性"}];function Kn({scheduleMode:t,onScheduleModeChange:s,nodeName:a,onNodeNameChange:o,availableNodes:n,nodesLoading:c,labelSelectorKv:r,onAddLabelSelector:i,onRemoveLabelSelector:k,onUpdateLabelSelector:l,nodeLabels:x}){return e.jsxs(U,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:54:5",className:"bg-slate-900 border-slate-800",children:[e.jsxs(he,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:55:7",className:"pb-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:56:9",className:"flex items-center justify-between",children:[e.jsxs(ue,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:57:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(Mt,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:58:13",className:"h-4 w-4 text-emerald-400"}),"调度 (Scheduling)"]}),e.jsx("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:60:11",className:"flex items-center gap-1 bg-slate-800 rounded-lg p-0.5 border border-slate-700",children:qn.map(S=>e.jsx("button",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:62:15",onClick:()=>s(S.key),className:`px-2.5 py-1 rounded text-[10px] font-medium transition-all ${t===S.key?"bg-emerald-500/20 text-emerald-300 shadow-sm":"text-slate-400 hover:text-slate-300"}`,children:S.label},S.key))})]}),e.jsxs("p",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:76:9",className:"text-xs text-slate-500 mt-1",children:[t==="nodeName"&&"Pod 将直接调度到指定节点",t==="nodeSelector"&&"Pod 将调度到匹配标签的节点",t==="nodeAffinity"&&"通过亲和性规则控制 Pod 调度到指定节点"]})]}),e.jsxs(Y,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:82:7",className:"pt-0",children:[t==="nodeName"&&e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:84:11",className:"space-y-2",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:85:13",className:"text-slate-400 text-xs",children:"请选择节点"}),c?e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:87:15",className:"flex items-center gap-1 text-slate-500 text-xs",children:[e.jsx(ve,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:88:17",className:"h-3 w-3 animate-spin"}),"加载节点列表..."]}):e.jsxs("select",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:91:15",value:a,onChange:S=>o(S.target.value),className:"h-8 w-full bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-2",children:[e.jsx("option",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:96:17",value:"",children:"(不指定)"}),n.map(S=>e.jsxs("option",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:98:19",value:S.name,children:[S.name," ",S.ip?`(${S.ip})`:""]},S.name))]}),a&&e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:105:15",className:"text-[10px] text-slate-500",children:["已选择: ",e.jsx("code",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:106:22",className:"bg-slate-800 px-1 py-0.5 rounded text-emerald-400",children:a})]})]}),t==="nodeSelector"&&e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:113:11",className:"space-y-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:114:13",className:"flex items-center justify-between",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:115:15",className:"text-slate-400 text-xs",children:"请选择标签"}),e.jsxs(v,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:116:15",size:"sm",variant:"ghost",className:"h-6 text-xs text-slate-400",onClick:i,children:[e.jsx(te,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:117:17",className:"h-3 w-3 mr-1"}),"添加"]})]}),r.length===0?e.jsx("p",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:121:15",className:"text-xs text-slate-600 italic",children:"未配置标签选择器"}):r.map((S,C)=>e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:124:17",className:"flex items-center gap-2",children:[e.jsxs("select",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:125:19",value:S.key,onChange:y=>l(C,{key:y.target.value,value:""}),className:"flex-1 h-7 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-1.5",children:[e.jsx("option",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:130:21",value:"",children:"选择标签"}),Object.entries(x).map(([y,b])=>e.jsxs("option",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:132:23",value:y,children:[y," (",b.length,")"]},y))]}),e.jsxs("select",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:135:19",value:S.value,onChange:y=>l(C,{value:y.target.value}),className:"flex-1 h-7 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-1.5",disabled:!S.key,children:[e.jsx("option",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:141:21",value:"",children:"选择值"}),(x[S.key]||[]).map(y=>e.jsx("option",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:143:23",value:y,children:y},y))]}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:146:19",size:"icon",variant:"ghost",className:"h-6 w-6 text-red-400",onClick:()=>k(C),children:e.jsx(be,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:152:21",className:"h-3 w-3"})})]},C))]}),t==="nodeAffinity"&&e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:161:11",className:"space-y-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:162:13",className:"flex items-center justify-between",children:[e.jsxs(H,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:163:15",className:"text-slate-400 text-xs",children:["请选择标签 ",e.jsx("span",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:164:23",className:"text-slate-600",children:"(生成 requiredDuringScheduling 规则)"})]}),e.jsxs(v,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:166:15",size:"sm",variant:"ghost",className:"h-6 text-xs text-slate-400",onClick:i,children:[e.jsx(te,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:167:17",className:"h-3 w-3 mr-1"}),"添加"]})]}),r.length===0?e.jsx("p",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:171:15",className:"text-xs text-slate-600 italic",children:"未配置亲和性规则"}):r.map((S,C)=>e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:174:17",className:"flex items-center gap-2",children:[e.jsxs("select",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:175:19",value:S.key,onChange:y=>l(C,{key:y.target.value,value:""}),className:"flex-1 h-7 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-1.5",children:[e.jsx("option",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:180:21",value:"",children:"选择标签"}),Object.entries(x).map(([y,b])=>e.jsxs("option",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:182:23",value:y,children:[y," (",b.length,")"]},y))]}),e.jsxs("select",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:185:19",value:S.value,onChange:y=>l(C,{value:y.target.value}),className:"flex-1 h-7 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-1.5",disabled:!S.key,children:[e.jsx("option",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:191:21",value:"",children:"选择值"}),(x[S.key]||[]).map(y=>e.jsx("option",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:193:23",value:y,children:y},y))]}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:196:19",size:"icon",variant:"ghost",className:"h-6 w-6 text-red-400",onClick:()=>k(C),children:e.jsx(be,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:202:21",className:"h-3 w-3"})})]},C))]})]})]})}function Jn({dnsNameservers:t,onDnsNameserversChange:s,dnsSearches:a,onDnsSearchesChange:o,dnsOptions:n,onDnsOptionsChange:c,hostAliases:r,onHostAliasesChange:i}){const k=()=>c([...n,{name:"",value:""}]),l=(b,w)=>c(n.map((P,I)=>I===b?{...P,...w}:P)),x=b=>c(n.filter((w,P)=>P!==b)),S=()=>i([...r,{ip:"",hostnames:""}]),C=(b,w)=>i(r.map((P,I)=>I===b?{...P,...w}:P)),y=b=>i(r.filter((w,P)=>P!==b));return e.jsxs(e.Fragment,{children:[e.jsxs(U,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:53:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(he,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:54:9",className:"pb-3",children:e.jsxs(ue,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:55:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(mn,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:56:13",className:"h-4 w-4 text-indigo-400"}),"DNS 配置 (dnsConfig)"]})}),e.jsxs(Y,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:59:9",className:"pt-0 space-y-3",children:[e.jsxs("p",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:60:11",className:"text-[11px] text-slate-500",children:["提示:dnsConfig 通常与 ",e.jsx("code",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:61:30",className:"text-slate-400",children:"dnsPolicy: None"})," 搭配使用。每行一个值。"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:63:11",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:64:13",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:65:15",className:"text-slate-500 text-xs",children:"nameservers(每行一个 IP)"}),e.jsx("textarea",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:66:15",value:t,onChange:b=>s(b.target.value),placeholder:`8.8.8.8
|
||
114.114.114.114`,rows:3,className:"w-full mt-1 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 font-mono p-2 resize-y"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:74:13",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:75:15",className:"text-slate-500 text-xs",children:"searches(搜索域,每行一个)"}),e.jsx("textarea",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:76:15",value:a,onChange:b=>o(b.target.value),placeholder:`svc.cluster.local
|
||
cluster.local`,rows:3,className:"w-full mt-1 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 font-mono p-2 resize-y"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:85:11",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:86:13",className:"flex items-center justify-between mb-1",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:87:15",className:"text-slate-400 text-xs",children:"options(DNS 选项)"}),e.jsxs(v,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:88:15",size:"sm",variant:"ghost",className:"h-6 text-xs text-slate-400",onClick:k,children:[e.jsx(te,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:89:17",className:"h-3 w-3 mr-1"}),"添加"]})]}),n.length===0?e.jsx("p",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:93:15",className:"text-xs text-slate-600 italic",children:"未配置"}):n.map((b,w)=>e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:96:17",className:"flex items-center gap-2 mb-1.5",children:[e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:97:19",value:b.name,onChange:P=>l(w,{name:P.target.value}),placeholder:"ndots",className:"flex-1 h-7 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:103:19",className:"text-slate-600",children:":"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:104:19",value:b.value,onChange:P=>l(w,{value:P.target.value}),placeholder:"5(可留空)",className:"flex-1 h-7 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:110:19",size:"icon",variant:"ghost",className:"h-6 w-6 text-red-400",onClick:()=>x(w),children:e.jsx(be,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:111:21",className:"h-3 w-3"})})]},w))]})]})]}),e.jsxs(U,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:120:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(he,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:121:9",className:"pb-3",children:e.jsxs(ue,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:122:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(xn,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:123:13",className:"h-4 w-4 text-amber-400"}),"主机别名 (hostAliases)"]})}),e.jsxs(Y,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:126:9",className:"pt-0 space-y-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:127:11",className:"flex items-center justify-between mb-1",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:128:13",className:"text-slate-400 text-xs",children:"IP → 主机名映射(注入 Pod 的 /etc/hosts)"}),e.jsxs(v,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:129:13",size:"sm",variant:"ghost",className:"h-6 text-xs text-slate-400",onClick:S,children:[e.jsx(te,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:130:15",className:"h-3 w-3 mr-1"}),"添加"]})]}),r.length===0?e.jsx("p",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:134:13",className:"text-xs text-slate-600 italic",children:"未配置"}):r.map((b,w)=>e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:137:15",className:"flex items-center gap-2",children:[e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:138:17",value:b.ip,onChange:P=>C(w,{ip:P.target.value}),placeholder:"10.10.10.72",className:"w-40 h-7 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:144:17",className:"text-slate-600",children:"→"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:145:17",value:b.hostnames,onChange:P=>C(w,{hostnames:P.target.value}),placeholder:"gitlab.local, registry.local",className:"flex-1 h-7 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:151:17",size:"icon",variant:"ghost",className:"h-6 w-6 text-red-400",onClick:()=>y(w),children:e.jsx(be,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:152:19",className:"h-3 w-3"})})]},w))]})]})]})}function Xn({clusterCode:t,namespace:s,deploymentName:a,manifest:o,onSaved:n,onCancel:c}){const{toast:r}=Me(),[i,k]=d.useState(!1),[l,x]=d.useState(!o),[S,C]=d.useState(o||{}),[y,b]=d.useState("RollingUpdate"),[w,P]=d.useState("25%"),[I,M]=d.useState("25%"),[F,V]=d.useState("10"),[X,q]=d.useState("600"),[W,Q]=d.useState("nodeSelector"),[$,Z]=d.useState(""),[N,_]=d.useState([]),[J,ee]=d.useState(!1),[me,ye]=d.useState([]),[ge,R]=d.useState({}),[p,h]=d.useState([]),[u,A]=d.useState("ClusterFirst"),[L,m]=d.useState("Always"),[g,j]=d.useState("default-scheduler"),[O,xe]=d.useState("30"),[se,B]=d.useState(""),[de,De]=d.useState(""),[Se,Ie]=d.useState(""),[$e,_e]=d.useState(""),[Be,Le]=d.useState(!1),[E,ie]=d.useState(!1),[je,Ne]=d.useState(!1),[Te,mt]=d.useState(!1),[qe,xt]=d.useState(!1),[Ke,Pe]=d.useState([]),[Bt,Rt]=d.useState(""),[Ot,$t]=d.useState(""),[_t,Lt]=d.useState([]);d.useEffect(()=>{const D=o;if(!D){x(!1);return}C(D);const T=D?.spec||{},G=T?.template?.spec||{},ne=T.strategy||{};b(ne.type||"RollingUpdate");const re=ne.rollingUpdate||{};P(String(re.maxSurge??"25%")),M(String(re.maxUnavailable??"25%")),V(T.revisionHistoryLimit!=null?String(T.revisionHistoryLimit):"10"),q(T.progressDeadlineSeconds!=null?String(T.progressDeadlineSeconds):"600");const ke=G.nodeSelector||{},ze=Object.entries(ke).map(([pe,zt])=>({key:pe,value:String(zt)}));ye(ze),Z(G.nodeName||""),G.nodeName?Q("nodeName"):G.affinity?.nodeAffinity?Q("nodeAffinity"):ze.length>0&&Q("nodeSelector"),t&&(ee(!0),K.getClusterNodes(t).then(pe=>{const Wt=(Array.isArray(pe)?pe:pe?.items||pe?.list||[]).map(Xe=>{const He=Xe.metadata||{},Qe=Xe.status||{},Bs=(Array.isArray(Qe.addresses)?Qe.addresses:[]).find(Rs=>Rs.type==="InternalIP")?.address||"";return{name:He.name||"",ip:Bs,labels:He.labels||{}}});_(Wt);const We={};for(const Xe of Wt)for(const[He,Qe]of Object.entries(Xe.labels)){const ut=String(Qe);We[He]||(We[He]=[]),We[He].includes(ut)||We[He].push(ut)}R(We)}).catch(()=>{}).finally(()=>ee(!1)));const Je=Array.isArray(G.tolerations)?G.tolerations:[];h(Je.map(pe=>({key:pe.key||"",operator:pe.operator||"Equal",value:pe.value||"",effect:pe.effect||"",tolerationSeconds:pe.tolerationSeconds!=null?String(pe.tolerationSeconds):""}))),A(G.dnsPolicy||"ClusterFirst"),m(G.restartPolicy||"Always"),j(G.schedulerName||"default-scheduler"),xe(G.terminationGracePeriodSeconds!=null?String(G.terminationGracePeriodSeconds):"30"),B(G.serviceAccountName||"");const we=G.securityContext||{};De(we.fsGroup!=null?String(we.fsGroup):""),Ie(we.runAsUser!=null?String(we.runAsUser):""),_e(we.runAsGroup!=null?String(we.runAsGroup):""),Le(!!we.runAsNonRoot),ie(!!G.hostNetwork),Ne(!!G.hostIPC),mt(!!G.hostPID),xt(!!G.shareProcessNamespace);const z=Array.isArray(G.hostAliases)?G.hostAliases:[];Pe(z.map(pe=>({ip:pe.ip||"",hostnames:Array.isArray(pe.hostnames)?pe.hostnames.join(", "):""})));const oe=G.dnsConfig||{};Rt(Array.isArray(oe.nameservers)?oe.nameservers.join(`
|
||
`):""),$t(Array.isArray(oe.searches)?oe.searches.join(`
|
||
`):"");const ht=Array.isArray(oe.options)?oe.options:[];Lt(ht.map(pe=>({name:pe.name||"",value:pe.value||""}))),x(!1)},[o]);const Ts=()=>ye(D=>[...D,{key:"",value:""}]),Ms=D=>ye(T=>T.filter((G,ne)=>ne!==D)),Hs=(D,T)=>ye(G=>G.map((ne,re)=>re===D?{...ne,...T}:ne)),Is=async()=>{k(!0);try{const D=JSON.parse(JSON.stringify(S));D.spec=D.spec||{},D.spec.template=D.spec.template||{},D.spec.template.spec=D.spec.template.spec||{};const T=D.spec.template.spec;if(D.spec.strategy={type:y},y==="RollingUpdate"&&(D.spec.strategy.rollingUpdate={maxSurge:w,maxUnavailable:I}),F&&(D.spec.revisionHistoryLimit=Number(F)),X&&(D.spec.progressDeadlineSeconds=Number(X)),W==="nodeName"&&$.trim())T.nodeName=$.trim(),delete T.nodeSelector,T.affinity&&delete T.affinity.nodeAffinity;else if(W==="nodeSelector"){const z={};for(const{key:oe,value:ht}of me){const pe=oe.trim();pe&&(z[pe]=ht)}Object.keys(z).length>0?T.nodeSelector=z:delete T.nodeSelector,T.nodeName&&delete T.nodeName,T.affinity&&delete T.affinity.nodeAffinity}else if(W==="nodeAffinity"){const z=me.filter(oe=>oe.key.trim()).map(oe=>({key:oe.key.trim(),operator:"In",values:[oe.value]}));z.length>0?(T.affinity=T.affinity||{},T.affinity.nodeAffinity={requiredDuringSchedulingIgnoredDuringExecution:{nodeSelectorTerms:[{matchExpressions:z}]}}):T.affinity&&delete T.affinity.nodeAffinity,delete T.nodeSelector,T.nodeName&&delete T.nodeName}const G=p.filter(z=>z.key||z.operator==="Exists").map(z=>{const oe={};return z.key&&(oe.key=z.key),z.operator&&(oe.operator=z.operator),z.value&&z.operator!=="Exists"&&(oe.value=z.value),z.effect&&(oe.effect=z.effect),z.tolerationSeconds&&z.effect==="NoExecute"&&(oe.tolerationSeconds=Number(z.tolerationSeconds)),oe});G.length>0?T.tolerations=G:delete T.tolerations,u&&(T.dnsPolicy=u),L&&(T.restartPolicy=L),g&&(T.schedulerName=g),O&&(T.terminationGracePeriodSeconds=Number(O)),se&&(T.serviceAccountName=se);const ne={};de&&(ne.fsGroup=Number(de)),Se&&(ne.runAsUser=Number(Se)),$e&&(ne.runAsGroup=Number($e)),Be&&(ne.runAsNonRoot=!0),Object.keys(ne).length>0?T.securityContext=ne:delete T.securityContext,E?T.hostNetwork=!0:delete T.hostNetwork,je?T.hostIPC=!0:delete T.hostIPC,Te?T.hostPID=!0:delete T.hostPID,qe?T.shareProcessNamespace=!0:delete T.shareProcessNamespace;const re=Ke.filter(z=>z.ip.trim()).map(z=>({ip:z.ip.trim(),hostnames:z.hostnames.split(/[,\s]+/).map(oe=>oe.trim()).filter(Boolean)})).filter(z=>z.hostnames.length>0);re.length>0?T.hostAliases=re:delete T.hostAliases;const ke={},ze=Bt.split(`
|
||
`).map(z=>z.trim()).filter(Boolean);ze.length>0&&(ke.nameservers=ze);const Je=Ot.split(`
|
||
`).map(z=>z.trim()).filter(Boolean);Je.length>0&&(ke.searches=Je);const we=_t.filter(z=>z.name.trim()).map(z=>{const oe={name:z.name.trim()};return z.value.trim()&&(oe.value=z.value.trim()),oe});we.length>0&&(ke.options=we),Object.keys(ke).length>0?T.dnsConfig=ke:delete T.dnsConfig,await pt(t,s,a,D),r({title:"高级设置已保存",description:`${a} 更新已提交`}),n(D)}catch(D){r({title:"保存失败",description:D?.message||String(D),variant:"destructive"})}finally{k(!1)}};return l?e.jsx(U,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:323:7",className:"bg-slate-900 border-slate-800",children:e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:324:9",className:"p-12 text-center",children:[e.jsx(ve,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:325:11",className:"h-6 w-6 animate-spin mx-auto text-slate-500"}),e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:326:11",className:"text-slate-500 mt-3 text-sm",children:"加载中..."})]})}):o?e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:343:5",className:"space-y-4",children:[e.jsxs(U,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:345:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:346:9",className:"pb-3",children:e.jsxs(ue,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:347:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(Ye,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:348:13",className:"h-4 w-4 text-blue-400"}),"更新策略 (Strategy)"]})}),e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:351:9",className:"pt-0 space-y-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:352:11",className:"flex items-center gap-4",children:[e.jsxs("label",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:353:13",className:"flex items-center gap-1.5 text-xs text-slate-300 cursor-pointer",children:[e.jsx("input",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:354:15",type:"radio",checked:y==="RollingUpdate",onChange:()=>b("RollingUpdate"),className:"accent-blue-500"}),"RollingUpdate(滚动更新)"]}),e.jsxs("label",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:358:13",className:"flex items-center gap-1.5 text-xs text-slate-300 cursor-pointer",children:[e.jsx("input",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:359:15",type:"radio",checked:y==="Recreate",onChange:()=>b("Recreate"),className:"accent-blue-500"}),"Recreate(重建)"]})]}),y==="RollingUpdate"&&e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:365:13",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:366:15",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:367:17",className:"text-slate-500 text-xs",children:"maxSurge(整数或百分比,超出期望副本数)"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:368:17",value:w,onChange:D=>P(D.target.value),placeholder:"25%",className:"h-8 mt-1 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:371:15",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:372:17",className:"text-slate-500 text-xs",children:"maxUnavailable(整数或百分比,不可用上限)"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:373:17",value:I,onChange:D=>M(D.target.value),placeholder:"25%",className:"h-8 mt-1 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]})]})]})]}),e.jsxs(U,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:382:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:383:9",className:"pb-3",children:e.jsxs(ue,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:384:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(vs,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:385:13",className:"h-4 w-4 text-amber-400"}),"历史版本 & 进度"]})}),e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:388:9",className:"pt-0 grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:389:11",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:390:13",className:"text-slate-500 text-xs",children:"revisionHistoryLimit(保留 RS 历史)"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:391:13",type:"number",value:F,onChange:D=>V(D.target.value),className:"h-8 mt-1 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:394:11",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:395:13",className:"text-slate-500 text-xs",children:"progressDeadlineSeconds(升级超时秒数)"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:396:13",type:"number",value:X,onChange:D=>q(D.target.value),className:"h-8 mt-1 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]})]})]}),e.jsxs(U,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:403:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:404:9",className:"pb-3",children:e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:405:11",className:"flex items-center justify-between",children:[e.jsx(ue,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:406:13",className:"text-sm text-slate-200",children:"容忍 (Tolerations)"}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:407:13",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:()=>h(D=>[...D,{key:"",operator:"Equal",value:"",effect:"NoSchedule",tolerationSeconds:""}]),children:[e.jsx(te,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:409:15",className:"h-3 w-3 mr-1"}),"添加"]})]})}),e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:413:9",className:"pt-0 space-y-2",children:[p.length===0&&e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:414:40",className:"text-xs text-slate-600",children:"未配置容忍"}),p.map((D,T)=>e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:416:13",className:"grid grid-cols-[1fr_80px_1fr_100px_80px_auto] gap-2 items-center",children:[e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:417:15",value:D.key,placeholder:"key",onChange:G=>h(ne=>ne.map((re,ke)=>ke===T?{...re,key:G.target.value}:re)),className:"h-7 bg-slate-800 border-slate-700 text-xs font-mono"}),e.jsxs("select",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:419:15",value:D.operator,onChange:G=>h(ne=>ne.map((re,ke)=>ke===T?{...re,operator:G.target.value}:re)),className:"h-7 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-1",children:[e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:421:17",value:"Equal",children:"Equal"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:422:17",value:"Exists",children:"Exists"})]}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:424:15",value:D.value,placeholder:"value",disabled:D.operator==="Exists",onChange:G=>h(ne=>ne.map((re,ke)=>ke===T?{...re,value:G.target.value}:re)),className:"h-7 bg-slate-800 border-slate-700 text-xs font-mono"}),e.jsxs("select",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:427:15",value:D.effect,onChange:G=>h(ne=>ne.map((re,ke)=>ke===T?{...re,effect:G.target.value}:re)),className:"h-7 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-1",children:[e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:429:17",value:"",children:"任意"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:430:17",value:"NoSchedule",children:"NoSchedule"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:431:17",value:"PreferNoSchedule",children:"PreferNoSchedule"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:432:17",value:"NoExecute",children:"NoExecute"})]}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:434:15",value:D.tolerationSeconds,placeholder:"秒",disabled:D.effect!=="NoExecute",onChange:G=>h(ne=>ne.map((re,ke)=>ke===T?{...re,tolerationSeconds:G.target.value}:re)),className:"h-7 bg-slate-800 border-slate-700 text-xs font-mono"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:437:15",variant:"ghost",size:"icon",className:"h-7 w-7 text-red-400",onClick:()=>h(G=>G.filter((ne,re)=>re!==T)),children:e.jsx(be,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:438:17",className:"h-3 w-3"})})]},T))]})]}),e.jsx(Kn,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:445:7",scheduleMode:W,onScheduleModeChange:Q,nodeName:$,onNodeNameChange:Z,availableNodes:N,nodesLoading:J,labelSelectorKv:me,onAddLabelSelector:Ts,onRemoveLabelSelector:Ms,onUpdateLabelSelector:Hs,nodeLabels:ge}),e.jsxs(U,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:460:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:461:9",className:"pb-3",children:e.jsxs(ue,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:462:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(wt,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:463:13",className:"h-4 w-4 text-slate-400"}),"Pod 级别"]})}),e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:466:9",className:"pt-0 grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:467:11",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:468:13",className:"text-slate-500 text-xs",children:"dnsPolicy"}),e.jsxs("select",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:469:13",value:u,onChange:D=>A(D.target.value),className:"h-8 mt-1 w-full bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-2",children:[e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:471:15",value:"ClusterFirst",children:"ClusterFirst"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:472:15",value:"ClusterFirstWithHostNet",children:"ClusterFirstWithHostNet"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:473:15",value:"Default",children:"Default"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:474:15",value:"None",children:"None"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:477:11",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:478:13",className:"text-slate-500 text-xs",children:"restartPolicy"}),e.jsxs("select",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:479:13",value:L,onChange:D=>m(D.target.value),className:"h-8 mt-1 w-full bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-2",children:[e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:481:15",value:"Always",children:"Always"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:482:15",value:"OnFailure",children:"OnFailure"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:483:15",value:"Never",children:"Never"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:486:11",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:487:13",className:"text-slate-500 text-xs",children:"schedulerName"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:488:13",value:g,onChange:D=>j(D.target.value),className:"h-8 mt-1 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:491:11",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:492:13",className:"text-slate-500 text-xs",children:"terminationGracePeriodSeconds"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:493:13",type:"number",value:O,onChange:D=>xe(D.target.value),className:"h-8 mt-1 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:496:11",className:"col-span-2",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:497:13",className:"text-slate-500 text-xs",children:"serviceAccountName"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:498:13",value:se,onChange:D=>B(D.target.value),placeholder:"default",className:"h-8 mt-1 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]})]})]}),e.jsxs(U,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:505:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:506:9",className:"pb-3",children:e.jsxs(ue,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:507:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(js,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:508:13",className:"h-4 w-4 text-rose-400"}),"Pod 安全上下文 (securityContext)"]})}),e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:511:9",className:"pt-0 grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:512:11",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:513:13",className:"text-slate-500 text-xs",children:"fsGroup"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:514:13",type:"number",value:de,onChange:D=>De(D.target.value),placeholder:"1000",className:"h-8 mt-1 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:517:11",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:518:13",className:"text-slate-500 text-xs",children:"runAsUser"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:519:13",type:"number",value:Se,onChange:D=>Ie(D.target.value),placeholder:"1000",className:"h-8 mt-1 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:522:11",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:523:13",className:"text-slate-500 text-xs",children:"runAsGroup"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:524:13",type:"number",value:$e,onChange:D=>_e(D.target.value),placeholder:"1000",className:"h-8 mt-1 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]}),e.jsx("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:527:11",className:"flex items-end pb-1",children:e.jsxs("label",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:528:13",className:"flex items-center gap-2 text-xs text-slate-400 cursor-pointer",children:[e.jsx("input",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:529:15",type:"checkbox",checked:Be,onChange:D=>Le(D.target.checked),className:"accent-blue-500"}),"runAsNonRoot"]})})]})]}),e.jsxs(U,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:538:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:539:9",className:"pb-3",children:e.jsxs(ue,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:540:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(Ae,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:541:13",className:"h-4 w-4 text-cyan-400"}),"主机设置 (Host Namespace)"]})}),e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:544:9",className:"pt-0 grid grid-cols-2 gap-3",children:[e.jsxs("label",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:545:11",className:"flex items-center gap-2 text-xs text-slate-300 cursor-pointer",children:[e.jsx("input",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:546:13",type:"checkbox",checked:E,onChange:D=>ie(D.target.checked),className:"accent-blue-500"}),"hostNetwork(共享主机网络命名空间)"]}),e.jsxs("label",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:550:11",className:"flex items-center gap-2 text-xs text-slate-300 cursor-pointer",children:[e.jsx("input",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:551:13",type:"checkbox",checked:je,onChange:D=>Ne(D.target.checked),className:"accent-blue-500"}),"hostIPC(共享主机 IPC 命名空间)"]}),e.jsxs("label",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:555:11",className:"flex items-center gap-2 text-xs text-slate-300 cursor-pointer",children:[e.jsx("input",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:556:13",type:"checkbox",checked:Te,onChange:D=>mt(D.target.checked),className:"accent-blue-500"}),"hostPID(共享主机 PID 命名空间)"]}),e.jsxs("label",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:560:11",className:"flex items-center gap-2 text-xs text-slate-300 cursor-pointer",children:[e.jsx("input",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:561:13",type:"checkbox",checked:qe,onChange:D=>xt(D.target.checked),className:"accent-blue-500"}),"shareProcessNamespace(共享进程命名空间)"]})]})]}),e.jsx(Jn,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:568:7",dnsNameservers:Bt,onDnsNameserversChange:Rt,dnsSearches:Ot,onDnsSearchesChange:$t,dnsOptions:_t,onDnsOptionsChange:Lt,hostAliases:Ke,onHostAliasesChange:Pe}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:580:7",className:"flex justify-end gap-2 pt-2",children:[e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:581:9",variant:"outline",className:"border-slate-700 text-slate-400",onClick:c,children:"取消"}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:582:9",className:"bg-blue-600 hover:bg-blue-700",disabled:i,onClick:Is,children:[i?e.jsx(ve,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:583:21",className:"h-4 w-4 animate-spin mr-1"}):e.jsx(it,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:583:73",className:"h-4 w-4 mr-1"}),"保存"]})]})]}):e.jsx(U,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:334:7",className:"bg-slate-900 border-slate-800",children:e.jsx(Y,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:335:9",className:"p-8 text-center text-slate-500",children:"未获取到 manifest 数据,请使用 YAML 编辑模式直接修改。"})})}const Qn=[{label:"HTTP",protocol:"TCP",port:8080,targetPort:8080,name:"http"},{label:"WebSocket",protocol:"TCP",port:8001,targetPort:8002,name:"ws"},{label:"gRPC",protocol:"TCP",port:8002,targetPort:8002,name:"grpc"}],rs=t=>Array.isArray(t)?t:t?.list||t?.items||t?.data||[];function Zn({clusterCode:t,namespace:s,deploymentName:a,manifest:o,onSaved:n,onCancel:c}){const{toast:r}=Me(),i=dt(),[k,l]=d.useState(!0),[x,S]=d.useState([]),[C,y]=d.useState([]),[b,w]=d.useState({}),[P,I]=d.useState(null),[M,F]=d.useState(null),[V,X]=d.useState({name:"",type:"ClusterIP",ports:[{name:"http",port:"8080",targetPort:"8080",protocol:"TCP",nodePort:""}]}),[q,W]=d.useState({name:"",className:"nginx",host:"",path:"/",pathType:"Prefix",svcPort:"80"}),Q=p=>{X(h=>({...h,ports:[...h.ports,p?{name:p.name,port:String(p.port),targetPort:String(p.targetPort),protocol:p.protocol,nodePort:""}:{name:"",port:"",targetPort:"",protocol:"TCP",nodePort:""}]}))},$=(p,h,u)=>{X(A=>({...A,ports:A.ports.map((L,m)=>m===p?{...L,[h]:u}:L)}))},Z=p=>{V.ports.length<=1||X(h=>({...h,ports:h.ports.filter((u,A)=>A!==p)}))},N=d.useCallback(async()=>{l(!0);try{const p=o?.spec?.selector?.matchLabels||o?.selector||{};w(p);const[h,u]=await Promise.all([K.getNamespaceServices(t,s).catch(()=>[]),K.getNamespaceIngresses(t,s).catch(()=>[])]),A=rs(h),L=rs(u),m=A.map(j=>{const O=j.spec||{},xe=Array.isArray(O.ports)?O.ports.map(se=>({port:se.port,targetPort:se.targetPort,protocol:se.protocol||"TCP",nodePort:se.nodePort,name:se.name})):Array.isArray(j.portList)?j.portList.map(se=>({port:se.port,targetPort:se.targetPort,protocol:se.protocol||"TCP",nodePort:se.nodePort,name:se.name})):[];return{name:j.name||j.metadata?.name||"",type:O.type||j.type||"ClusterIP",clusterIP:O.clusterIP||j.cluster_ip||"<none>",externalIP:Array.isArray(O.externalIPs)?O.externalIPs.join(","):"",ports:xe,selector:O.selector||j.selector||{},age:j.age||j.created_at||"",raw:j}}),g=L.map(j=>{const O=j.spec||{},se=(Array.isArray(O.rules)?O.rules:Array.isArray(j.rules)?j.rules:[]).map(B=>({host:B.host||"",paths:(B.http?.paths||B.paths||[]).map(de=>({path:de.path||"/",backend:{service:de.backend?.service?.name||de.backendService||"",port:de.backend?.service?.port?.number||de.backend?.service?.port?.name||de.backendPort||""}}))}));return{name:j.name||j.metadata?.name||"",className:O.ingressClassName||j.ingressClass||"<none>",hosts:se.map(B=>B.host).filter(Boolean),rules:se,raw:j}});S(m),y(g)}catch(p){console.error("M9 load error:",p)}finally{l(!1)}},[t,s,o]);d.useEffect(()=>{N()},[N]);const _=p=>Object.keys(p).length===0?!1:Object.entries(p).every(([h,u])=>b[h]===u),J=x.filter(p=>_(p.selector)),ee=new Set(J.map(p=>p.name)),me=C.filter(p=>p.rules.some(h=>h.paths.some(u=>ee.has(u.backend.service)))),ye=async()=>{const p=V.name.trim()||`${a}-svc`,h=V.ports.map(A=>{const L={name:A.name||"http",port:Number(A.port)||80,targetPort:/^\d+$/.test(String(A.targetPort))?Number(A.targetPort):A.targetPort,protocol:A.protocol||"TCP"};return V.type==="NodePort"&&A.nodePort&&(L.nodePort=Number(A.nodePort)),L}),u={apiVersion:"v1",kind:"Service",metadata:{name:p,namespace:s,labels:{app:a}},spec:{type:V.type,selector:b,ports:h}};try{const A=await Gt(u);await K.applyYAML(t,A),r({title:"Service 已创建",description:p}),F(null),N()}catch(A){r({title:"创建失败",description:A?.message||String(A),variant:"destructive"})}},ge=async()=>{const p=q.name.trim()||`${a}-ingress`,h=J[0]?.name||`${a}-svc`,u=Number(q.svcPort)||80,A={apiVersion:"networking.k8s.io/v1",kind:"Ingress",metadata:{name:p,namespace:s,labels:{app:a}},spec:{ingressClassName:q.className||void 0,rules:[{host:q.host||void 0,http:{paths:[{path:q.path||"/",pathType:q.pathType||"Prefix",backend:{service:{name:h,port:{number:u}}}}]}}]}};q.className||delete A.spec.ingressClassName;try{const L=await Gt(A);await K.applyYAML(t,L),r({title:"Ingress 已创建",description:p}),F(null),N()}catch(L){r({title:"创建失败",description:L?.message||String(L),variant:"destructive"})}},R=async(p,h)=>{if(await i({title:"删除资源",description:`确认删除 ${p==="service"?"Service":"Ingress"} 「${h}」?此操作不可撤销。`,confirmText:"删除",variant:"destructive"}))try{const A=p==="service"?"services":"ingresses";await K.deleteResourceYaml(t,s,A,h),r({title:"已删除",description:`${p==="service"?"Service":"Ingress"} ${h} 已删除`}),N()}catch(A){r({title:"删除失败",description:A?.message||String(A),variant:"destructive"})}};return k?e.jsx(U,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:291:7",className:"bg-slate-900 border-slate-800",children:e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:292:9",className:"p-12 text-center",children:[e.jsx(ve,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:293:11",className:"h-6 w-6 animate-spin mx-auto text-slate-500"}),e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:294:11",className:"text-slate-500 mt-3 text-sm",children:"加载中..."})]})}):e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:301:5",className:"space-y-4",children:[e.jsx(U,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:303:7",className:"bg-slate-900/50 border-slate-800",children:e.jsx(Y,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:304:9",className:"p-3",children:e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:305:11",className:"flex items-center gap-2 text-xs text-slate-400",children:[e.jsx(Ae,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:306:13",className:"h-3.5 w-3.5 text-blue-400"}),e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:307:13",children:"选择器:"}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:308:13",className:"flex flex-wrap gap-1",children:[Object.entries(b).map(([p,h])=>e.jsxs("code",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:310:17",className:"bg-slate-800 px-1.5 py-0.5 rounded text-slate-300 text-[11px]",children:[p,"=",h]},p)),Object.keys(b).length===0&&e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:313:17",className:"text-slate-600 italic",children:"(无 selector)"})]}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:316:13",size:"sm",variant:"ghost",className:"h-6 ml-auto text-xs text-slate-400",onClick:N,children:[e.jsx(Ye,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:317:15",className:"h-3 w-3 mr-1"}),"刷新"]})]})})}),e.jsxs(U,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:324:7",className:"bg-slate-900 border-slate-800",children:[e.jsxs(he,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:325:9",className:"pb-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:326:11",className:"flex items-center justify-between",children:[e.jsxs(ue,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:327:13",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(Ae,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:328:15",className:"h-4 w-4 text-blue-400"}),"Services",e.jsxs(ae,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:330:15",variant:"outline",className:"border-slate-700 text-slate-400",children:[J.length," 个关联"]})]}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:332:13",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:()=>{X({name:`${a}-svc`,type:"ClusterIP",ports:[{name:"http",port:"8080",targetPort:"8080",protocol:"TCP",nodePort:""}]}),F("service")},children:[e.jsx(te,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:337:15",className:"h-3 w-3 mr-1"}),"创建 Service"]})]}),e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:340:11",className:"text-xs text-slate-500 mt-1",children:"仅显示 selector 匹配此 Deployment 的关联 Service"})]}),e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:342:9",className:"pt-0",children:[J.length===0&&M!=="service"?e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:344:13",className:"text-center py-6 text-slate-500 text-sm border border-dashed border-slate-800 rounded-lg",children:[e.jsx(Ae,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:345:15",className:"h-8 w-8 mx-auto mb-2 text-slate-700"}),"当前命名空间暂无关联 Service"]}):e.jsx("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:349:13",className:"space-y-2",children:J.map(p=>{const h=_(p.selector);return e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:353:19",className:`rounded-lg border p-3 ${h?"border-blue-700/50 bg-blue-950/20":"border-slate-800 bg-slate-950/30"}`,children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:354:21",className:"flex items-center gap-2 flex-wrap",children:[h?e.jsx(Ct,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:355:34",className:"h-4 w-4 text-blue-400"}):e.jsx(Ae,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:355:86",className:"h-4 w-4 text-slate-500"}),e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:356:23",className:"text-sm font-semibold text-slate-200",children:p.name}),e.jsx(ae,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:357:23",variant:"outline",className:"border-slate-700 text-slate-400 text-[10px]",children:p.type}),h&&e.jsx(ae,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:358:35",className:"bg-blue-500/20 text-blue-300 border-blue-500/30 text-[10px]",children:"关联"}),e.jsx("code",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:359:23",className:"text-[11px] text-slate-500 ml-auto",children:p.clusterIP}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:360:23",size:"sm",variant:"ghost",className:"h-6 text-xs text-emerald-400",onClick:()=>I({resource:"services",name:p.name}),children:[e.jsx(Ut,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:362:25",className:"h-3 w-3 mr-1"}),"编辑"]}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:364:23",size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-red-400 hover:text-red-300",title:"删除 Service",onClick:()=>R("service",p.name),children:e.jsx(be,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:366:25",className:"h-3 w-3"})})]}),e.jsx("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:370:21",className:"mt-2 flex flex-wrap gap-1.5 text-[11px]",children:p.ports.map((u,A)=>e.jsxs("code",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:372:25",className:"bg-slate-800/60 px-1.5 py-0.5 rounded text-slate-300",children:[u.name&&e.jsxs("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:373:38",className:"text-slate-500",children:[u.name,": "]}),u.port,"→",u.targetPort,u.nodePort?`/NodePort:${u.nodePort}`:"","/",u.protocol]},A))}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:379:21",className:"mt-1 flex flex-wrap gap-1 text-[10px]",children:[e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:380:23",className:"text-slate-600",children:"selector:"}),Object.entries(p.selector).map(([u,A])=>e.jsxs("code",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:382:25",className:"text-slate-500",children:[u,"=",A]},u))]})]},p.name)})}),M==="service"&&e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:393:13",className:"mt-3 border border-blue-800/50 rounded-lg p-3 bg-blue-950/20 space-y-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:394:15",className:"text-xs font-semibold text-blue-300 flex items-center gap-1.5",children:[e.jsx(te,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:395:17",className:"h-3 w-3"}),"创建新 Service"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:399:15",className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:400:17",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:401:19",className:"text-slate-500 text-[11px]",children:"名称"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:402:19",value:V.name,onChange:p=>X(h=>({...h,name:p.target.value})),placeholder:`${a}-svc`,className:"h-7 mt-0.5 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:406:17",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:407:19",className:"text-slate-500 text-[11px]",children:"类型"}),e.jsxs("select",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:408:19",value:V.type,onChange:p=>X(h=>({...h,type:p.target.value})),className:"h-7 mt-0.5 w-full bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-2",children:[e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:410:21",value:"ClusterIP",children:"ClusterIP"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:411:21",value:"NodePort",children:"NodePort"})]})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:417:15",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:418:17",className:"text-slate-500 text-[11px] mb-1 block",children:"快速添加常用端口"}),e.jsx("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:419:17",className:"flex gap-1.5",children:Qn.map(p=>e.jsxs("button",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:421:21",onClick:()=>Q(p),className:`flex items-center gap-1 px-2 py-1 rounded text-[10px] font-medium
|
||
bg-slate-800 border border-slate-700 text-slate-300 hover:border-blue-500/50 hover:text-blue-300 transition-colors`,children:[e.jsx(gs,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:424:23",className:"h-2.5 w-2.5"}),p.label,e.jsxs("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:426:23",className:"text-slate-500 text-[9px]",children:[p.protocol," ",p.port,":",p.targetPort]})]},p.name))})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:433:15",className:"space-y-2",children:[e.jsxs(H,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:434:17",className:"text-slate-500 text-[11px]",children:["端口配置 ",e.jsxs("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:435:24",className:"text-slate-600",children:["(",V.ports.length," 个端口)"]})]}),V.ports.map((p,h)=>e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:438:19",className:"flex items-center gap-1.5 p-2 rounded bg-slate-800/50 border border-slate-700/50",children:[e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:440:21",value:p.name,onChange:u=>$(h,"name",u.target.value),placeholder:"http",className:"h-7 w-[72px] bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsxs("select",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:444:21",value:p.protocol,onChange:u=>$(h,"protocol",u.target.value),className:"h-7 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-1.5 w-16",children:[e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:446:23",value:"TCP",children:"TCP"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:447:23",value:"UDP",children:"UDP"})]}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:450:21",value:p.port,onChange:u=>$(h,"port",u.target.value),type:"number",placeholder:"port",className:"h-7 w-[72px] bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:453:21",className:"text-slate-600 text-[10px]",children:"→"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:454:21",value:p.targetPort,onChange:u=>$(h,"targetPort",u.target.value),type:"number",placeholder:"targetPort",className:"h-7 w-[72px] bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),V.type==="NodePort"&&e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:459:23",value:p.nodePort,onChange:u=>$(h,"nodePort",u.target.value),type:"number",placeholder:"30000-32767",className:"h-7 w-[80px] bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:464:21",size:"icon",variant:"ghost",className:"h-6 w-6 text-slate-500 hover:text-red-400",onClick:()=>Z(h),disabled:V.ports.length<=1,children:e.jsx(Tt,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:466:23",className:"h-3 w-3"})})]},h)),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:471:17",size:"sm",variant:"outline",className:"h-7 w-full border-dashed border-slate-700 text-slate-400 text-xs",onClick:()=>Q(),children:[e.jsx(te,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:473:19",className:"h-3 w-3 mr-1"}),"添加自定义端口"]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:478:15",className:"text-[10px] text-slate-500 border-t border-slate-700/50 pt-2",children:[e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:479:17",className:"text-slate-600",children:"selector (自动检测): "}),Object.keys(b).length>0?Object.entries(b).map(([p,h])=>e.jsxs("code",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:482:21",className:"bg-slate-800 px-1 py-0.5 rounded text-slate-400 ml-1",children:[p,"=",h]},p)):e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:485:19",className:"text-slate-600 italic",children:"未检测到"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:489:15",className:"flex justify-end gap-2 pt-1",children:[e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:490:17",size:"sm",variant:"ghost",className:"h-7 text-xs text-slate-400",onClick:()=>F(null),children:"取消"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:491:17",size:"sm",className:"h-7 bg-blue-600 hover:bg-blue-700 text-xs",onClick:ye,children:"创建"})]})]})]})]}),e.jsxs(U,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:499:7",className:"bg-slate-900 border-slate-800",children:[e.jsxs(he,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:500:9",className:"pb-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:501:11",className:"flex items-center justify-between",children:[e.jsxs(ue,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:502:13",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(jt,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:503:15",className:"h-4 w-4 text-purple-400"}),"Ingresses (应用路由)",e.jsxs(ae,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:505:15",variant:"outline",className:"border-slate-700 text-slate-400",children:[me.length,"/",C.length]})]}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:507:13",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:()=>{W(p=>({...p,name:`${a}-ingress`,svcPort:String(J[0]?.ports[0]?.port||80)})),F("ingress")},children:[e.jsx(te,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:512:15",className:"h-3 w-3 mr-1"}),"创建 Ingress"]})]}),e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:515:11",className:"text-xs text-slate-500 mt-1",children:"backend 指向关联 Service 的 Ingress 自动高亮"})]}),e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:517:9",className:"pt-0",children:[C.length===0?e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:519:13",className:"text-center py-6 text-slate-500 text-sm border border-dashed border-slate-800 rounded-lg",children:[e.jsx(jt,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:520:15",className:"h-8 w-8 mx-auto mb-2 text-slate-700"}),"当前命名空间暂无 Ingress"]}):e.jsx("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:524:13",className:"space-y-2",children:C.map(p=>{const h=me.includes(p);return e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:528:19",className:`rounded-lg border p-3 ${h?"border-purple-700/50 bg-purple-950/20":"border-slate-800 bg-slate-950/30"}`,children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:529:21",className:"flex items-center gap-2 flex-wrap",children:[h?e.jsx(Ct,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:530:34",className:"h-4 w-4 text-purple-400"}):e.jsx(jt,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:530:88",className:"h-4 w-4 text-slate-500"}),e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:531:23",className:"text-sm font-semibold text-slate-200",children:p.name}),e.jsx(ae,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:532:23",variant:"outline",className:"border-slate-700 text-slate-400 text-[10px]",children:p.className}),h&&e.jsx(ae,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:533:35",className:"bg-purple-500/20 text-purple-300 border-purple-500/30 text-[10px]",children:"关联"}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:534:23",size:"sm",variant:"ghost",className:"h-6 text-xs text-emerald-400 ml-auto",onClick:()=>I({resource:"ingresses",name:p.name}),children:[e.jsx(Ut,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:536:25",className:"h-3 w-3 mr-1"}),"编辑"]}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:538:23",size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-red-400 hover:text-red-300",title:"删除 Ingress",onClick:()=>R("ingress",p.name),children:e.jsx(be,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:540:25",className:"h-3 w-3"})})]}),e.jsx("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:544:21",className:"mt-2 space-y-1 text-[11px]",children:p.rules.map((u,A)=>e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:546:25",className:"flex items-start gap-1.5",children:[e.jsx(Mt,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:547:27",className:"h-3 w-3 text-slate-500 mt-0.5"}),e.jsx("code",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:548:27",className:"text-slate-300",children:u.host||"*"}),u.paths.map((L,m)=>e.jsxs("code",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:550:29",className:"bg-slate-800/60 px-1.5 py-0.5 rounded text-slate-400",children:[L.path," → ",L.backend?.service,":",L.backend?.port]},m))]},A))})]},p.name)})}),M==="ingress"&&e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:565:13",className:"mt-3 border border-purple-800/50 rounded-lg p-3 bg-purple-950/20 space-y-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:566:15",className:"text-xs font-semibold text-purple-300 flex items-center gap-1.5",children:[e.jsx(te,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:567:17",className:"h-3 w-3"}),"创建新 Ingress"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:569:15",className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:570:17",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:571:19",className:"text-slate-500 text-[11px]",children:"名称"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:572:19",value:q.name,onChange:p=>W(h=>({...h,name:p.target.value})),placeholder:`${a}-ingress`,className:"h-7 mt-0.5 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:576:17",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:577:19",className:"text-slate-500 text-[11px]",children:"ingressClassName"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:578:19",value:q.className,onChange:p=>W(h=>({...h,className:p.target.value})),placeholder:"nginx",className:"h-7 mt-0.5 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:582:17",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:583:19",className:"text-slate-500 text-[11px]",children:"host (域名)"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:584:19",value:q.host,onChange:p=>W(h=>({...h,host:p.target.value})),placeholder:"app.example.com",className:"h-7 mt-0.5 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:588:17",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:589:19",className:"text-slate-500 text-[11px]",children:"path"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:590:19",value:q.path,onChange:p=>W(h=>({...h,path:p.target.value})),placeholder:"/",className:"h-7 mt-0.5 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:594:17",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:595:19",className:"text-slate-500 text-[11px]",children:"Service 端口"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:596:19",type:"number",value:q.svcPort,onChange:p=>W(h=>({...h,svcPort:p.target.value})),className:"h-7 mt-0.5 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:600:15",className:"flex justify-end gap-2 pt-1",children:[e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:601:17",size:"sm",variant:"ghost",className:"h-7 text-xs text-slate-400",onClick:()=>F(null),children:"取消"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:602:17",size:"sm",className:"h-7 bg-purple-600 hover:bg-purple-700 text-xs",onClick:ge,children:"创建"})]})]})]})]}),P&&e.jsx(Cs,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:610:9",clusterCode:t,namespace:s,resource:P.resource,name:P.name,onClose:()=>I(null),onSaved:()=>{I(null),N()}}),e.jsx("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:620:7",className:"flex justify-end gap-2 pt-2",children:e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:621:9",size:"sm",variant:"outline",className:"h-7 text-xs border-slate-700 text-slate-400",onClick:c,children:"返回查看"})})]})}function cs({clusterCode:t,namespace:s,deploymentName:a,manifest:o,onSaved:n,onCancel:c,isCreate:r=!1}){const[i,k]=d.useState("basic"),[l,x]=d.useState(o);d.useEffect(()=>{o&&x(o)},[o]);const S=b=>{b&&x(b),n(b)},C=[{key:"basic",label:"基本信息",icon:wt},{key:"containers",label:"容器信息",icon:Ue},{key:"storage",label:"存储挂载",icon:tt},{key:"advanced",label:"高级设置",icon:wt},{key:"service",label:"服务/应用路由",icon:Ae}],y={clusterCode:t,namespace:s,deploymentName:a,manifest:l,onSaved:S,onCancel:c,isCreate:r};return e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/EditModeContainer.tsx:54:5",className:"space-y-4",children:[e.jsx("div",{"code-path":"src/components/kubernetes/deployment-workload/EditModeContainer.tsx:55:7",className:"flex items-center gap-1 border-b border-slate-800 pb-px overflow-x-auto",children:C.map(b=>{const w=i===b.key,P=b.icon;return e.jsxs("button",{"code-path":"src/components/kubernetes/deployment-workload/EditModeContainer.tsx:60:13",onClick:()=>k(b.key),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium border-b-2 transition-colors whitespace-nowrap ${w?"border-blue-500 text-blue-400":"border-transparent text-slate-400 hover:text-slate-200"}`,children:[e.jsx(P,{"code-path":"src/components/kubernetes/deployment-workload/EditModeContainer.tsx:67:15",className:"h-3.5 w-3.5"}),b.label]},b.key)})}),i==="basic"&&e.jsx(Tn,{"code-path":"src/components/kubernetes/deployment-workload/EditModeContainer.tsx:74:33",...y}),i==="containers"&&e.jsx(In,{"code-path":"src/components/kubernetes/deployment-workload/EditModeContainer.tsx:75:38",...y}),i==="storage"&&e.jsx(Yn,{"code-path":"src/components/kubernetes/deployment-workload/EditModeContainer.tsx:76:35",...y}),i==="advanced"&&e.jsx(Xn,{"code-path":"src/components/kubernetes/deployment-workload/EditModeContainer.tsx:77:36",...y}),i==="service"&&e.jsx(Zn,{"code-path":"src/components/kubernetes/deployment-workload/EditModeContainer.tsx:78:35",...y})]})}function eo({clusterCode:t,namespace:s,deploymentName:a,image:o="",containerName:n=""}){const c=Ws(),[r,i]=d.useState(!0),[k,l]=d.useState(!1),[x,S]=d.useState(!1),[C,y]=d.useState("");d.useEffect(()=>{let V=!1;return(async()=>{i(!0);const X=Ls();X&&y(X);try{const q=await zs.getApiAccessKey();V||(l(!!q?.has_token),S(!!q?.expired))}catch{V||l(!!X)}finally{V||i(!1)}})(),()=>{V=!0}},[]);const b=`${c}/kubernetes/${t}/namespace/${s}/deployments/${a}/update-image`,w=`${c}/kubernetes/${t}/namespace/${s}/deployments/${a}/restart`,P=d.useMemo(()=>{const V={image:o||"<新镜像地址>"};return n&&(V.container_name=n),JSON.stringify(V)},[o,n]),I=C?`curl -X POST '${b}' \\
|
||
-H 'X-AIOps-Access-Key: ${C}' \\
|
||
-H 'Content-Type: application/json' \\
|
||
-d '${P}'`:`curl -X POST '${b}' \\
|
||
-H 'X-AIOps-Access-Key: <个人中心生成的访问密钥>' \\
|
||
-H 'Content-Type: application/json' \\
|
||
-d '${P}'`,M=C?`curl -X POST '${w}' \\
|
||
-H 'X-AIOps-Access-Key: ${C}'`:`curl -X POST '${w}' \\
|
||
-H 'X-AIOps-Access-Key: <个人中心生成的访问密钥>'`,F=!!C&&!x;return e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:82:5",className:"space-y-4",children:[e.jsx("div",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:83:7",className:"rounded-md bg-[var(--dg-bg-tertiary)]/50 px-3 py-2 text-xs text-[var(--dg-text-muted)] leading-relaxed",children:r?e.jsxs("span",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:85:11",className:"inline-flex items-center gap-1.5",children:[e.jsx(ve,{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:86:13",className:"h-3 w-3 animate-spin"}),"正在读取 API 密钥…"]}):x?e.jsxs(e.Fragment,{children:["访问凭证已过期,请前往",e.jsx(yt,{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:91:13",to:"/profile",className:"text-[var(--dg-blue)] hover:underline mx-1",children:"个人中心"}),"调整有效期或轮换凭证后再复制 curl。"]}):C?e.jsx(e.Fragment,{children:"已填入本机保存的访问凭证,复制 curl 后可直接在终端执行触发更新。"}):k?e.jsxs(e.Fragment,{children:["已检测到访问凭证,但本机未缓存明文。请前往",e.jsx(yt,{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:99:13",to:"/profile",className:"text-[var(--dg-blue)] hover:underline mx-1",children:"个人中心"}),"轮换凭证一次,之后 curl 将自动填入。"]}):e.jsxs(e.Fragment,{children:["请先在",e.jsx(yt,{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:105:13",to:"/profile",className:"text-[var(--dg-blue)] hover:underline mx-1",children:"个人中心"}),"签发 CI/CD 访问凭证,curl 将自动填入。"]})}),e.jsx(Jt,{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:111:7",label:"更新镜像",code:I,copyLabel:"curl 已复制,可直接粘贴到终端执行",copyDisabled:!F,copyDisabledTitle:"请先在个人中心签发访问凭证"}),e.jsx(Jt,{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:118:7",label:"滚动重启",code:M,copyLabel:"curl 已复制,可直接粘贴到终端执行",copyDisabled:!F,copyDisabledTitle:"请先在个人中心签发访问凭证"}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:126:7",className:"text-xs text-[var(--dg-text-muted)] space-y-1",children:[e.jsxs("p",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:127:9",children:["• 示例镜像:",e.jsx("code",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:127:19",className:"text-[var(--dg-text-secondary)]",children:o||"—"}),n?e.jsxs(e.Fragment,{children:[" · 容器 ",e.jsx("code",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:128:36",className:"text-[var(--dg-text-secondary)]",children:n})]}):null]}),e.jsx("p",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:130:9",children:"• 使用长期 API 密钥,不会随登录 JWT 过期"}),e.jsxs("p",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:131:9",children:["• 修改 ",e.jsx("code",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:131:17",className:"text-[var(--dg-text-secondary)]",children:"image"})," 字段后执行 curl 即可触发滚动更新"]}),e.jsxs("p",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:132:9",children:["• 也可用 ",e.jsx("code",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:132:18",className:"text-[var(--dg-text-secondary)]",children:"Authorization: Bearer <密钥>"})]})]})]})}function lt({title:t,children:s,onClose:a,size:o="default"}){const n=o==="xl"?"w-[780px]":o==="lg"?"w-[680px]":"w-[460px]";return e.jsx("div",{"code-path":"src/components/kubernetes/deployment-workload/ModalShell.tsx:18:5",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4",onClick:a,children:e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/ModalShell.tsx:19:7",className:`bg-slate-900 border border-slate-700 rounded-xl ${n} max-w-[92vw] max-h-[85vh] flex flex-col shadow-2xl`,onClick:c=>c.stopPropagation(),children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/ModalShell.tsx:23:9",className:"flex items-center justify-between gap-3 px-6 pt-6 pb-4 shrink-0",children:[e.jsx("h2",{"code-path":"src/components/kubernetes/deployment-workload/ModalShell.tsx:24:11",className:"text-base font-bold text-slate-100 truncate min-w-0",title:t,children:t}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-workload/ModalShell.tsx:25:11",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-slate-400",onClick:a,children:e.jsx(Ss,{"code-path":"src/components/kubernetes/deployment-workload/ModalShell.tsx:25:109",className:"h-4 w-4"})})]}),e.jsx("div",{"code-path":"src/components/kubernetes/deployment-workload/ModalShell.tsx:27:9",className:"flex-1 min-h-0 overflow-y-auto px-6 pb-6",children:s})]})})}function to({clusterCode:t,namespace:s,podName:a,containers:o,onClose:n}){const{toast:c}=Me(),[r,i]=d.useState(""),[k,l]=d.useState(200),[x,S]=d.useState(o[0]||""),[C,y]=d.useState(!1),[b,w]=d.useState(!1),P=async()=>{y(!0);try{const M=await K.getPodLogs(t,s,a,k,x||void 0);i(M?.data?.logs||M?.logs||M||"无日志")}catch{i("获取日志失败")}finally{y(!1)}};d.useEffect(()=>{P()},[x,k]);const I=async()=>{w(!0);const M=is.getState().token||"",F="",V=x?`&container=${encodeURIComponent(x)}`:"",X=`${F}/api/v1/kubernetes/${t}/namespace/${s}/pods/${a}/logs?tail=${k}&stream=true${V}`;try{const W=(await fetch(X,{headers:{Authorization:`Bearer ${M}`}})).body?.getReader();if(!W)return;const Q=new TextDecoder;let $="";for(;;){const{done:Z,value:N}=await W.read();if(Z)break;$+=Q.decode(N,{stream:!0}),i($)}}catch{c({title:"流式日志连接中断",variant:"destructive"})}finally{w(!1)}};return e.jsx("div",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:65:5",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:n,children:e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:66:7",className:"bg-slate-900 border border-slate-700 rounded-xl w-[90vw] max-w-4xl max-h-[80vh] flex flex-col",onClick:M=>M.stopPropagation(),children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:67:9",className:"flex items-center justify-between p-3 border-b border-slate-700 gap-3 shrink-0",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:68:11",className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx(At,{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:69:13",className:"h-4 w-4 shrink-0 text-blue-400"}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:70:13",className:"text-sm font-semibold text-slate-200 truncate",title:a,children:a}),x&&e.jsx(ae,{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:71:27",variant:"outline",className:"border-slate-700 text-slate-400 text-[10px] shrink-0",children:x})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:73:11",className:"flex items-center gap-2 shrink-0 flex-wrap justify-end",children:[o.length>0&&e.jsx("select",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:75:15",value:x,onChange:M=>S(M.target.value),className:"bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-2 py-1",children:o.map(M=>e.jsx("option",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:77:38",value:M,children:M},M))}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:80:13",className:"text-[11px] text-slate-500",children:"最近"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:81:13",type:"number",value:k,onChange:M=>l(Number(M.target.value)||200),className:"w-16 h-7 bg-slate-800 border-slate-700 text-slate-200 text-xs"}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:83:13",className:"text-[11px] text-slate-500",children:"行"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:84:13",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:P,disabled:C,children:C?e.jsx(ve,{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:85:26",className:"h-3 w-3 animate-spin"}):e.jsx(Ye,{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:85:73",className:"h-3 w-3"})}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:87:13",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-emerald-400 text-xs",onClick:I,disabled:b,children:b?"流中...":"实时流"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:90:13",variant:"ghost",size:"icon",className:"h-7 w-7 text-slate-400",onClick:n,children:e.jsx(Ss,{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:90:102",className:"h-4 w-4"})})]})]}),e.jsx("div",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:93:9",className:"flex-1 overflow-auto p-3",children:e.jsx("pre",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:94:11",className:"bg-slate-950 rounded p-3 text-xs text-slate-300 font-mono whitespace-pre-wrap max-h-[60vh] overflow-auto",children:r||"无日志内容"})})]})})}function ls(t){const s=(t||"").trim();if(!s)return{repository:"",tag:"latest"};if(s.includes("@")){const n=s.lastIndexOf("@");return{repository:s.slice(0,n),tag:s.slice(n+1),digest:s.slice(n+1)}}const a=s.lastIndexOf("/"),o=s.lastIndexOf(":");return o>a?{repository:s.slice(0,o),tag:s.slice(o+1)||"latest"}:{repository:s,tag:"latest"}}function ds(t,s){const a=t.trim(),o=s.trim();return a?o?o.startsWith("sha256:")?`${a}@${o}`:`${a}:${o}`:a:""}function so({deployment:t,newImage:s,setNewImage:a,actionLoading:o,onClose:n,onUpdateImage:c}){const r=t?.image||"",i=d.useMemo(()=>ls(r),[r]),[k,l]=d.useState(""),[x,S]=d.useState("");d.useEffect(()=>{const I=ls(s||r);l(I.repository),S(I.tag)},[s,r]);const C=d.useMemo(()=>ds(k,x),[k,x]),y=x.trim()!==i.tag,b=k.trim()!==i.repository,w=C!==r,P=(I,M)=>{a(ds(I,M))};return e.jsx(lt,{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:49:5",title:"调整镜像版本",onClose:n,size:"xl",children:e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:50:7",className:"space-y-5",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:52:9",className:"rounded-lg border border-slate-700/80 bg-slate-800/40 p-4 space-y-3",children:[e.jsx("p",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:53:11",className:"text-xs font-medium text-slate-400",children:"当前镜像"}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:54:11",className:"grid grid-cols-[1fr_180px] gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:55:13",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:56:15",className:"text-slate-500 text-xs",children:"镜像地址"}),e.jsx("p",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:57:15",className:"mt-1.5 text-sm text-slate-200 font-mono break-all leading-relaxed bg-slate-900/60 rounded-md px-3 py-2.5 min-h-[42px]",title:i.repository||"-",children:i.repository||"-"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:64:13",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:65:15",className:"text-slate-500 text-xs",children:"当前 Tag"}),e.jsx("p",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:66:15",className:"mt-1.5 text-sm text-cyan-300 font-mono break-all leading-relaxed bg-slate-900/60 rounded-md px-3 py-2.5 min-h-[42px]",title:i.tag||"-",children:i.tag||"-"})]})]}),e.jsxs("p",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:74:11",className:"text-[11px] text-slate-500 font-mono break-all",title:r,children:["完整引用:",e.jsx("span",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:75:18",className:"text-slate-400",children:r||"-"})]})]}),e.jsx("div",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:79:9",className:"flex items-center justify-center text-slate-600",children:e.jsx(Yt,{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:80:11",className:"h-4 w-4"})}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:84:9",className:"rounded-lg border border-blue-500/30 bg-blue-500/5 p-4 space-y-3",children:[e.jsx("p",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:85:11",className:"text-xs font-medium text-blue-300/90",children:"新镜像"}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:86:11",className:"grid grid-cols-[1fr_180px] gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:87:13",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:88:15",className:"text-slate-400 text-xs",children:"镜像地址"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:89:15",value:k,onChange:I=>{const M=I.target.value;l(M),P(M,x)},placeholder:"harbor.example.com/project/app",className:"mt-1.5 h-10 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:100:13",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:101:15",className:"text-slate-400 text-xs",children:"新版本 Tag"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:102:15",value:x,onChange:I=>{const M=I.target.value;S(M),P(k,M)},placeholder:"v2.0.0",className:"mt-1.5 h-10 bg-slate-800 border-slate-700 text-cyan-200 text-sm font-mono"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:115:11",className:"flex flex-wrap items-center gap-2 text-xs",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:116:13",className:"text-slate-500",children:"Tag 变更:"}),e.jsx("code",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:117:13",className:"px-2 py-0.5 rounded bg-slate-800 text-slate-400 font-mono",children:i.tag}),e.jsx(Yt,{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:118:13",className:"h-3 w-3 text-slate-600"}),e.jsx("code",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:119:13",className:`px-2 py-0.5 rounded font-mono ${y?"bg-cyan-500/15 text-cyan-300":"bg-slate-800 text-slate-400"}`,children:x.trim()||"-"}),!y&&!b&&e.jsx("span",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:127:15",className:"text-slate-600",children:"(未修改)"}),b&&!y&&e.jsx("span",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:130:15",className:"text-amber-400/80",children:"地址已变更"})]}),e.jsxs("p",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:134:11",className:"text-[11px] text-slate-500 font-mono break-all",children:["更新预览:",e.jsx("span",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:135:18",className:"text-slate-300",children:C||"-"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:139:9",className:"flex justify-end gap-2 pt-1",children:[e.jsx(v,{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:140:11",variant:"outline",className:"border-slate-700 text-slate-400",onClick:n,children:"取消"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:143:11",className:"bg-blue-600 hover:bg-blue-700",disabled:o==="image"||!C.trim()||!w,onClick:c,children:o==="image"?e.jsx(ve,{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:148:42",className:"h-4 w-4 animate-spin"}):"更新镜像"})]})]})})}function no({modal:t,deployment:s,namespace:a,deploymentName:o,newImage:n,setNewImage:c,scaleValue:r,setScaleValue:i,actionLoading:k,onClose:l,onUpdateImage:x,onScaleTo:S,onDelete:C}){return e.jsxs(e.Fragment,{children:[t?.kind==="image"&&e.jsx(so,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:46:9",deployment:s,newImage:n,setNewImage:c,actionLoading:k,onClose:l,onUpdateImage:x}),t?.kind==="scale"&&e.jsx(lt,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:58:9",title:"伸缩 (Scale)",onClose:l,children:e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:59:11",className:"space-y-3",children:[e.jsxs("p",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:60:13",className:"text-xs text-slate-500",children:["当前副本: ",s.replicas||0]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:61:13",className:"flex items-center justify-center gap-3 py-3",children:[e.jsx(v,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:62:15",variant:"outline",size:"icon",className:"border-slate-700 text-slate-300",disabled:k==="scale"||r<=0,onClick:()=>i(y=>Math.max(0,y-1)),children:e.jsx(Tt,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:65:17",className:"h-4 w-4"})}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:67:15",type:"number",min:0,value:r,onChange:y=>i(Math.max(0,Number(y.target.value))),className:"w-24 text-center text-lg font-bold bg-slate-800 border-slate-700 text-slate-200"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:70:15",variant:"outline",size:"icon",className:"border-slate-700 text-slate-300",disabled:k==="scale",onClick:()=>i(y=>y+1),children:e.jsx(te,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:73:17",className:"h-4 w-4"})})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:76:13",className:"flex justify-end gap-2 pt-2",children:[e.jsx(v,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:77:15",variant:"outline",className:"border-slate-700 text-slate-400",onClick:l,children:"取消"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:78:15",className:"bg-blue-600 hover:bg-blue-700",disabled:k==="scale",onClick:S,children:k==="scale"?e.jsx(ve,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:79:46",className:"h-4 w-4 animate-spin"}):"确认"})]})]})}),t?.kind==="delete"&&e.jsx(lt,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:88:9",title:"删除 Deployment",onClose:l,children:e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:89:11",className:"space-y-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:90:13",className:"flex items-center gap-2 text-red-400",children:[e.jsx(ws,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:91:15",className:"h-5 w-5"}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:92:15",className:"font-semibold",children:"此操作不可撤销"})]}),e.jsxs("p",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:94:13",className:"text-sm text-slate-400",children:["确认删除 Deployment ",e.jsxs("code",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:95:31",className:"text-slate-200 font-mono",children:[a,"/",o]}),"? 其管理的所有 Pod 将被一并回收。"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:98:13",className:"flex justify-end gap-2 pt-2",children:[e.jsx(v,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:99:15",variant:"outline",className:"border-slate-700 text-slate-400",onClick:l,children:"取消"}),e.jsxs(v,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:100:15",variant:"destructive",disabled:k==="delete",onClick:C,children:[k==="delete"?e.jsx(ve,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:101:47",className:"h-4 w-4 animate-spin mr-1"}):e.jsx(be,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:101:99",className:"h-4 w-4 mr-1"}),"确认删除"]})]})]})})]})}function oo(t){const s=t?.containers;return Array.isArray(s)?s.map(a=>typeof a=="string"?a:a?.name||a?.Name).filter(Boolean):Array.isArray(t?.container_statuses)?t.container_statuses.map(a=>a?.name).filter(Boolean):Array.isArray(t?.containerNames)?t.containerNames.filter(Boolean):[]}function ao({clusterCode:t,namespace:s,deploymentName:a,mode:o,onBack:n,onModeChange:c}){const r=It(a),i=ps(),{toast:k}=Me(),l=dt(),[x,S]=d.useState(null),[C,y]=d.useState(null),[b,w]=d.useState([]),[P,I]=d.useState([]),[M,F]=d.useState([]),[V,X]=d.useState(!0),[q,W]=d.useState(""),[Q,$]=d.useState(null),[Z,N]=d.useState(""),[_,J]=d.useState(0),[ee,me]=d.useState(null),[ye,ge]=d.useState(null),R=x?.cluster_id||x?.clusterId||t,p=d.useMemo(()=>{const E=C?.spec?.template?.spec?.containers?.[0]?.name;if(E)return E;if(b.length>0){const ie=oo(b[0]);if(ie.length)return ie[0]}return""},[C,b]),h=E=>Array.isArray(E)?E:E?.list||E?.items||E?.data||[],u=d.useCallback(async()=>{if(r){const E=yn("deployments",s,"my-app");S({name:"my-app",namespace:s,replicas:1}),y(E),w([]),I([]),F([]),X(!1);return}X(!0);try{const[E,ie,je,Ne]=await Promise.all([K.getDeployment(t,s,a).catch(()=>null),K.getNamespacePods(t,s).catch(()=>[]),K.getReplicaSets(t,s).catch(()=>[]),K.getDeploymentRevisions(t,s,a).catch(()=>[])]),Te=E||(Array.isArray(E)?E[0]:null);S(Te),J(Te?.replicas||0),N(Te?.image||"");const qe=h(ie).filter(Pe=>Pe.namespace===s&&(Pe.name||"").startsWith(a));w(qe);const Ke=h(je).filter(Pe=>Pe.namespace===s&&(Pe.owner_deployment===a||(Pe.name||"").startsWith(a)));I(Ke),F(h(Ne))}catch(E){console.error("加载详情失败:",E)}finally{X(!1)}},[t,s,a,r]),A=d.useCallback(async()=>{if(!r)try{const E=await K.getResourceYaml(t,s,"deployments",a),{parseEditableManifest:ie}=await Gs(async()=>{const{parseEditableManifest:Ne}=await import("./PodFileBrowser-B-U8iHmY.js").then(Te=>Te.k);return{parseEditableManifest:Ne}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])),{manifest:je}=await ie(E);y(je||x)}catch(E){console.warn("加载 manifest 失败(编辑功能降级):",E),y(x)}},[t,s,a,x]),L=d.useCallback(()=>jn(t,s,a),[t,s,a]),m=d.useCallback(E=>fn(t,s,E),[t,s]);d.useEffect(()=>{u()},[u]),d.useEffect(()=>{r||o!=="edit"||C||A()},[o,C,A,r]);const g=async()=>{W("scale");try{await K.scaleDeployment(t,s,a,_),k({title:"伸缩成功",description:`副本数已设置为 ${_}`}),$(null),u()}catch(E){k({title:"操作失败",description:E?.message||String(E),variant:"destructive"})}finally{W("")}},j=async()=>{if(await l({title:"滚动重启",description:`确认滚动重启 Deployment "${a}"?`,confirmText:"重启"})){W("restart");try{await K.restartDeployment(t,s,a),k({title:"重启指令已下发",description:"Deployment 正在滚动重启"}),setTimeout(u,1500)}catch(ie){k({title:"重启失败",description:ie?.message||String(ie),variant:"destructive"})}finally{W("")}}},O=async()=>{const E=!!x?.paused,ie=E?"恢复":"暂停";if(await l({title:`${ie}滚动更新`,description:`确认${ie} Deployment "${a}" 的滚动更新?`,confirmText:ie})){W(E?"resume":"pause");try{E?await K.resumeDeployment(t,s,a):await K.pauseDeployment(t,s,a),k({title:`${ie}成功`,description:`Deployment 滚动更新已${ie}`}),setTimeout(u,1e3)}catch(Ne){k({title:`${ie}失败`,description:Ne?.message||String(Ne),variant:"destructive"})}finally{W("")}}},xe=async()=>{!r&&!C&&await A(),$({kind:"cicd"})},se=async()=>{if(Z.trim()){W("image");try{await K.updateDeploymentImage(t,s,a,Z,p||void 0),k({title:"镜像更新成功",description:`正在滚动更新为 ${Z}`}),$(null),u()}catch(E){k({title:"更新失败",description:E?.message||String(E),variant:"destructive"})}finally{W("")}}},B=async()=>{W("delete");try{const E=is.getState().token||"",je=`/api/v1/kubernetes/${t}/namespace/${s}/deployments/${a}`,Ne=await fetch(je,{method:"DELETE",headers:{Authorization:`Bearer ${E}`}});if(!Ne.ok)throw new Error(`HTTP ${Ne.status}`);k({title:"删除成功",description:`${a} 已删除`}),$(null),setTimeout(()=>i(`/kubernetes/${t}/namespace/${s}/deployments`),800)}catch(E){k({title:"删除失败",description:E?.message||String(E),variant:"destructive"})}finally{W("")}},de=E=>$({kind:"podLogs",pod:E.name}),De=E=>$({kind:"podYaml",pod:E.name}),Se=E=>{me(E.name)},Ie=E=>{ge(E.name)},$e=async E=>{if(await l({title:"删除 Pod",description:`确认删除 Pod "${E.name}"?操作不可恢复。`,confirmText:"删除"}))try{await K.deletePod(t,s,E.name),k({title:"Pod 已删除"}),u()}catch(je){k({title:"删除失败",description:je?.message||String(je),variant:"destructive"})}};if(V)return e.jsx(U,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:288:7",className:"bg-slate-900 border-slate-800",children:e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:289:9",className:"p-12 text-center",children:[e.jsx(ve,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:290:11",className:"h-6 w-6 animate-spin mx-auto text-slate-500"}),e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:291:11",className:"text-slate-500 mt-3",children:"加载中..."})]})});if(!x&&!r)return e.jsx(U,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:299:7",className:"bg-slate-900 border-slate-800",children:e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:300:9",className:"p-12 text-center",children:[e.jsx(hn,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:301:11",className:"h-8 w-8 mx-auto text-red-400"}),e.jsxs("p",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:302:11",className:"text-slate-400 mt-3",children:["未找到 Deployment: ",a]}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:303:11",variant:"outline",className:"mt-4",onClick:n,children:"返回"})]})});if(r){const E=ie=>{const je=ie?.metadata?.name;je&&i(`/kubernetes/${t}/namespace/${s}/workload/view/Deployment/${je}`)};return e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:317:7",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:318:9",className:"flex items-center gap-3",children:[e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:319:11",variant:"ghost",size:"sm",className:"text-slate-400",onClick:n,children:[e.jsx(qt,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:320:13",className:"h-4 w-4 mr-1"}),"返回"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:322:11",children:[e.jsx("h1",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:323:13",className:"text-xl font-bold text-slate-100",children:"新建 Deployment"}),e.jsxs("p",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:324:13",className:"text-xs text-slate-500 mt-0.5",children:[s," · ",t]})]})]}),e.jsx(cs,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:327:9",clusterCode:t,namespace:s,deploymentName:Ds,manifest:C,isCreate:!0,onSaved:E,onCancel:n})]})}const _e=x.ready_replicas||x.readyReplicas||0,Be=x.replicas||0,Le=_e===Be&&Be>0;return e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:346:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:348:7",className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:349:9",className:"flex items-center gap-3 min-w-0",children:[e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:350:11",variant:"ghost",size:"sm",className:"text-slate-400",onClick:n,children:[e.jsx(qt,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:351:13",className:"h-4 w-4 mr-1"}),"返回"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:353:11",className:"min-w-0",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:354:13",className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h1",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:355:15",className:"text-xl font-bold text-slate-100 truncate",children:a}),e.jsx(ae,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:356:15",variant:"outline",className:"border-slate-700 text-slate-400",children:s}),e.jsx(ae,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:357:15",variant:"outline",className:"border-slate-700 text-slate-400",children:"Deployment"}),e.jsxs(ae,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:358:15",className:Le?"bg-emerald-500/20 text-emerald-400 border-emerald-500/30":"bg-amber-500/20 text-amber-400 border-amber-500/30",children:[Le?e.jsx(Ct,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:363:30",className:"h-3 w-3 mr-1"}):e.jsx(ws,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:363:73",className:"h-3 w-3 mr-1"}),_e,"/",Be]}),x?.paused&&e.jsxs(ae,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:367:17",className:"bg-orange-500/20 text-orange-400 border-orange-500/30",children:[e.jsx(Kt,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:368:19",className:"h-3 w-3 mr-1"}),"已暂停更新"]})]}),e.jsxs("p",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:372:13",className:"text-xs text-slate-500 mt-0.5 truncate",children:["镜像: ",e.jsx("code",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:373:19",className:"text-slate-400",children:x.image||"-"})]})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:378:9",className:"flex items-center gap-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:380:11",className:"inline-flex rounded-md border border-slate-700 overflow-hidden",children:[e.jsx("button",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:381:13",className:`px-3 py-1.5 text-xs font-medium transition-colors ${o==="view"?"bg-slate-700 text-slate-100":"bg-transparent text-slate-400 hover:text-slate-200"}`,onClick:()=>c("view"),children:"查看"}),e.jsx("button",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:387:13",className:`px-3 py-1.5 text-xs font-medium transition-colors ${o==="edit"?"bg-blue-600 text-white":"bg-transparent text-slate-400 hover:text-slate-200"}`,onClick:()=>c("edit"),children:"编辑"}),e.jsx("button",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:393:13",className:`px-3 py-1.5 text-xs font-medium transition-colors ${o==="yaml"?"bg-emerald-600 text-white":"bg-transparent text-slate-400 hover:text-slate-200"}`,onClick:()=>c("yaml"),children:"YAML"})]}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:401:11",variant:"outline",size:"sm",className:"border-slate-700 text-slate-400",onClick:u,title:"刷新",children:e.jsx(Ye,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:402:13",className:"h-4 w-4"})}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:406:11",className:"flex items-center gap-1.5",children:[e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:407:13",variant:"outline",size:"sm",className:"border-slate-700 text-slate-300",onClick:()=>{N(x?.image||""),$({kind:"image"})},children:[e.jsx(un,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:416:15",className:"h-3.5 w-3.5 mr-1"}),"调整镜像"]}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:418:13",variant:"outline",size:"sm",className:"border-slate-700 text-slate-300",onClick:j,children:[e.jsx(fs,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:419:15",className:"h-3.5 w-3.5 mr-1"}),"重启"]}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:421:13",variant:"outline",size:"sm",className:"border-slate-700 text-slate-300",disabled:!!q,onClick:O,children:x?.paused?e.jsxs(e.Fragment,{children:[e.jsx(Ns,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:428:21",className:"h-3.5 w-3.5 mr-1 text-green-400"}),"恢复"]}):e.jsxs(e.Fragment,{children:[e.jsx(Kt,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:429:21",className:"h-3.5 w-3.5 mr-1 text-orange-400"}),"暂停"]})}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:432:13",variant:"outline",size:"sm",className:"border-slate-700 text-slate-300",onClick:xe,children:[e.jsx(bn,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:433:15",className:"h-3.5 w-3.5 mr-1 text-purple-400"}),"CI/CD"]}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:435:13",variant:"outline",size:"sm",className:"border-slate-700 text-red-400 hover:bg-red-500/10",onClick:()=>$({kind:"delete"}),children:[e.jsx(be,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:436:15",className:"h-3.5 w-3.5 mr-1"}),"删除"]})]})]})]}),o==="view"?e.jsx(An,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:444:9",clusterCode:t,namespace:s,deployment:x,pods:b,replicaSets:P,revisions:M,onRefresh:u,onShowPodLogs:de,onShowPodTerminal:Se,onShowPodYaml:De,onShowPodFileBrowser:Ie,onDeletePod:$e}):o==="yaml"?e.jsx(kt,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:460:9",clusterCode:t,namespace:s,resource:"deployments",name:a,inline:!0,resourceHint:"含关联 Service",loadYamlFn:L,saveYamlFn:m,onSaved:u,onClose:()=>c("view")}):e.jsx(cs,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:474:9",clusterCode:t,namespace:s,deploymentName:a,manifest:C,onSaved:()=>{A(),u()},onCancel:()=>c("view")}),Q?.kind==="yaml"&&e.jsx(kt,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:486:9",clusterCode:t,namespace:s,resource:"deployments",name:a,resourceHint:"含关联 Service",loadYamlFn:L,saveYamlFn:m,onClose:()=>$(null),onSaved:u}),e.jsx(no,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:499:7",modal:Q,deployment:x,namespace:s,deploymentName:a,newImage:Z,setNewImage:N,scaleValue:_,setScaleValue:J,actionLoading:q,onClose:()=>$(null),onUpdateImage:se,onScaleTo:g,onDelete:B}),Q?.kind==="cicd"&&e.jsx(lt,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:517:9",title:"CI/CD Webhook",onClose:()=>$(null),size:"lg",children:e.jsx(eo,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:518:11",clusterCode:t,namespace:s,deploymentName:a,image:x?.image||Z||"",containerName:p})}),Q?.kind==="podYaml"&&e.jsx(kt,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:530:9",clusterCode:t,namespace:s,resource:"pods",name:Q.pod,readOnly:!0,onClose:()=>$(null)}),Q?.kind==="podLogs"&&e.jsx(to,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:542:9",clusterCode:t,namespace:s,podName:Q.pod,containers:(b.find(E=>E.name===Q.pod)?.containers||[]).map(E=>E.name).filter(Boolean),onClose:()=>$(null)}),e.jsx(Ys,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:552:7",open:!!ee,onOpenChange:E=>{E||me(null)},clusterId:R,namespace:s,podName:ee||"",containers:(b.find(E=>E.name===ee)?.containers||[]).map(E=>E.name).filter(Boolean)}),e.jsx(qs,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:561:7",open:!!ye,onOpenChange:E=>{E||ge(null)},clusterCode:t,namespace:s,podName:ye||"",containers:(b.find(E=>E.name===ye)?.containers||[]).map(E=>E.name).filter(Boolean)})]})}function Eo(){const t=Vs(),s=ps(),a=t.clusterCode||"",o=t.namespace||"",n=t.name||"",c=It(n)?"edit":t.mode==="edit"||t.mode==="yaml"?t.mode:"view",r=i=>{i!==c&&s(`/kubernetes/${a}/namespace/${o}/workload/${i}/Deployment/${n}`,{replace:!0})};return e.jsx(ao,{"code-path":"src/components/kubernetes/DeploymentDetailPage.tsx:41:5",clusterCode:a,namespace:o,deploymentName:n,mode:c,onBack:()=>s(-1),onModeChange:r})}export{Eo as default};
|