import{d as l,k as u,r as d,l as m,j as e,$ as h,q as x}from"./index-Cziemgsu.js";import{I as f}from"./ItemName-CywOV74d.js";import{R as p}from"./ResourceLink-D2AYI_En.js";const j=({member:t})=>{const r=l.useNotify(),s=u(),[n,a]=d.useState(!1),i=m(),o=()=>{a(!0),h(t,"evacuate").then(()=>{s.success(e.jsxs(e.Fragment,{children:["Cluster member"," ",e.jsx(p,{type:"cluster-member",value:t.server_name,to:"/ui/cluster"})," ","evacuation started."]}))}).catch(c=>r.failure("Cluster member evacuation failed",c)).finally(()=>{a(!1),i.invalidateQueries({queryKey:[x.cluster]})})};return e.jsx(l.ConfirmationButton,{appearance:"",loading:n,confirmationModalProps:{title:"Confirm evacuation",children:e.jsxs("p",{children:["This will evacuate cluster member"," ",e.jsx(f,{item:{name:t.server_name},bold:!0}),"."]}),confirmButtonLabel:"Evacuate",onConfirm:o},shiftClickEnabled:!0,showShiftClickHint:!0,children:e.jsx("span",{children:"Evacuate"})})},v=({member:t})=>{const r=l.useNotify(),s=u(),[n,a]=d.useState(!1),i=m(),o=()=>{a(!0),h(t,"restore").then(()=>{s.success(e.jsxs(e.Fragment,{children:["Cluster member"," ",e.jsx(p,{to:"/ui/cluster",type:"cluster-member",value:t.server_name})," ","restore started."]}))}).catch(c=>r.failure("Cluster member restore failed",c)).finally(()=>{a(!1),i.invalidateQueries({queryKey:[x.cluster]})})};return e.jsx(l.ConfirmationButton,{appearance:"",loading:n,confirmationModalProps:{title:"Confirm restore",children:e.jsxs("p",{children:["This will restore cluster member"," ",e.jsx(f,{item:{name:t.server_name},bold:!0}),"."]}),confirmButtonLabel:"Restore",onConfirm:o,confirmButtonAppearance:"positive"},shiftClickEnabled:!0,showShiftClickHint:!0,children:e.jsx("span",{children:"Restore"})})},y="All cluster groups",b=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"}],E=(t,r)=>t.map(s=>{var n;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:(n=s.groups)==null?void 0:n.filter(a=>a!==r).join(", "),role:"cell","aria-label":r?"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(v,{member:s}):e.jsx(j,{member:s})}),role:"cell",className:"u-align--right actions","aria-label":"Action"}],sortData:{roles:s.roles,description:s.description}}});export{y as a,b,E as g};
