/
snap
/
lxd
/
current
/
share
/
lxd-ui
/
assets
/
File Upload :
llllll
Current File: //snap/lxd/current/share/lxd-ui/assets/Server-DjdccHpv.js
import{C as g,l as b,d as t,c as x,b as y,f,g as p,i as j,bY as v,q as C,j as e,m as N,e as S,aJ as E}from"./index-B3cgCbnJ.js";import{C as q}from"./ClusterMemberHardware-ckiwZVJQ.js";import{B as A}from"./BaseLayout-DIbLs-hH.js";import{T as F}from"./TabLinks-BN40EEc5.js";import"./Meter-v0AAwaqr.js";import"./scroll-BEbDVMxI.js";const P=async s=>fetch("/1.0/cluster",{method:"PUT",headers:{"Content-Type":"application/json"},body:s}).then(g).then(r=>r.metadata),k=({onClose:s})=>{var d;const r=b(),i=t.useNotify(),l=t.useToastNotification(),o=x(),{data:n}=y(),u=f().shape({serverName:p().required("This field is required"),clusterAddress:p().required("This field is required")}),a=j({initialValues:{serverName:"",clusterAddress:((d=n==null?void 0:n.config)==null?void 0:d["cluster.https_address"])??""},enableReinitialize:!0,validationSchema:u,onSubmit:async m=>{try{await v({"cluster.https_address":String(m.clusterAddress)})}catch(c){i.failure("Failed to update cluster address",c);return}const h=JSON.stringify({server_name:m.serverName,enabled:!0});P(h).then(()=>{l.success("Clustering enabled."),r.invalidateQueries({queryKey:[C.settings]}),o("/ui/cluster/members")}).catch(c=>{i.failure("Failed to enable clustering",c)}).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")})]})},w=()=>{const{canEditServerConfiguration:s}=N(),{openPortal:r,closePortal:i,isOpen:l,Portal:o}=t.usePortal({programmaticallyOpen:!0}),n=s(),u=n?"Enable clustering":"You do not have permission to edit the server";return e.jsxs(e.Fragment,{children:[e.jsxs(t.Button,{appearance:"positive",hasIcon:!0,onClick:r,disabled:!n,title:u,children:[e.jsx(t.Icon,{name:"plus",light:!0}),e.jsx("span",{children:"Enable clustering"})]}),l&&e.jsx(o,{children:e.jsx(k,{onClose:i})})]})},O=({activeTab:s})=>{const r=["Hardware","Clustering"];return e.jsxs(A,{title:"Server",contentClassName:"detail-page cluster-member-details",children:[e.jsx(S,{}),e.jsxs(t.Row,{children:[e.jsx(F,{tabs:r,activeTab:s,tabUrl:"/ui/server"}),!s&&e.jsx(q,{}),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.jsx(E,{docPath:"/explanation/clustering/",hasExternalIcon:!0,children:"Learn more about clustering"})}),e.jsx(w,{})]})]})]})};export{O as default};
Copyright ©2k19 -
Hexid
|
Tex7ure