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 a}from"./index-Cziemgsu.js";import{c as b,a as $}from"./index.esm-dDZ7-lOE.js";import{N as k}from"./NotificationRow-BJRTvUVl.js";import{B as P}from"./BaseLayout-7LTMOawH.js";import{M as T,v as B,a as K}from"./StorageVolumeForm-0gLpkZqf.js";import{P as O}from"./StorageVolumesFilter-Dy03DJeW.js";import{F as Q}from"./FormFooterLayout-BJQGpdhQ.js";import{R}from"./ResourceLink-D2AYI_En.js";import"./FormMenuItem-phSiN9Ls.js";import"./instanceOptions-BVjIWe7l.js";import"./ConfigFieldDescription-1GO19eHS.js";import"./AutoExpandingTextArea-Bc4N4lSt.js";import"./ScrollableTable-D1yV1_jU.js";import"./formFields-BDRvqvBI.js";import"./snapshots-AEdTpwkf.js";import"./DiskSizeSelector--EFhW8D8.js";import"./ClusterMemberSelector--J9qxfzT.js";import"./StoragePoolSelector-BZZPCPdz.js";import"./CustomSelect-1ZX4nHvi.js";import"./StoragePoolSize-DPO2JD2N.js";import"./searchAndFilter-BEZtSWxl.js";import"./ScrollableContainer-C6sud4ax.js";import"./ResourceIcon-DRRIqKSs.js";const ie=()=>{const n=j(),l=m.useNotify(),p=h(),r=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(()=>{r.invalidateQueries({queryKey:[a.storage]}),r.invalidateQueries({queryKey:[a.customVolumes,t]}),r.invalidateQueries({queryKey:[a.projects,t]}),r.invalidateQueries({predicate:i=>i.queryKey[0]===a.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{ie as default};
