/
snap
/
lxd
/
current
/
share
/
lxd-ui
/
assets
/
File Upload :
llllll
Current File: //snap/lxd/current/share/lxd-ui/assets/CreateProfile-B3juqrtu.js
import{c as N,d as t,p as E,l as g,r,j as e,f as R,g as D,Y as O,i as b,a0 as v,R as T,q as y,e as Y,P as _,Q as k,T as U}from"./index-B3cgCbnJ.js";import{y as L,c as M,o as A}from"./YamlSwitch-Bng19N-X.js";import{s as B,c as V,b as w,m as G,d as q,e as K,f as $,g as H,R as Q,a as z,I as J,M as W,B as X,C as Z,Y as ee}from"./FormMenuItem-BwEOqt61.js";import{M as j,p as oe,Y as n,P as se,a as ae,D as ie,N as te,G as re,b as ne,O as me,R as ce,S as le,c as pe,d as de,B as fe,C as ue}from"./ProfileDetailsForm-CsY5yJ4o.js";import{D as ye,N as je,G as xe,P as he,O as Pe}from"./ProxyDeviceForm-DVEGshLd.js";import{B as Se}from"./BaseLayout-DIbLs-hH.js";import{F as Ce}from"./FormFooterLayout-ChlQYZN0.js";import{Y as Fe}from"./YamlNotification-C209eie-.js";import"./limits-CLEFMbq-.js";import"./AutoExpandingTextArea-BmFqLvbw.js";import"./scroll-BEbDVMxI.js";import"./instanceOptions-D4bz_1Ev.js";import"./ConfigFieldDescription-C9KDhW5s.js";import"./snapshots-Bt9cFkFc.js";import"./StoragePoolSelector-_Ij9bIB_.js";import"./StoragePoolSize-34u3KM6q.js";import"./Meter-v0AAwaqr.js";import"./DiskSizeSelector-CIkNkBL4.js";import"./StorageVolumeForm-0OnQ0JYw.js";import"./projects-9DerJg4m.js";import"./useVolumes-BGHjBnNk.js";import"./images-CA6qXE8n.js";import"./storage-volumes-BlpH9Ab1.js";import"./FormLink-B3Ky5UhN.js";import"./useNetworks-DC9cTd9P.js";import"./networks-DBYE4DQa.js";import"./ExpandableList-DwC4iUKg.js";import"./NetworkSelector-DygdY6TH.js";import"./useNetworkAcls-n0o7vmIP.js";import"./network-acls-BrbgJ988.js";const Ze=()=>{var u;const m=N(),c=t.useNotify(),x=t.useToastNotification(),{project:i}=E(),l=g(),h=r.useState(null),[a,P]=r.useState(j);if(!i)return e.jsx(e.Fragment,{children:"Missing project"});const S=R().shape({name:D().test("deduplicate","A profile with this name already exists",async s=>O(s,i,h,"profiles")).required()}),p=()=>{U("form-contents","p-bottom-controls")};r.useEffect(p,[(u=c.notification)==null?void 0:u.message,a]),t.useListener(window,p,"resize",!0);const o=b({initialValues:{name:"",devices:[],cloud_init_ssh_keys:[],readOnly:!1,entityType:"profile"},validationSchema:S,onSubmit:s=>{const F=s.yaml?L(s.yaml):d(s);v(JSON.stringify(F),i).then(()=>{m(`/ui/project/${encodeURIComponent(i)}/profiles`),x.success(e.jsxs(e.Fragment,{children:["Profile"," ",e.jsx(T,{type:"profile",value:s.name,to:`/ui/project/${encodeURIComponent(i)}/profile/${encodeURIComponent(s.name)}`})," ","created."]}))}).catch(I=>{o.setSubmitting(!1),c.failure("Profile creation failed",I)}).finally(()=>{l.invalidateQueries({queryKey:[y.profiles]}),l.invalidateQueries({queryKey:[y.projects,i]})})}}),d=s=>({...oe(s),devices:H(s.devices),config:{...$(s),...K(s),...q(s),...G(s),...w(s),...V(s),...B(s)}}),f=s=>{o.values.yaml&&s!==n&&o.setFieldValue("yaml",void 0),P(s)};function C(){const s=d(o.values);return A(s)}return e.jsxs(Se,{title:"Create a profile",contentClassName:"create-profile",children:[e.jsxs(t.Form,{onSubmit:o.handleSubmit,className:"form",children:[a!==n&&e.jsx(se,{active:a,setActive:f,isDisabled:!o.values.name,formik:o}),e.jsx(t.Row,{className:"form-contents",children:e.jsxs(t.Col,{size:12,children:[e.jsx(Y,{}),a===j&&e.jsx(ae,{formik:o,isEdit:!1}),a===ie&&e.jsx(ye,{formik:o,project:i}),a===te&&e.jsx(je,{formik:o,project:i}),a===re&&e.jsx(xe,{formik:o,project:i}),a===ne&&e.jsx(he,{formik:o,project:i}),a===me&&e.jsx(Pe,{formik:o,project:i}),a===ce&&e.jsx(Q,{formik:o}),a===le&&e.jsx(z,{formik:o}),a===pe&&e.jsx(J,{formik:o}),a===de&&e.jsx(W,{formik:o}),a===fe&&e.jsx(X,{formik:o}),a===ue&&e.jsx(Z,{formik:o}),a===n&&e.jsx(ee,{yaml:C(),setYaml:s=>void o.setFieldValue("yaml",s),children:e.jsx(Fe,{entity:"profile",docPath:"/profiles"})})]})},a)]}),e.jsxs(Ce,{children:[e.jsx("div",{className:"yaml-switch",children:e.jsx(M,{formik:o,section:a,setSection:f,disableReason:o.values.name?void 0:"Please enter a profile name before adding custom configuration"})}),e.jsx(t.Button,{appearance:"base",onClick:async()=>m(`/ui/project/${encodeURIComponent(i)}/profiles`),children:"Cancel"}),e.jsx(t.ActionButton,{appearance:"positive",loading:o.isSubmitting,disabled:!o.isValid||o.isSubmitting||!o.values.name||_(o)||k(o),onClick:()=>void o.submitForm(),children:"Create"})]})]})};export{Ze as default};
Copyright ©2k19 -
Hexid
|
Tex7ure