/
proc
/
3430793
/
root
/
snap
/
lxd
/
current
/
share
/
lxd-ui
/
assets
/
File Upload :
llllll
Current File: //proc/3430793/root/snap/lxd/current/share/lxd-ui/assets/CreateProject-Bn0yWGVl.js
import{c as C,d as a,l as R,r as c,V as j,G as b,u as F,a0 as N,f as D,g as E,Y as $,i as L,a1 as q,a2 as B,a3 as T,a4 as A,a5 as I,q as U,j as e,T as z,R as O}from"./index-dL2n30-Z.js";import{P as V,n as G,d as H,i as J,c as K,r as Q,p as M,a as Y,b as Z}from"./ProjectForm-DWfduXbW.js";import{B as W}from"./BaseLayout-DoX0qSEj.js";import{F as X}from"./FormFooterLayout-Bmq4RXkd.js";import"./FormMenuItem-DRePjRCl.js";import"./limits-CLEFMbq-.js";import"./AutoExpandingTextArea-CQuEMXHF.js";import"./scroll-Dmr9Jl9h.js";import"./instanceOptions-D4bz_1Ev.js";import"./ConfigFieldDescription-B5-bOr1x.js";import"./ScrollableTable-CQDmfMtz.js";import"./snapshots-AS6hXv2C.js";import"./StoragePoolSelector-BbIrdWMX.js";import"./StoragePoolSize-BwIynhzl.js";import"./Meter-BBGrNnHA.js";import"./NetworkSelector-C6jsH-fc.js";import"./useNetworks-FA5tQKQK.js";import"./networks-DWdMsnuF.js";import"./DiskSizeSelector-DZsA03GF.js";import"./useClusterGroups-ToCYhzHQ.js";import"./ScrollableContainer-ceiHesUW.js";const _t=()=>{var f;const r=C(),p=a.useNotify(),d=a.useToastNotification(),y=R(),h=c.useState(null),[l,g]=c.useState(j(V)),{hasProjectsNetworksZones:P,hasStorageBuckets:_}=b(),{isFineGrained:k}=F(),{data:i}=N("default","default"),S=D().shape({name:E().test("deduplicate","A project with this name already exists",async t=>$(t,"",h,"projects")).required()}),m=()=>{z("form-contents","p-bottom-controls")};c.useEffect(m,[(f=p.notification)==null?void 0:f.message,l]),a.useListener(window,m,"resize",!0);const u=t=>{r(`/ui/project/${encodeURIComponent(t.name)}/instances`),d.success(e.jsxs(e.Fragment,{children:["Project"," ",e.jsx(O,{type:"project",value:t.name,to:`/ui/project/${encodeURIComponent(t.name)}/instances`})," ","created."]}))},o=L({initialValues:{name:"",restricted:!1,readOnly:!1,entityType:"project",default_instance_storage_pool:i?B(i):"",default_project_network:i?q(i):""},enableReinitialize:!0,validationSchema:S,onSubmit:t=>{const w=t.restricted?{...K(t),...J(t),...H(t),...G(t)}:{};P||(t.features_networks_zones=void 0),_||(t.features_storage_buckets=void 0);const n=t.default_project_network!=="none";T(JSON.stringify({...Y(t),config:{...M(t),...Q(t),...w}})).then(async()=>{if(!t.default_instance_storage_pool&&!n||t.features_profiles===!1){u(t);return}const s=await A("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"}}},I(s,t.name).then(()=>{u(t)}).catch(x=>{r(`/ui/project/${encodeURIComponent(t.name)}/instances`),d.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:[U.projects]})})}});return e.jsxs(W,{title:"Create a project",contentClassName:"create-project",children:[e.jsx(Z,{formik:o,section:l,updateSection:t=>{g(j(t))},isEdit:!1}),e.jsxs(X,{children:[e.jsx(a.Button,{appearance:"base",onClick:async()=>r(-1),children:"Cancel"}),e.jsx(a.ActionButton,{appearance:"positive",loading:o.isSubmitting,disabled:!o.isValid||o.isSubmitting||!o.values.name,onClick:()=>void o.submitForm(),children:"Create"})]})]})};export{_t as default};
Copyright ©2k19 -
Hexid
|
Tex7ure