%PDF- %PDF-
Direktori : /snap/lxd/28373/share/lxd-ui/assets/ |
Current File : //snap/lxd/28373/share/lxd-ui/assets/CreateStoragePool-e2d089cb.js |
import{e as b,d as a,i as j,m as x,r as C,j as e,B as v,b as y,M as P,O as q,q as N}from"./index-13b2882d.js";import{S as z}from"./updateMaxHeight-325b3cd4.js";import{c as $,a as k,u as B}from"./index.esm-82c30f37.js";import{u as D,t as F,S as M,z as R,b as V}from"./useClusterMembers-dbf45674.js";import"./DiskSizeSelector-dd5e138a.js";import"./AutoExpandingTextArea-3a779a81.js";import"./FormMenuItem-c8a1a121.js";import"./StorageVolumeFormMenu-e90b9f5c.js";import"./settings-c23f9009.js";const I=()=>{const i=b(),o=a.useNotify(),u=j(),{project:t}=x(),m=C.useState(null),{data:n=[]}=D();if(!t)return e.jsx(e.Fragment,{children:"Missing project"});const d=$().shape({name:k().test(...F(t,m)).required("This field is required")}),s=B({initialValues:{isCreating:!0,isReadOnly:!1,name:"",description:"",driver:R,source:"",size:""},validationSchema:d,onSubmit:({name:p,description:g,driver:c,source:f,size:l})=>{const S=l.match(/^\d/),r={name:p,description:g,driver:c,source:c!==V?f:void 0,config:{size:S?l:void 0}};(n.length>0?()=>P(r,t,n):()=>q(r,t))().then(()=>{u.invalidateQueries({queryKey:[N.storage]}),i(`/ui/project/${t}/storage`,o.queue(o.success(`Storage pool ${r.name} created.`)))}).catch(h=>{s.setSubmitting(!1),o.failure("Storage pool creation failed",h)})}});return e.jsxs(v,{title:"Create a storage pool",contentClassName:"create-storage-pool",children:[e.jsx(y,{}),e.jsx(M,{formik:s}),e.jsxs("div",{className:"p-bottom-controls",children:[e.jsx("hr",{}),e.jsx(a.Row,{className:"u-align--right",children:e.jsxs(a.Col,{size:12,children:[e.jsx(a.Button,{appearance:"base",onClick:()=>i(`/ui/project/${t}/storage`),children:"Cancel"}),e.jsx(z,{isSubmitting:s.isSubmitting,isDisabled:!s.isValid||!s.values.name,buttonLabel:"Create",onClick:()=>void s.submitForm()})]})})]})]})};export{I as default};