import{b as k,r as m,k as v,j as e,M as A,F as D,P as x,B as o,m as I,a as R}from"./main-BzPVmAp-.js";import{b,d as z,c as M}from"./index-D0tEL95I.js";import{F as w}from"./Table-kIlrKW-9.js";const T=({visible:c,onClose:l,params:d,callback:p})=>{if(!c)return null;const{modal:i,openModal:y,closeModal:u}=k(),{component_id:r,component_type:C,namespace:F,namespace_name:P,name:h,...$}=d,[j,_]=m.useState([]),{messageApi:a}=v(),s=async()=>{const t=await R.get(`/get-depend-component/${r}`);_(t.data)},f=async t=>{try{const n=await z(t);a.success("删除成功!"),s()}catch(n){console.log(n),a.error(`${n.response.data.detail}`)}},g=async t=>{try{const n=await M(t);a.success("删除成功!"),l(),p&&p()}catch(n){console.log(n),a.error(`${n.response.data.detail}`)}};return m.useEffect(()=>{s()},[r]),e.jsxs("div",{children:[e.jsxs(A,{width:"70%",title:`Component(${C},${h})`,open:c,onCancel:l,footer:(t,{OkBtn:n,CancelBtn:B})=>e.jsxs(e.Fragment,{children:[e.jsx(x,{title:"Are you sure to delete this component?",onConfirm:()=>{g(r)},children:e.jsx(o,{size:"small",color:"danger",variant:"solid",children:"Delete Component"})}),e.jsx(o,{size:"small",color:"cyan",variant:"solid",onClick:s,children:"Refresh"}),e.jsx(o,{size:"small",color:"cyan",variant:"solid",onClick:l,children:"Close"})]}),children:[e.jsx("div",{children:e.jsx(w,{size:"small",bordered:!0,pagination:!1,columns:[{title:"Component Name",dataIndex:"component_name",key:"component_name"},{title:"Component Type",dataIndex:"component_type",key:"component_type"},{title:"Relation Type",dataIndex:"relation_type",key:"relation_type"},{title:"Component ID",dataIndex:"component_id",key:"component_id"},{title:"Relation ID",dataIndex:"relation_id",key:"relation_id"},{title:"Action",key:"action",render:(t,n)=>e.jsxs(D,{gap:"small",children:[e.jsx(x,{title:"Are you sure to delete this relation?",onConfirm:()=>{f(n.relation_id)},children:e.jsx(o,{size:"small",color:"danger",variant:"solid",children:"Delete Relation"})}),e.jsx(o,{size:"small",color:"cyan",variant:"solid",onClick:()=>{y("modalA",{data:n,structure:{component_type:n.component_type}})},children:"Update"})]})}],dataSource:j})}),e.jsx(I,{ghost:!0,items:[{key:"1",label:"More",children:e.jsx("pre",{children:JSON.stringify(d,null,2)})}]})]}),e.jsx(b,{callback:s,visible:i.key=="modalA"&&i.visible,onClose:u,params:i.params})]})};export{T as D};
