import{d as l,r as o,i as u,j as e,I as d,U as h,q as m}from"./index-3c1b2661.js";const x=({member:t})=>{const a=l.useNotify(),[s,r]=o.useState(!1),n=u(),i=()=>{r(!0),h(t,"evacuate").then(()=>{a.success(`Cluster member ${t.server_name} evacuation started.`)}).catch(c=>a.failure("Cluster member evacuation failed",c)).finally(()=>{r(!1),n.invalidateQueries({queryKey:[m.cluster]})})};return e.jsx(l.ConfirmationButton,{appearance:"",loading:s,confirmationModalProps:{title:"Confirm evacuation",children:e.jsxs("p",{children:["This will evacuate cluster member"," ",e.jsx(d,{item:{name:t.server_name},bold:!0}),"."]}),confirmButtonLabel:"Evacuate",onConfirm:i},shiftClickEnabled:!0,showShiftClickHint:!0,children:e.jsx("span",{children:"Evacuate"})})},f=({member:t})=>{const a=l.useNotify(),[s,r]=o.useState(!1),n=u(),i=()=>{r(!0),h(t,"restore").then(()=>{a.success(`Cluster member ${t.server_name} restore started.`)}).catch(c=>a.failure("Cluster member restore failed",c)).finally(()=>{r(!1),n.invalidateQueries({queryKey:[m.cluster]})})};return e.jsx(l.ConfirmationButton,{appearance:"",loading:s,confirmationModalProps:{title:"Confirm restore",children:e.jsxs("p",{children:["This will restore cluster member"," ",e.jsx(d,{item:{name:t.server_name},bold:!0}),"."]}),confirmButtonLabel:"Restore",onConfirm:i,confirmButtonAppearance:"positive"},shiftClickEnabled:!0,showShiftClickHint:!0,children:e.jsx("span",{children:"Restore"})})},p="All cluster groups",v=t=>[{content:e.jsxs(e.Fragment,{children:["Name",e.jsx("br",{}),e.jsx("div",{className:"header-second-row",children:"Url"})]}),className:"name"},{content:"Roles",sortKey:"roles",className:"roles"},{content:e.jsxs(e.Fragment,{children:["Architecture",e.jsx("br",{}),e.jsx("div",{className:"header-second-row",children:"Failure domain"})]}),className:"architecture"},{content:"Description",sortKey:"description",className:"description"},{content:t?"Other groups":"Groups"},{content:e.jsxs(e.Fragment,{children:["Status",e.jsx("br",{}),e.jsx("div",{className:"header-second-row",children:"Message"})]}),className:"status"},{"aria-label":"Action",className:"u-align--right actions"}],g=(t,a)=>t.map(s=>{var r;return{className:"u-row",name:s.server_name,columns:[{content:e.jsxs(e.Fragment,{children:[e.jsx("div",{children:s.server_name}),e.jsx("div",{className:"u-text--muted",children:s.url})]}),role:"cell","aria-label":"Name and url",className:"name"},{content:s.roles.join(", "),role:"cell","aria-label":"Roles",className:"roles"},{content:e.jsxs(e.Fragment,{children:[e.jsx("div",{children:s.architecture}),e.jsx("div",{className:"u-text--muted",children:s.failure_domain})]}),role:"cell","aria-label":"Architecture and failure domain",className:"architecture"},{content:s.description,role:"cell","aria-label":"Description",className:"description"},{content:(r=s.groups)==null?void 0:r.filter(n=>n!==a).join(", "),role:"cell","aria-label":a?"Other groups":"Groups"},{content:e.jsxs(e.Fragment,{children:[e.jsx("div",{children:s.status}),e.jsx("div",{className:"u-text--muted",children:s.message})]}),role:"cell","aria-label":"Status and message",className:"status"},{content:e.jsx("div",{className:"cluster-actions",children:s.status==="Evacuated"?e.jsx(f,{member:s}):e.jsx(x,{member:s})}),role:"cell",className:"u-align--right actions","aria-label":"Action"}],sortData:{roles:s.roles,description:s.description}}});export{p as a,v as b,g};
