import{d as a,m as h,v as j,p as b,j as e,L as y,R as C,C as f,w as v,e as L}from"./index-Dz5JRQhj.js";import{B as M}from"./BaseLayout-Zdoa_UmA.js";import{H as w}from"./HelpLink-IKbgKG-X.js";import{u as S}from"./useSortTableData-hB-CR5gt.js";import{C as R}from"./ClusterMemberActions-CV45MsxB.js";import{u as T}from"./usePanelParams-Ct0mzMbg.js";import"./GroupSelection-nMtUu7a9.js";import"./PermissionGroupsFilter-lOSp9Bf0.js";import"./SelectableMainTable-5fh72u4t.js";import"./useClusterGroups-C_js1wC4.js";const U=()=>{const r=a.useNotify(),l=T(),{data:o=[],error:n,isLoading:i}=h(),c=j(),{canEditServerConfiguration:u}=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:"Memory",className:"memory"},{content:"Description",sortKey:"description",className:"description"},{content:"Groups",className:"groups u-align--right",sortKey:"groups"},{"aria-label":"Action",className:"u-align--right actions"}],d=o.map(s=>{const t=(s.groups??[]).length,x=()=>{l.openEditMember(s.server_name)},N=c.getType(s.server_name);return{key:s.server_name,name:s.server_name,columns:[{content:e.jsxs(e.Fragment,{children:[e.jsx("div",{children:e.jsx(y,{to:`${C}/ui/cluster/member/${encodeURIComponent(s.server_name)}`,children:s.server_name})}),e.jsx("div",{className:"u-text--muted",children:s.url})]}),role:"rowheader","aria-label":"Name and url",className:"name"},{content:e.jsxs(e.Fragment,{children:[e.jsx("div",{children:e.jsx(f,{member:s})}),e.jsx("div",{className:"u-text--muted status-header",children:N?"In progress":s.message})]}),role:"cell","aria-label":"Status",className:"status"},{content:s.roles.join(", "),role:"cell","aria-label":"Roles",className:"roles"},{content:e.jsx(v,{member:s}),role:"cell","aria-label":"Memory",className:"memory"},{content:s.description,role:"cell","aria-label":"Description",className:"description"},{content:u()?e.jsx(a.Button,{appearance:"link",dense:!0,onClick:x,children:t}):t,role:"cell",className:"groups u-align--right","aria-label":"Groups"},{content:e.jsx(R,{member:s}),role:"cell",className:"u-align--right actions","aria-label":"Action"}],sortData:{name:s.server_name.toLowerCase(),status:s.status.toLowerCase(),roles:s.roles,description:s.description?.toLowerCase(),groups:t}}}),{rows:p,updateSort:g}=S({rows:d});return e.jsxs(M,{mainClassName:"cluster-list",title:e.jsx(w,{docPath:"/explanation/clustering/",title:"Learn more about clustering",children:"Cluster members"}),children:[e.jsx(L,{}),e.jsx(a.Row,{children:e.jsx(a.ScrollableTable,{dependencies:[o,r.notification],tableId:"cluster-table",belowIds:["status-bar"],children:e.jsx(a.TablePagination,{data:p,id:"pagination",itemName:"cluster member",className:"u-no-margin--top","aria-label":"Table pagination control",children:e.jsx(a.MainTable,{id:"cluster-table",headers:m,sortable:!0,responsive:!0,onUpdateSort:g,emptyStateMsg:i&&e.jsx(a.Spinner,{className:"u-loader",text:"Loading cluster members..."})})})})})]})};export{U as default};
