import{d as s,g as f,m as j,i as b,j as e,L as C}from"./index-lOezWVmi.js";import{N as L}from"./NotificationRow-DdxAfFhk.js";import{B as v}from"./BaseLayout-CM5eWMFT.js";import{H as y}from"./HelpLink-8_zL-2ID.js";import{u as w}from"./useSortTableData-DWeqi6jP.js";import{C as S,a as M}from"./ClusterMemberStatus-D6H6dtfH.js";import{u as _}from"./usePanelParams-8kZEbPGc.js";import"./GroupSelection-Dk08yxTV.js";import"./PermissionGroupsFilter-_sIBqW1q.js";import"./SelectableMainTable-DfupvQ-c.js";import"./useClusterGroups-gPFjN-2N.js";const G=()=>{const r=s.useNotify(),l=_(),{data:o=[],error:n,isLoading:c}=f(),u=j(),{canEditServerConfiguration:d}=b();n&&r.failure("Loading cluster members failed",n);const m=[{content:"Name",className:"name",sortKey:"name"},{content:e.jsx("span",{className:"status-header",children:"Status"}),className:"status",sortKey:"status"},{content:"Roles",sortKey:"roles",className:"roles"},{content:"Failure domain",className:"failure-domain",sortKey:"failureDomain"},{content:"Description",sortKey:"description",className:"description"},{content:"Groups",className:"groups u-align--right",sortKey:"groups"},{"aria-label":"Action",className:"u-align--right actions"}],p=o.map(a=>{var i;const t=(a.groups??[]).length,N=()=>{l.openEditMember(a.server_name)},h=u.getType(a.server_name);return{key:a.server_name,name:a.server_name,columns:[{content:e.jsxs(e.Fragment,{children:[e.jsx("div",{children:e.jsx(C,{to:`/ui/cluster/member/${encodeURIComponent(a.server_name)}`,children:a.server_name})}),e.jsx("div",{className:"u-text--muted",children:a.url})]}),role:"rowheader","aria-label":"Name and url",className:"name"},{content:e.jsxs(e.Fragment,{children:[e.jsx("div",{children:e.jsx(S,{member:a})}),e.jsx("div",{className:"u-text--muted status-header",children:h?"In progress":a.message})]}),role:"cell","aria-label":"Status",className:"status"},{content:a.roles.join(", "),role:"cell","aria-label":"Roles",className:"roles"},{content:a.failure_domain,role:"cell","aria-label":"Failure domain",className:"failure-domain"},{content:a.description,role:"cell","aria-label":"Description",className:"description"},{content:d()?e.jsx(s.Button,{appearance:"link",dense:!0,onClick:N,children:t}):t,role:"cell",className:"groups u-align--right","aria-label":"Groups"},{content:e.jsx(M,{member:a}),role:"cell",className:"u-align--right actions","aria-label":"Action"}],sortData:{name:a.server_name.toLowerCase(),status:a.status.toLowerCase(),failureDomain:a.failure_domain.toLowerCase(),roles:a.roles,description:(i=a.description)==null?void 0:i.toLowerCase(),groups:t}}}),{rows:g,updateSort:x}=w({rows:p});return e.jsxs(v,{mainClassName:"cluster-list",title:e.jsx(y,{docPath:"/explanation/clustering/",title:"Learn more about clustering",children:"Cluster members"}),children:[e.jsx(L,{}),e.jsx(s.Row,{children:e.jsx(s.ScrollableTable,{dependencies:[o,r.notification],tableId:"cluster-table",belowIds:["status-bar"],children:e.jsx(s.TablePagination,{data:g,id:"pagination",itemName:"cluster member",className:"u-no-margin--top","aria-label":"Table pagination control",children:e.jsx(s.MainTable,{id:"cluster-table",headers:m,sortable:!0,responsive:!0,onUpdateSort:x,emptyStateMsg:c&&e.jsx(s.Spinner,{className:"u-loader",text:"Loading cluster members..."})})})})})]})};export{G as default};
