import{f as j,d as m,k as h,l as x,r as u,J as c,o as C,au as N,j as e,a$ as F,c as q,b1 as V,q as r}from"./index-CzUo07dn.js";import{c as b,a as $}from"./index.esm-BBoKC3tX.js";import{N as k}from"./NotificationRow-IVGrYQV6.js";import{B as P}from"./BaseLayout-D6pt0Et9.js";import{M as T,v as B,a as K}from"./StorageVolumeForm-Den1BhUT.js";import{P as O}from"./StorageVolumesFilter-PdfD9x0A.js";import{F as Q}from"./FormFooterLayout-CkQ9739Z.js";import{R}from"./ResourceLink-5fvv3Myt.js";import"./FormMenuItem-D-3tk9Lf.js";import"./instanceOptions-BVjIWe7l.js";import"./ConfigFieldDescription-DYgLBIgn.js";import"./AutoExpandingTextArea-DbenJele.js";import"./ScrollableTable-COas1_r_.js";import"./formFields-BDRvqvBI.js";import"./snapshots-DWXTDgvk.js";import"./DiskSizeSelector-C28v9MJO.js";import"./StoragePoolSelector-B0M_DZ36.js";import"./CustomSelect-D8P9H5Av.js";import"./StoragePoolSize-DCNPXe9o.js";import"./searchAndFilter-BEZtSWxl.js";import"./ScrollableContainer-CSFAM_C4.js";import"./ResourceIcon-CQum9kVZ.js";const re=()=>{const n=j(),l=m.useNotify(),p=h(),a=x(),[d,y]=u.useState(c(T)),f=u.useState(null),{project:t}=C(),[g]=N();if(!t)return e.jsx(e.Fragment,{children:"Missing project"});const v=b().shape({name:$().test(...F(t,"custom",f)).required("This field is required")}),s=q({initialValues:{content_type:"filesystem",volumeType:"custom",name:"",project:t,pool:g.get(O)||"",size:"GiB",readOnly:!1,isCreating:!0,entityType:"storageVolume"},validationSchema:v,onSubmit:o=>{const S=B(o,t);V(o.pool,t,S,o.clusterMember).then(()=>{a.invalidateQueries({queryKey:[r.storage]}),a.invalidateQueries({queryKey:[r.customVolumes,t]}),a.invalidateQueries({queryKey:[r.projects,t]}),a.invalidateQueries({predicate:i=>i.queryKey[0]===r.volumes}),n(`/ui/project/${t}/storage/volumes`),p.success(e.jsxs(e.Fragment,{children:["Storage volume"," ",e.jsx(R,{type:"volume",value:o.name,to:`/ui/project/${t}/storage/pool/${o.pool}/volumes/custom/${o.name}`})," ","created."]}))}).catch(i=>{s.setSubmitting(!1),l.failure("Storage volume creation failed",i)})}});return e.jsxs(P,{title:"Create volume",contentClassName:"storage-volume-form",children:[e.jsx(k,{}),e.jsx(K,{formik:s,section:d,setSection:o=>y(c(o))}),e.jsxs(Q,{children:[e.jsx(m.Button,{appearance:"base",onClick:()=>n(`/ui/project/${t}/storage/volumes`),children:"Cancel"}),e.jsx(m.ActionButton,{appearance:"positive",loading:s.isSubmitting,disabled:!s.isValid,onClick:()=>void s.submitForm(),children:"Create"})]})]})};export{re as default};
