import{f as v,d as r,k as C,l as N,o as P,r as p,J as u,p as b,j as e,T as F,U as k,c as q,V as R,W as T,q as $,X as M}from"./index-CzUo07dn.js";import{B as w}from"./BaseLayout-D6pt0Et9.js";import{N as B}from"./NotificationRow-IVGrYQV6.js";import{c as I,a as O}from"./index.esm-BBoKC3tX.js";import{M as A,u as D,t as E,S as L}from"./useClusterMembers-CwCStE1-.js";import{F as V}from"./FormFooterLayout-CkQ9739Z.js";import{y as z,c as K}from"./YamlSwitch-DLbjsyg1.js";import{R as Q}from"./ResourceLink-5fvv3Myt.js";import"./DiskSizeSelector-C28v9MJO.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"./ScrollableContainer-CSFAM_C4.js";import"./ResourceIcon-CQum9kVZ.js";const me=()=>{const i=v(),d=r.useNotify(),g=C(),S=N(),{project:s}=P(),[n,f]=p.useState(u(A)),y=p.useState(null),{data:c=[]}=D(),{data:j}=b();if(!s)return e.jsx(e.Fragment,{children:"Missing project"});const x=I().shape({name:O().test(...F(s,y)).required("This field is required")}),l=k(j),t=q({initialValues:{isCreating:!0,readOnly:!1,name:"",description:"",driver:l.size>0?l.values().next().value:"",source:"",size:"",entityType:"storagePool"},validationSchema:x,onSubmit:o=>{const a=o.yaml?z(o.yaml):E(o);(c.length>0?()=>R(a,c):()=>T(a))().then(()=>{S.invalidateQueries({queryKey:[$.storage]}),i(`/ui/project/${s}/storage/pools`),g.success(e.jsxs(e.Fragment,{children:["Storage pool"," ",e.jsx(Q,{type:"pool",value:a.name,to:`/ui/project/${s}/storage/pool/${o.name}`})," ","created."]}))}).catch(h=>{t.setSubmitting(!1),d.failure("Storage pool creation failed",h)})}}),m=o=>{f(u(o))};return e.jsxs(w,{title:"Create a storage pool",contentClassName:"create-storage-pool",children:[e.jsx(B,{}),e.jsx(L,{formik:t,section:n,setSection:m}),e.jsxs(V,{children:[e.jsx("div",{className:"yaml-switch",children:e.jsx(K,{formik:t,section:n,setSection:m,disableReason:t.values.name?void 0:"Please enter a storage pool name to enable this section"})}),e.jsx(r.Button,{appearance:"base",onClick:()=>i(`/ui/project/${s}/storage/pools`),children:"Cancel"}),e.jsx(r.ActionButton,{appearance:"positive",loading:t.isSubmitting,disabled:!t.isValid||!t.values.name||M(t),onClick:()=>void t.submitForm(),children:"Create"})]})]})};export{me as default};
