Your IP : 216.73.216.189


Current Path : /proc/thread-self/root/snap/lxd/current/share/lxd-ui/assets/
Upload File :
Current File : //proc/thread-self/root/snap/lxd/current/share/lxd-ui/assets/CreateProject-BOKoalXK.js

import{c as b,d as a,t as R,r as c,a5 as d,K as C,u as F,f as N,h as E,E as $,k as D,ab as T,R as j,w as A,ac as B,ad as L,j as e,a2 as O}from"./index-BFGypnt-.js";import{P as q,i as z,n as H,d as I,a as K,c as U,r as J,p as Q,b as V,e as G}from"./ProjectForm-CDXtLiR1.js";import{B as M}from"./BaseLayout-ft99KK4_.js";import{F as Z}from"./FormFooterLayout-CMGxv4XX.js";import{a as W,f as X,b as Y}from"./useProfiles-CErbukD2.js";import{P as v}from"./ProjectRichChip-CtiU36yR.js";import"./FormMenuItem-fhYfVpHc.js";import"./ConfigurationTable-CmO6jSmV.js";import"./ConfigFieldDescription-CY0sdTp6.js";import"./useStoragePools-qBtKr1j9.js";import"./useClusterMembers-B29_ixY7.js";import"./cluster-members-CG6XHzn4.js";import"./AutoExpandingTextArea-WEdimI5c.js";import"./ScrollableForm-D-7nf2YI.js";import"./StoragePoolSelector-CIzPJc24.js";import"./StoragePoolSize-ChYxPd_8.js";import"./Meter-VGEmUMfL.js";import"./NetworkSelector-BaEsMhep.js";import"./useNetworks-B1lu5MbM.js";import"./ProfileRichChip-XiLIeCE5.js";import"./ProfileResourceLimits-DkY60ueM.js";import"./ScrollableConfigurationTable-Cdfv_OdM.js";import"./DiskSizeSelector-C_YZZUSe.js";import"./useResources-D4gdq2PK.js";import"./useClusterGroups-BlRzika4.js";import"./useImageRegistries-BcqfYS33.js";import"./image-registries-YAuyq4CZ.js";import"./images-C6WqBeZG.js";const Ft=()=>{const i=b(),p=a.useNotify(),m=a.useToastNotification(),y=R(),_=c.useState(null),[f,h]=c.useState(d(q)),{hasProjectsNetworksZones:g,hasStorageBuckets:P}=C(),{isFineGrained:k}=F(),{data:r}=W("default","default"),S=N().shape({name:E().test("deduplicate","A project with this name already exists",async t=>$(t,"",_,"projects")).required()}),u=()=>{O("form-contents","p-bottom-controls")};c.useEffect(u,[p.notification?.message,f]),a.useListener(window,u,"resize",!0);const l=t=>{i(`${j}/ui/project/${encodeURIComponent(t.name)}/instances`),m.success(e.jsxs(e.Fragment,{children:["Project"," ",e.jsx(v,{projectName:t.name,urlSuffix:"/instances"})," ","created."]}))},o=D({initialValues:{name:"",restricted:!1,readOnly:!1,entityType:"project",default_instance_storage_pool:r?L(r):"",default_project_network:r?B(r):"",features_images:!0,features_profiles:!0,features_networks:!1,features_networks_zones:!1,features_storage_buckets:!0,features_storage_volumes:!0},enableReinitialize:!0,validationSchema:S,onSubmit:t=>{const w=t.restricted?{...U(t),...K(t),...I(t),...H(t),...z(t)}:{};g||(t.features_networks_zones=void 0),P||(t.features_storage_buckets=void 0);const n=t.default_project_network!=="none";T(JSON.stringify({...V(t),config:{...Q(t),...J(t),...w}})).then(async()=>{if(!t.default_instance_storage_pool&&!n||t.features_profiles===!1){l(t);return}const s=await X("default",t.name,k);s.devices={root:{path:"/",pool:t.default_instance_storage_pool,type:"disk"},...n&&{eth0:{name:"eth0",network:t.default_project_network,type:"nic"}}},Y(s,t.name).then(()=>{l(t)}).catch(x=>{i(`${j}/ui/project/${encodeURIComponent(t.name)}/instances`),m.failure(`Successfully created ${t.name} project. Failed to attach storage pool${n?" and network":""}.`,x)})}).catch(s=>{o.setSubmitting(!1),p.failure("Project creation failed",s)}).finally(()=>{y.invalidateQueries({queryKey:[A.projects]})})}});return e.jsxs(M,{title:"Create a project",contentClassName:"create-project",children:[e.jsx(G,{formik:o,section:f,updateSection:t=>{h(d(t))},isEdit:!1}),e.jsxs(Z,{children:[e.jsx(a.Button,{appearance:"base",onClick:async()=>i(-1),children:"Cancel"}),e.jsx(a.ActionButton,{appearance:"positive",loading:o.isSubmitting,disabled:!o.isValid||o.isSubmitting||!o.values.name,onClick:()=>{o.submitForm()},children:"Create"})]})]})};export{Ft as default};