| Current Path : /proc/thread-self/root/snap/lxd/current/share/lxd-ui/assets/ |
| Current File : //proc/thread-self/root/snap/lxd/current/share/lxd-ui/assets/CreateStoragePool-DBTS-SFj.js |
import{c as I,d as r,t as R,I as w,r as S,a5 as h,K as M,J as O,j as e,f as T,h as k,k as A,R as y,y as $,p as q,w as z}from"./index-BFGypnt-.js";import{t as E,z as B,c as Q,a as D,i as K,b as L,d as U,e as V,f as _}from"./useStoragePools-qBtKr1j9.js";import{B as G}from"./BaseLayout-ft99KK4_.js";import{M as H,t as J,S as Y}from"./StoragePoolForm-hvCxtFgL.js";import{u as W}from"./useClusterMembers-B29_ixY7.js";import{F as X}from"./FormFooterLayout-CMGxv4XX.js";import{y as Z,d as ee}from"./YamlSwitch-BQqYYI1i.js";import{S as te}from"./StoragePoolRichChip-CxRTjvv2.js";import"./DiskSizeSelector-C_YZZUSe.js";import"./AutoExpandingTextArea-WEdimI5c.js";import"./ScrollableForm-D-7nf2YI.js";import"./FormMenuItem-fhYfVpHc.js";import"./ClusterMemberRichChip-h3WaiYeI.js";import"./ClusterMemberMemoryUsage-UO8J-hw2.js";import"./Meter-VGEmUMfL.js";import"./cluster-members-CG6XHzn4.js";import"./ClusterSpecificInput-BYM6R5do.js";import"./ConfigurationTable-CmO6jSmV.js";import"./ConfigFieldDescription-CY0sdTp6.js";import"./useProfiles-CErbukD2.js";import"./ScrollableConfigurationTable-Cdfv_OdM.js";import"./StoragePoolSize-ChYxPd_8.js";const Fe=()=>{const n=I(),C=r.useNotify(),c=r.useToastNotification(),j=R(),{project:s}=w(),[l,b]=S.useState(h(H)),P=S.useState(null),{data:m=[]}=W(),{hasRemoteDropSource:x,hasStorageAndNetworkOperations:p}=M(),N=O();if(!s)return e.jsx(e.Fragment,{children:"Missing project"});const F=T().shape({name:k().test(...E(s,P)).required("This field is required")}),u=()=>{j.invalidateQueries({queryKey:[z.storage]})},d=o=>{u(),t.setSubmitting(!1),c.success(e.jsxs(e.Fragment,{children:["Storage pool"," ",e.jsx(te,{poolName:o,projectName:s})," ","created."]}))},g=o=>{u(),t.setSubmitting(!1),C.failure("Creation of storage pool failed",o)},t=A({initialValues:{isCreating:!0,readOnly:!1,name:"",description:"",driver:B,source:"",size:"",entityType:"storagePool"},validationSchema:F,onSubmit:o=>{const a=o.yaml?Z(o.yaml):J(o,x);(m.length>0?async()=>Q(a,m,p,o.sourcePerClusterMember,o.zfsPoolNamePerClusterMember,o.sizePerClusterMember):async()=>D(a))().then(i=>{n(`${y}/ui/project/${encodeURIComponent(s)}/storage/pools`),p?(c.info(e.jsxs(e.Fragment,{children:["Creation of storage pool"," ",e.jsx($,{bold:!0,type:"pool",value:a.name})," has started."]})),N.set(i.metadata.id,()=>{d(a.name)},v=>{g(new Error(v))})):d(a.name)}).catch(i=>{g(i)})}}),f=o=>{b(h(o))};return e.jsxs(G,{title:"Create a storage pool",contentClassName:"create-storage-pool",children:[e.jsx(q,{}),e.jsx(Y,{formik:t,section:l,setSection:f}),e.jsxs(X,{children:[e.jsx("div",{className:"yaml-switch",children:e.jsx(ee,{formik:t,section:l,setSection:f,disableReason:t.values.name?void 0:"Please enter a storage pool name to enable this section"})}),e.jsx(r.Button,{appearance:"base",onClick:async()=>n(`${y}/ui/project/${encodeURIComponent(s)}/storage/pools`),children:"Cancel"}),e.jsx(r.ActionButton,{appearance:"positive",loading:t.isSubmitting,disabled:!t.isValid||t.isSubmitting||!t.values.name||K(t)||L(t)||U(t)||V(t)||_(t),onClick:()=>{t.submitForm()},children:"Create"})]})]})};export{Fe as default};