%PDF- %PDF-
Direktori : /proc/self/root/snap/lxd/29351/share/lxd-ui/assets/ |
Current File : //proc/self/root/snap/lxd/29351/share/lxd-ui/assets/CreateProject-3768bb7f.js |
import{e as y,d as i,i as h,r as o,z as P,A as S,j as e,B as x,K as b,q as g}from"./index-13b2882d.js";import{c as C,a as R,u as E}from"./index.esm-82c30f37.js";import{S as N,u as k}from"./updateMaxHeight-325b3cd4.js";import{P as q,a as D,c as L,i as B,d as F,n as $,p as w,b as z,r as A}from"./ProjectForm-55619b78.js";import"./FormMenuItem-c8a1a121.js";import"./formFields-fc140429.js";import"./instanceConfigInheritance-fbf987f8.js";import"./ConfigurationTable-1a9d4d6f.js";import"./ConfigFieldDescription-00c1a193.js";import"./AutoExpandingTextArea-3a779a81.js";import"./DiskSizeSelector-dd5e138a.js";const _=()=>{var m;const r=y(),a=i.useNotify(),l=h(),d=o.useState(null),[c,u]=o.useState(q),p=C().shape({name:R().test("deduplicate","A project with this name already exists",t=>P(t,"",d,"projects")).required()}),n=()=>{k("form-contents","p-bottom-controls")};o.useEffect(n,[(m=a.notification)==null?void 0:m.message,c]),S("resize",n);const s=E({initialValues:{name:"",restricted:!1,readOnly:!1,type:"project"},validationSchema:p,onSubmit:t=>{const j=t.restricted?{...L(t),...B(t),...F(t),...$(t)}:{};b(JSON.stringify({...w(t),config:{...z(t),...A(t),...j}})).then(()=>{r(`/ui/project/${t.name}/instances`,a.queue(a.success(`Project ${t.name} created.`)))}).catch(f=>{s.setSubmitting(!1),a.failure("Project creation failed",f)}).finally(()=>{l.invalidateQueries({queryKey:[g.projects]})})}});return e.jsxs(x,{title:"Create a project",contentClassName:"create-project",children:[e.jsx(D,{formik:s,section:c,updateSection:u,isEdit:!1}),e.jsxs("div",{className:"p-bottom-controls",id:"form-footer",children:[e.jsx("hr",{}),e.jsx(i.Row,{className:"u-align--right",children:e.jsxs(i.Col,{size:12,children:[e.jsx(i.Button,{appearance:"base",onClick:()=>r(-1),children:"Cancel"}),e.jsx(N,{isSubmitting:s.isSubmitting,isDisabled:!s.isValid||!s.values.name,buttonLabel:"Create",onClick:()=>void s.submitForm()})]})})]})]})};export{_ as default};