/
snap
/
lxd
/
current
/
share
/
lxd-ui
/
assets
/
File Upload :
llllll
Current File: //snap/lxd/current/share/lxd-ui/assets/ClusterMemberStatus-BxKMB8Rv.js
import{d as n,r as y,l as M,t as w,o as I,m as F,j as e,v as R,n as L,w as k,R as v,q as p,s as P,i as G,x as T,e as q,y as K,z as Q}from"./index-B3cgCbnJ.js";import{u as B,p as U}from"./usePanelParams-CZsrUgz_.js";import{G as $}from"./GroupSelection-DeSbcBFI.js";import{b as A}from"./useClusterGroups-DvMC8idl.js";const O=({member:s,hasLabel:o=!1,className:u,onClose:l})=>{const c=n.useNotify(),t=n.useToastNotification(),[m,h]=y.useState(!1),[a,g]=y.useState(""),x=M(),b=w(),r=I().getType(s.server_name),{canEditServerConfiguration:d}=F(),f=()=>{x.invalidateQueries({queryKey:[p.cluster],predicate:i=>i.queryKey[0]===p.cluster||i.queryKey[0]===p.operations})},S=()=>{t.success(e.jsxs(e.Fragment,{children:["Member"," ",e.jsx(v,{type:"cluster-member",value:s.server_name,to:`/ui/cluster/member/${encodeURIComponent(s.server_name)}`})," ","evacuation completed."]}))},E=i=>{t.failure("Member evacuation failed",new Error(i),e.jsx(v,{type:"cluster-member",value:s.server_name,to:`/ui/cluster/member/${encodeURIComponent(s.server_name)}`}))},N=()=>{h(!0),k(s,"evacuate",a).then(i=>{t.info(e.jsxs(e.Fragment,{children:["Member"," ",e.jsx(v,{type:"cluster-member",value:s.server_name,to:`/ui/cluster/member/${encodeURIComponent(s.server_name)}`})," ","evacuation started."]})),b.set(i.metadata.id,S,E,f),l==null||l()}).catch(i=>{c.failure("Member evacuation failed",i)}).finally(()=>{h(!1),f()})},j=d(),_=m||s.status!=="Online"||!!r||!j;return e.jsxs(n.ConfirmationButton,{appearance:o?"":"base",loading:m||r==="Evacuating",disabled:_,confirmationModalProps:{title:"Confirm evacuation",children:e.jsxs(e.Fragment,{children:[e.jsx(n.Select,{label:"Evacuation action",options:[{label:"Auto",value:""},{label:"Stop all instances",value:"stop"},{label:"Migrate instances to other members",value:"migrate"},{label:"Live migrate instances to other members",value:"live-migrate"}],help:"Chose what to do with instances on this member.",onChange:i=>{g(i.target.value)},value:a}),e.jsxs("p",{children:["This will evacuate cluster member"," ",e.jsx(L,{type:"cluster-member",value:s.server_name,bold:!0}),"."]})]}),confirmButtonLabel:j?"Evacuate cluster member":"You do not have permission to evacuate cluster members",onConfirm:N},shiftClickEnabled:!0,title:"Evacuate cluster member",className:R(u,"has-icon u-no-margin--bottom"),children:[e.jsx(n.Icon,{name:"stop"}),o&&e.jsx("span",{children:"Evacuate"})]})},V=({member:s,hasLabel:o=!1,className:u,onClose:l})=>{const c=n.useNotify(),t=n.useToastNotification(),[m,h]=y.useState(!1),[a,g]=y.useState(""),x=M(),b=w(),r=I().getType(s.server_name),{canEditServerConfiguration:d}=F(),f=()=>{x.invalidateQueries({queryKey:[p.cluster],predicate:i=>i.queryKey[0]===p.cluster||i.queryKey[0]===p.operations})},S=()=>{t.success(e.jsxs(e.Fragment,{children:["Member"," ",e.jsx(v,{type:"cluster-member",value:s.server_name,to:`/ui/cluster/member/${encodeURIComponent(s.server_name)}`})," ","restore completed."]}))},E=i=>{t.failure("Member restore failed",new Error(i),e.jsx(v,{type:"cluster-member",value:s.server_name,to:`/ui/cluster/member/${encodeURIComponent(s.server_name)}`}))},N=()=>{h(!0),k(s,"restore",a).then(i=>{t.info(e.jsxs(e.Fragment,{children:["Member"," ",e.jsx(v,{to:`/ui/cluster/member/${encodeURIComponent(s.server_name)}`,type:"cluster-member",value:s.server_name})," ","restore started."]})),b.set(i.metadata.id,S,E,f),l==null||l()}).catch(i=>{c.failure("Member restore failed",i)}).finally(()=>{h(!1),f()})},j=d(),_=m||s.status!=="Evacuated"||!!r||!j;return e.jsxs(n.ConfirmationButton,{appearance:o?"":"base",loading:m||r==="Restoring",disabled:_,confirmationModalProps:{title:"Confirm restore",children:e.jsxs(e.Fragment,{children:[e.jsx(n.CheckboxInput,{label:"Restore instances",onChange:()=>{g(a===""?"skip":"")},checked:a===""}),e.jsx("p",{className:"p-form-help-text",children:"Chose whether to restore instances that were stopped or migrated"}),e.jsxs("p",{children:["This will restore cluster member"," ",e.jsx(L,{type:"cluster-member",value:s.server_name,bold:!0}),"."]})]}),confirmButtonLabel:j?"Restore cluster member":"You do not have permission to restore cluster members",onConfirm:N,confirmButtonAppearance:"positive"},shiftClickEnabled:!0,title:"Restore cluster member",className:R(u,"has-icon u-no-margin--bottom"),children:[e.jsx(n.Icon,{name:"play"}),o&&e.jsx("span",{children:"Restore"})]})},D=({onClose:s})=>{var C;const o=B(),u=n.useNotify(),l=n.useToastNotification(),c=M(),{data:t}=P(o.member??""),{data:m=[]}=A(),h=()=>{o.clear(),u.clear(),s==null||s()},a=G({initialValues:{name:(t==null?void 0:t.server_name)??"",description:(t==null?void 0:t.description)??"",failureDomain:(t==null?void 0:t.failure_domain)??"",groups:(t==null?void 0:t.groups)??[]},enableReinitialize:!0,onSubmit:r=>{const d={server_name:r.name,description:r.description,failure_domain:r.failureDomain,groups:r.groups,roles:t==null?void 0:t.roles};T(d).then(()=>{l.success(e.jsxs(e.Fragment,{children:["Cluster member"," ",e.jsx(v,{type:"cluster-member",value:r.name,to:`/ui/cluster/member/${encodeURIComponent(r.name)}`})," ","saved."]})),h()}).catch(f=>{u.failure("Cluster member update failed",f)}).finally(()=>{a.setSubmitting(!1),c.invalidateQueries({queryKey:[p.cluster,p.members]}),c.invalidateQueries({queryKey:[p.cluster,p.members,r.name]})})}}),g=a.values.groups.filter(r=>{var d;return!((d=t==null?void 0:t.groups)!=null&&d.includes(r))||!1}),x=((C=t==null?void 0:t.groups)==null?void 0:C.filter(r=>!a.values.groups.includes(r)))??[],b=new Set([...g,...x]);return e.jsxs(n.SidePanel,{children:[e.jsx(n.SidePanel.Header,{children:e.jsxs(n.SidePanel.HeaderTitle,{children:["Edit cluster member ",o.member]})}),e.jsx(q,{className:"u-no-padding"}),e.jsx(n.SidePanel.Content,{className:"u-no-padding",children:e.jsx(n.ScrollableContainer,{dependencies:[u.notification],belowIds:["panel-footer"],children:e.jsxs(n.Form,{onSubmit:a.handleSubmit,children:[e.jsx(n.Input,{type:"submit",hidden:!0,value:"Hidden input"}),e.jsx(n.Input,{...a.getFieldProps("description"),type:"text",label:"Description",placeholder:"Enter description"}),e.jsx(n.Input,{...a.getFieldProps("failureDomain"),type:"text",label:"Failure domain",placeholder:"Enter failure domain"}),e.jsx("p",{className:"u-sv-1",children:"Cluster groups"}),e.jsx($,{groups:m,modifiedGroups:b,parentItemName:"member",parentItems:[{name:a.values.name}],selectedGroups:new Set(a.values.groups),setSelectedGroups:(r,d)=>{d?a.setFieldValue("groups",[]):a.setFieldValue("groups",r)},preselectedGroups:new Set((t==null?void 0:t.groups)??[]),indeterminateGroups:new Set,toggleGroup:r=>{const d=new Set([...a.values.groups]);d.has(r)?d.delete(r):d.add(r),a.setFieldValue("groups",[...d])},scrollDependencies:[u.notification]})]})})}),e.jsxs(n.SidePanel.Footer,{className:"u-align--right",children:[e.jsx(n.Button,{appearance:"base",onClick:h,className:"u-no-margin--bottom",children:"Cancel"}),e.jsx(n.ActionButton,{appearance:"positive",loading:a.isSubmitting,onClick:()=>void a.submitForm(),className:"u-no-margin--bottom",disabled:!a.isValid||a.isSubmitting||!a.values.name,children:"Save changes"})]})]})},H=({member:s,hasLabel:o=!1,className:u,onClose:l})=>{const c=B(),{canEditServerConfiguration:t}=F(),m=t();return e.jsxs(e.Fragment,{children:[e.jsxs(n.Button,{appearance:o?"":"base",className:R(u,"u-no-margin--bottom"),disabled:!m,onClick:()=>{c.openEditMember(s)},title:m?"Edit cluster member":"You do not have permission to edit cluster members",hasIcon:!0,children:[e.jsx(n.Icon,{name:"edit"}),o&&e.jsx("span",{children:"Edit"})]}),c.panel===U.editClusterMember&&c.member===s&&e.jsx(D,{onClose:l})]})},X=({member:s,isDetailPage:o=!1})=>{const u=K(Q);if(!s)return null;const l=o?u?"p-contextual-menu__link":"p-segmented-control__button":"",c=[];return c.push(e.jsx(V,{member:s,hasLabel:o,className:l},"restore")),c.push(e.jsx(O,{member:s,hasLabel:o,className:l},"evacuate")),c.push(e.jsx(H,{member:s.server_name,hasLabel:o,className:l},"edit")),o?u?e.jsx(n.ContextualMenu,{closeOnOutsideClick:!1,toggleLabel:"Actions",position:"left",hasToggleIcon:!0,title:"actions",children:t=>e.jsx("span",{children:[...c].map(m=>y.cloneElement(m,{onClose:t}))})}):e.jsx("div",{className:"p-segmented-control",children:e.jsxs("div",{className:"p-segmented-control__list",children:[...c]})}):e.jsx(n.List,{inline:!0,className:"actions-list",items:c})},Z=({member:s})=>{const u=I().getType(s.server_name);if(u)return e.jsxs(e.Fragment,{children:[e.jsx(n.Icon,{className:"u-animation--spin status-icon",name:"spinner"}),e.jsx("i",{children:u})]});const l=()=>({Evacuated:"status-queued-small",Online:"status-succeeded-small",Offline:"status-failed-small",Blocked:"status-waiting-small"})[s.status]??"";return e.jsxs(e.Fragment,{children:[e.jsx(n.Icon,{name:l(),className:"status-icon"}),s.status]})};export{Z as C,X as a};
Copyright ©2k19 -
Hexid
|
Tex7ure