/
snap
/
lxd
/
current
/
share
/
lxd-ui
/
assets
/
File Upload :
llllll
Current File: //snap/lxd/current/share/lxd-ui/assets/Server-CzNMq74b.js
import{B as g,l as b,d as t,c as x,b as y,f,g as d,i as j,bO as N,q as v,j as e,n as C,e as S}from"./index-dL2n30-Z.js";import{C as k}from"./ClusterMemberHardware-DKiFONjB.js";import{B as q}from"./BaseLayout-DoX0qSEj.js";import{T as A}from"./TabLinks-BqmE_r1L.js";import"./ScrollableContainer-ceiHesUW.js";import"./debounce-DuKxa5-z.js";import"./Meter-BBGrNnHA.js";import"./scroll-Dmr9Jl9h.js";const B=async s=>fetch("/1.0/cluster",{method:"PUT",headers:{"Content-Type":"application/json"},body:s}).then(g).then(r=>r.metadata),E=({onClose:s})=>{var u;const r=b(),n=t.useNotify(),i=t.useToastNotification(),m=x(),{data:l}=y(),p=f().shape({serverName:d().required("This field is required"),clusterAddress:d().required("This field is required")}),a=j({initialValues:{serverName:"",clusterAddress:((u=l==null?void 0:l.config)==null?void 0:u["cluster.https_address"])??""},enableReinitialize:!0,validationSchema:p,onSubmit:async c=>{try{await N({"cluster.https_address":String(c.clusterAddress)})}catch(o){n.failure("Failed to update cluster address",o);return}const h=JSON.stringify({server_name:c.serverName,enabled:!0});B(h).then(()=>{i.success("Clustering enabled."),r.invalidateQueries({queryKey:[v.settings]}),m("/ui/cluster/members")}).catch(o=>{n.failure("Failed to enable clustering",o)}).finally(()=>{a.setSubmitting(!1)})}});return e.jsxs(t.Modal,{close:s,title:"Enable clustering",className:"enable-clustering-modal",buttonRow:e.jsxs(e.Fragment,{children:[e.jsx(t.Button,{"aria-label":"Close",className:"u-no-margin--bottom",onClick:s,type:"button",children:"Close"}),e.jsx(t.ActionButton,{appearance:"positive",loading:a.isSubmitting,className:"u-no-margin--bottom",onClick:()=>void a.submitForm(),disabled:!a.values.serverName||!a.values.clusterAddress,type:"button",children:"Enable clustering"})]}),children:[e.jsx(t.NotificationConsumer,{}),e.jsx(t.Notification,{severity:"caution",title:"Are you sure you want to enable clustering?",children:"This action cannot be undone."}),e.jsx(t.Input,{label:"Server name",type:"text",required:!0,...a.getFieldProps("serverName")}),e.jsx(t.Input,{label:"Cluster address",type:"text",help:"Address to use for clustering traffic by this server",required:!0,...a.getFieldProps("clusterAddress")})]})},F=()=>{const{openPortal:s,closePortal:r,isOpen:n,Portal:i}=t.usePortal({programmaticallyOpen:!0});return e.jsxs(e.Fragment,{children:[e.jsxs(t.Button,{appearance:"positive",hasIcon:!0,onClick:s,children:[e.jsx(t.Icon,{name:"plus",light:!0}),e.jsx("span",{children:"Enable clustering"})]}),n&&e.jsx(i,{children:e.jsx(E,{onClose:r})})]})},M=({activeTab:s})=>{const r=C(),n=["Hardware","Clustering"];return e.jsxs(q,{title:"Server",contentClassName:"detail-page cluster-member-details",children:[e.jsx(S,{}),e.jsxs(t.Row,{children:[e.jsx(A,{tabs:n,activeTab:s,tabUrl:"/ui/server"}),!s&&e.jsx(k,{}),s==="clustering"&&e.jsxs(t.EmptyState,{className:"empty-state",image:e.jsx(t.Icon,{name:"cluster-host",className:"empty-state-icon"}),title:"This server is not clustered",children:[e.jsx("p",{children:e.jsxs("a",{href:`${r}/explanation/clustering/`,target:"_blank",rel:"noopener noreferrer",children:["Learn more about clustering",e.jsx(t.Icon,{className:"external-link-icon",name:"external-link"})]})}),e.jsx(F,{})]})]})]})};export{M as default};
Copyright ©2k19 -
Hexid
|
Tex7ure