| Current Path : /snap/lxd/38768/share/lxd-ui/assets/ |
| Current File : //snap/lxd/38768/share/lxd-ui/assets/CreateStoragePool-D-AvdyLy.js |
import{c as j,d as s,v as P,C as x,r as m,a6 as p,t as b,j as e,f as N,h as F,ak as R,k as v,al as I,am as M,an as T,x as k,R as u,p as q,ao as O,ap as $,aq as A}from"./index-BsQN_SZU.js";import{B as w}from"./BaseLayout-D3ZT4TU8.js";import{M as z,t as B,S as E}from"./StoragePoolForm-BroxRsS_.js";import{F as U}from"./FormFooterLayout-CcbL_-PB.js";import{y as D,Y as K}from"./YamlSwitch-BStSXJFs.js";import{S as L}from"./StoragePoolRichChip-Daex_aZU.js";import"./DiskSizeSelector-C9kWj54D.js";import"./limits-yeXZOxhv.js";import"./AutoExpandingTextArea-Bd-45rZK.js";import"./formFields-DzJouV_d.js";import"./SshKeyForm-BNz7yPwa.js";import"./scroll-Dc7Cgzms.js";import"./ProjectRichChip-DZzjTfq6.js";import"./ConfigFieldDescription-CjXKAIpa.js";import"./snapshots-LtzKNDw1.js";import"./ClusterSpecificInput-7EvfCd3b.js";import"./ClusterMemberRichChip-Di9w-E3M.js";import"./ClusterMemberMemoryUsage-DYUQFY0n.js";import"./Meter-cq8smrSm.js";import"./StoragePoolSize-BNbqTfwA.js";const pe=()=>{const i=j(),d=s.useNotify(),g=s.useToastNotification(),S=P(),{project:a}=x(),[n,f]=m.useState(p(z)),y=m.useState(null),{data:c=[]}=b();if(!a)return e.jsx(e.Fragment,{children:"Missing project"});const C=N().shape({name:F().test(...R(a,y)).required("This field is required")}),t=v({initialValues:{isCreating:!0,readOnly:!1,name:"",description:"",driver:I,source:"",size:"",entityType:"storagePool"},validationSchema:C,onSubmit:o=>{const r=o.yaml?D(o.yaml):B(o);(c.length>0?async()=>M(r,c,o.sourcePerClusterMember,o.zfsPoolNamePerClusterMember,o.sizePerClusterMember):async()=>T(r))().then(()=>{S.invalidateQueries({queryKey:[k.storage]}),i(`${u}/ui/project/${encodeURIComponent(a)}/storage/pools`),g.success(e.jsxs(e.Fragment,{children:["Storage pool"," ",e.jsx(L,{poolName:r.name,projectName:a})," ","created."]}))}).catch(h=>{t.setSubmitting(!1),d.failure("Storage pool creation failed",h)})}}),l=o=>{f(p(o))};return e.jsxs(w,{title:"Create a storage pool",contentClassName:"create-storage-pool",children:[e.jsx(q,{}),e.jsx(E,{formik:t,section:n,setSection:l}),e.jsxs(U,{children:[e.jsx("div",{className:"yaml-switch",children:e.jsx(K,{formik:t,section:n,setSection:l,disableReason:t.values.name?void 0:"Please enter a storage pool name to enable this section"})}),e.jsx(s.Button,{appearance:"base",onClick:async()=>i(`${u}/ui/project/${encodeURIComponent(a)}/storage/pools`),children:"Cancel"}),e.jsx(s.ActionButton,{appearance:"positive",loading:t.isSubmitting,disabled:!t.isValid||t.isSubmitting||!t.values.name||O(t)||$(t)||A(t),onClick:()=>{t.submitForm()},children:"Create"})]})]})};export{pe as default};