%PDF- %PDF-
Direktori : /snap/lxd/current/share/lxd-ui/assets/ |
Current File : //snap/lxd/current/share/lxd-ui/assets/ClusterList-13b65a6c.js |
import{j as e,c as C,e as x,d as s,f,g as y,q as o,h as N,r as L,i as v,I as k,k as S,l as I,m as w,n as D,o as G,B as M,H as q,b as B,S as T,L as _,P as E,p as H}from"./index-13b2882d.js";import{a as g,g as P,b as $}from"./clusterGroups-3fc1789d.js";import{i as F}from"./settings-c23f9009.js";const K=({clusterGroups:r})=>{const n=new Set(r.flatMap(t=>t.members));return e.jsx("div",{children:[{name:g,members:[...n],description:"Members from all cluster groups"},...r].map(t=>e.jsx("div",{className:"p-contextual-menu__group cluster-group",children:e.jsxs(C,{to:t.name===g?"/ui/cluster":`/ui/cluster/groups/detail/${t.name}`,className:"p-contextual-menu__link link",children:[e.jsx("div",{title:t.name,className:"u-truncate name",children:t.name}),e.jsxs("div",{className:"p-text--x-small u-float-right u-no-margin--bottom count",children:[t.members.length," ",t.members.length===1?"member":"members"]}),e.jsx("br",{}),e.jsx("div",{className:"p-text--x-small u-no-margin--bottom u-truncate description",title:t.description,children:t.description||"-"})]})},t.name))})},R=({activeGroup:r})=>{const n=x(),t=s.useNotify(),{data:i=[],error:a}=f({queryKey:[o.cluster,o.groups],queryFn:N});return a&&t.failure("Loading cluster groups failed",a),i.sort(y),e.jsx(s.ContextualMenu,{dropdownProps:{"aria-label":"select cluster group"},toggleClassName:"toggle",position:"left",toggleLabel:r,toggleAppearance:"base",className:"u-no-margin--bottom cluster-group-select",hasToggleIcon:!0,title:"Select group",children:e.jsxs("div",{className:"cluster-group-list",children:[e.jsx(K,{clusterGroups:i}),e.jsx("hr",{}),e.jsxs(s.Button,{onClick:()=>n("/ui/cluster/groups/create"),className:"p-contextual-menu__link",hasIcon:!0,children:[e.jsx(s.Icon,{name:"plus"}),e.jsx("span",{children:"Create group"})]})]},"my-div")})},Q=({group:r})=>{const n=x();return e.jsx(s.Button,{className:"u-no-margin--bottom",onClick:()=>n(`/ui/cluster/groups/detail/${r}/edit`),children:"Edit group"})},A=({group:r})=>{const n=s.useNotify(),[t,i]=L.useState(!1),a=x(),c=v(),m=()=>{i(!0),S(r).then(()=>{a("/ui/cluster",n.queue(n.success(`Cluster group ${r} deleted.`)))}).catch(p=>{i(!1),n.failure("Cluster group deletion failed",p)}).finally(()=>{c.invalidateQueries({queryKey:[o.cluster,o.groups]})})},u=r==="default",l=()=>u?"The default cluster group cannot be deleted":"Delete cluster group";return e.jsx(s.ConfirmationButton,{onHoverText:l(),appearance:"",loading:t,confirmationModalProps:{title:"Confirm delete",confirmMessage:e.jsxs("p",{children:["This will permanently delete cluster group"," ",e.jsx(k,{item:{name:r},bold:!0}),". ",e.jsx("br",{}),"This action cannot be undone, and can result in data loss."]}),confirmButtonLabel:"Delete",onConfirm:m},disabled:u,shiftClickEnabled:!0,showShiftClickHint:!0,children:e.jsx("span",{children:"Delete cluster group"})})},J=()=>{const r=I(),n=s.useNotify(),{group:t}=w(),{data:i}=D(),a=F(i),{data:c=[],error:m,isLoading:u}=f({queryKey:[o.cluster,o.members],queryFn:H,enabled:a});m&&n.failure("Loading cluster members failed",m);const l=c.filter(j=>{var h;return!t||((h=j.groups)==null?void 0:h.includes(t))}),p=$(t),b=P(l,t),d=G(b);return e.jsxs(M,{mainClassName:"cluster-list",contentClassName:"cluster-content",title:e.jsx(q,{href:`${r}/explanation/clustering/`,title:"Learn more about clustering",children:a?e.jsx(R,{activeGroup:t??g},t):"Cluster"}),controls:t?e.jsx(Q,{group:t}):null,children:[e.jsx(B,{}),e.jsxs(s.Row,{children:[a&&l.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(T,{dependencies:[l,n.notification],belowId:"pagination",children:e.jsx(s.MainTable,{headers:p,rows:d.pageData,sortable:!0,onUpdateSort:d.updateSort,emptyStateMsg:u&&e.jsx(_,{text:"Loading cluster members..."})})}),e.jsx(E,{...d,id:"pagination",totalCount:c.length,visibleCount:l.length===c.length?d.pageData.length:l.length,keyword:"cluster member"})]}),!u&&a&&t&&l.length<1&&e.jsxs(s.EmptyState,{className:"empty-state",image:e.jsx(s.Icon,{name:"machines",className:"empty-state-icon"}),title:"Cluster group empty",children:[e.jsx("p",{children:"Add cluster members to this group."}),e.jsx("p",{children:e.jsxs("a",{href:`${r}/explanation/clustering/`,target:"_blank",rel:"noreferrer",children:["Learn more about clustering",e.jsx(s.Icon,{className:"external-link-icon",name:"external-link"})]})}),e.jsx(A,{group:t})]}),!a&&e.jsxs(s.EmptyState,{className:"empty-state",image:e.jsx(s.Icon,{name:"machines",className:"empty-state-icon"}),title:"This server is not clustered",children:[e.jsx("p",{children:"Creating cluster members is not supported in LXD UI. Create one using LXD CLI"}),e.jsx("p",{children:e.jsxs("a",{href:`${r}/explanation/clustering/`,target:"_blank",rel:"noreferrer",children:["Learn more about clustering",e.jsx(s.Icon,{className:"external-link-icon",name:"external-link"})]})})]})]})]})};export{J as default};