/
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/CreateProfile-CRFqd9ks.js
import{n as E,c as g,d as t,o as D,l as R,r,j as e,f as O,g as b,Y as v,i as T,$ as Y,R as _,q as y,e as k,P as L,Q as U,T as B}from"./index-dL2n30-Z.js";import{y as M,c as A,o as V}from"./YamlSwitch-BRMLXARm.js";import{s as w,c as $,b as G,m as q,d as K,e as H,f as Q,g as z,R as J,a as W,I as X,M as Z,B as ee,C as oe,Y as se}from"./FormMenuItem-DRePjRCl.js";import{M as j,p as ae,Y as n,P as ie,a as te,D as re,N as ne,G as ce,b as me,O as le,R as pe,S as de,c as fe,d as ue,B as ye,C as je}from"./ProfileDetailsForm-yMOvd-7e.js";import{D as xe,N as he,G as Se,P as Pe,O as Ce}from"./ProxyDeviceForm-sOuk1c-t.js";import{B as Fe}from"./BaseLayout-DoX0qSEj.js";import{F as Ie}from"./FormFooterLayout-Bmq4RXkd.js";import{Y as Ne}from"./YamlNotification-BqA1Vb41.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"./DiskSizeSelector-DZsA03GF.js";import"./useVolumes-DkjZCOr_.js";import"./images-BNK9xDRN.js";import"./storage-volumes-DY5ibnP4.js";import"./StorageVolumeForm-BktJTI1i.js";import"./FormLink-jsAVvDgu.js";import"./useNetworks-FA5tQKQK.js";import"./networks-DWdMsnuF.js";import"./NetworkSelector-C6jsH-fc.js";import"./ScrollableContainer-ceiHesUW.js";const Ze=()=>{var u;const x=E(),c=g(),m=t.useNotify(),h=t.useToastNotification(),{project:i}=D(),l=R(),S=r.useState(null),[a,P]=r.useState(j);if(!i)return e.jsx(e.Fragment,{children:"Missing project"});const C=O().shape({name:b().test("deduplicate","A profile with this name already exists",async s=>v(s,i,S,"profiles")).required()}),p=()=>{B("form-contents","p-bottom-controls")};r.useEffect(p,[(u=m.notification)==null?void 0:u.message,a]),t.useListener(window,p,"resize",!0);const o=T({initialValues:{name:"",devices:[],cloud_init_ssh_keys:[],readOnly:!1,entityType:"profile"},validationSchema:C,onSubmit:s=>{const I=s.yaml?M(s.yaml):d(s);Y(JSON.stringify(I),i).then(()=>{c(`/ui/project/${encodeURIComponent(i)}/profiles`),h.success(e.jsxs(e.Fragment,{children:["Profile"," ",e.jsx(_,{type:"profile",value:s.name,to:`/ui/project/${encodeURIComponent(i)}/profile/${encodeURIComponent(s.name)}`})," ","created."]}))}).catch(N=>{o.setSubmitting(!1),m.failure("Profile creation failed",N)}).finally(()=>{l.invalidateQueries({queryKey:[y.profiles]}),l.invalidateQueries({queryKey:[y.projects,i]})})}}),d=s=>({...ae(s),devices:z(s.devices),config:{...Q(s),...H(s),...K(s),...q(s),...G(s),...$(s),...w(s)}}),f=s=>{o.values.yaml&&s!==n&&o.setFieldValue("yaml",void 0),P(s)};function F(){const s=d(o.values);return V(s)}return e.jsxs(Fe,{title:"Create a profile",contentClassName:"create-profile",children:[e.jsxs(t.Form,{onSubmit:o.handleSubmit,className:"form",children:[a!==n&&e.jsx(ie,{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(k,{}),a===j&&e.jsx(te,{formik:o,isEdit:!1}),a===re&&e.jsx(xe,{formik:o,project:i}),a===ne&&e.jsx(he,{formik:o,project:i}),a===ce&&e.jsx(Se,{formik:o,project:i}),a===me&&e.jsx(Pe,{formik:o,project:i}),a===le&&e.jsx(Ce,{formik:o,project:i}),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===ye&&e.jsx(ee,{formik:o}),a===je&&e.jsx(oe,{formik:o}),a===n&&e.jsx(se,{yaml:F(),setYaml:s=>void o.setFieldValue("yaml",s),children:e.jsx(Ne,{entity:"profile",href:`${x}/profiles`})})]})},a)]}),e.jsxs(Ie,{children:[e.jsx("div",{className:"yaml-switch",children:e.jsx(A,{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()=>c(`/ui/project/${encodeURIComponent(i)}/profiles`),children:"Cancel"}),e.jsx(t.ActionButton,{appearance:"positive",loading:o.isSubmitting,disabled:!o.isValid||o.isSubmitting||!o.values.name||L(o)||U(o),onClick:()=>void o.submitForm(),children:"Create"})]})]})};export{Ze as default};
Copyright ©2k19 -
Hexid
|
Tex7ure