/
snap
/
lxd
/
current
/
share
/
lxd-ui
/
assets
/
File Upload :
llllll
Current File: //snap/lxd/current/share/lxd-ui/assets/CreateStoragePool-BPLymB1c.js
import{c as j,d as s,l as h,p as x,r as m,V as p,k as P,j as e,f as b,g as N,a7 as I,i as R,a8 as F,a9 as M,aa as v,q as k,R as q,e as $,ab as T,ac as U,ad as w}from"./index-B3cgCbnJ.js";import{B as z}from"./BaseLayout-DIbLs-hH.js";import{M as A,t as B,S as O}from"./StoragePoolForm-BqqQdWs0.js";import{F as E}from"./FormFooterLayout-ChlQYZN0.js";import{y as L,c as V}from"./YamlSwitch-Bng19N-X.js";import"./DiskSizeSelector-CIkNkBL4.js";import"./limits-CLEFMbq-.js";import"./AutoExpandingTextArea-BmFqLvbw.js";import"./FormMenuItem-BwEOqt61.js";import"./scroll-BEbDVMxI.js";import"./instanceOptions-D4bz_1Ev.js";import"./ConfigFieldDescription-C9KDhW5s.js";import"./snapshots-Bt9cFkFc.js";import"./ClusterSpecificInput-C86z5N6a.js";const se=()=>{const i=j(),u=s.useNotify(),d=s.useToastNotification(),g=h(),{project:a}=x(),[n,y]=m.useState(p(A)),f=m.useState(null),{data:c=[]}=P();if(!a)return e.jsx(e.Fragment,{children:"Missing project"});const S=b().shape({name:N().test(...I(a,f)).required("This field is required")}),t=R({initialValues:{isCreating:!0,readOnly:!1,name:"",description:"",driver:F,source:"",size:"",entityType:"storagePool"},validationSchema:S,onSubmit:o=>{const r=o.yaml?L(o.yaml):B(o);(c.length>0?async()=>M(r,c,o.sourcePerClusterMember,o.zfsPoolNamePerClusterMember,o.sizePerClusterMember):async()=>v(r))().then(()=>{g.invalidateQueries({queryKey:[k.storage]}),i(`/ui/project/${encodeURIComponent(a)}/storage/pools`),d.success(e.jsxs(e.Fragment,{children:["Storage pool"," ",e.jsx(q,{type:"pool",value:r.name,to:`/ui/project/${encodeURIComponent(a)}/storage/pool/${encodeURIComponent(o.name)}`})," ","created."]}))}).catch(C=>{t.setSubmitting(!1),u.failure("Storage pool creation failed",C)})}}),l=o=>{y(p(o))};return e.jsxs(z,{title:"Create a storage pool",contentClassName:"create-storage-pool",children:[e.jsx($,{}),e.jsx(O,{formik:t,section:n,setSection:l}),e.jsxs(E,{children:[e.jsx("div",{className:"yaml-switch",children:e.jsx(V,{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(`/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||T(t)||U(t)||w(t),onClick:()=>void t.submitForm(),children:"Create"})]})]})};export{se as default};
Copyright ©2k19 -
Hexid
|
Tex7ure