Your IP : 216.73.217.13


Current Path : /snap/lxd/current/share/lxd-ui/assets/
Upload File :
Current File : //snap/lxd/current/share/lxd-ui/assets/CreateProfile-DVnPyWIS.js

import{c as E,d as t,C as g,v as O,r as n,j as e,f as v,h as R,a9 as b,k as T,ad as k,R as y,x as j,p as _,a3 as w}from"./index-BsQN_SZU.js";import{y as Y,Y as A,o as L}from"./YamlSwitch-BStSXJFs.js";import{w as M,s as U,m as V,n as B,o as G,p as q,q as K,t as $,x as H,v as z,y as Q,z as J,c as W,e as X,g as Z,i as ee,j as ae,k as oe,l as se}from"./SshKeyForm-BNz7yPwa.js";import{M as x,Y as m,P as ie,D as te,N as re,G as ne,a as me,O as ce,R as le,S as pe,b as de,c as fe,B as ue,C as ye}from"./ProfileFormMenu-7-YVA4bO.js";import{D as je,N as xe,G as Pe,P as he,O as Se,h as Ne,a as Ce,c as Fe}from"./NetworkDevicePanel-Dyz6smUO.js";import{B as De}from"./BaseLayout-D3ZT4TU8.js";import{F as Ie}from"./FormFooterLayout-CcbL_-PB.js";import{Y as Ee}from"./NetworkDefaultACLSelector-8KsXe1ya.js";import{u as ge,p as P}from"./usePanelParams-CNAJZsSX.js";import"./limits-yeXZOxhv.js";import"./AutoExpandingTextArea-Bd-45rZK.js";import"./formFields-DzJouV_d.js";import"./scroll-Dc7Cgzms.js";import"./ProjectRichChip-DZzjTfq6.js";import"./ConfigFieldDescription-CjXKAIpa.js";import"./snapshots-LtzKNDw1.js";import"./StoragePoolSelector-Bvqvds5t.js";import"./StoragePoolSize-BNbqTfwA.js";import"./Meter-cq8smrSm.js";import"./DiskSizeSelector-C9kWj54D.js";import"./StorageVolumeForm-C6mvm1BU.js";import"./formChangeCount-Kjdextdt.js";import"./StoragePoolRichChip-Daex_aZU.js";import"./projects-CczQ3aFg.js";import"./useVolumes-Bxw5lKYj.js";import"./images-dZFGKb1g.js";import"./storage-volumes-CG043sqG.js";import"./FormLink-3uUdaYvf.js";import"./UploadCustomIso-C4mIsVip.js";import"./ProgressBar-CZqVHpuJ.js";import"./useNetworks-1j5RF-bH.js";import"./ExpandableList-DsGr0BpD.js";import"./NetworkRichChip-Cp8QBNS_.js";import"./NetworkSelector-DuJmwRYk.js";import"./useNetworkAcls-Bl3lzJua.js";import"./network-acls-bpCzo6oH.js";const la=()=>{const c=E(),l=t.useNotify(),h=t.useToastNotification(),{project:i}=g(),p=O(),S=n.useState(null),[s,N]=n.useState(x),d=ge();if(!i)return e.jsx(e.Fragment,{children:"Missing project"});const C=v().shape({name:R().test("deduplicate","A profile with this name already exists",async o=>b(o,i,S,"profiles")).required()}),f=()=>{w("form-contents","p-bottom-controls")};n.useEffect(f,[l.notification?.message,s]),t.useListener(window,f,"resize",!0);const a=T({initialValues:{name:"",devices:[],cloud_init_ssh_keys:[],readOnly:!1,entityType:"profile"},validationSchema:C,onSubmit:o=>{const D=o.yaml?Y(o.yaml):u(o);k(JSON.stringify(D),i).then(()=>{c(`${y}/ui/project/${encodeURIComponent(i)}/profiles`),h.success(e.jsxs(e.Fragment,{children:["Profile"," ",e.jsx(M,{profileName:o.name,projectName:i})," ","created."]}))}).catch(I=>{a.setSubmitting(!1),l.failure("Profile creation failed",I)}).finally(()=>{p.invalidateQueries({queryKey:[j.profiles]}),p.invalidateQueries({queryKey:[j.projects,i]})})}}),u=o=>({...Q(o),devices:z(o.devices),config:{...H(o),...$(o),...K(o),...q(o),...G(o),...B(o),...V(o),...U(o)}}),r=o=>{a.values.yaml&&o!==m&&a.setFieldValue("yaml",void 0),N(o)};function F(){const o=u(a.values);return L(o)}return e.jsxs(De,{title:"Create a profile",contentClassName:"create-profile",children:[e.jsxs(t.Form,{onSubmit:a.handleSubmit,className:"form",children:[s!==m&&e.jsx(ie,{active:s,setActive:r,isDisabled:!a.values.name,formik:a}),e.jsx(t.Row,{className:"form-contents",children:e.jsxs(t.Col,{size:12,children:[e.jsx(_,{}),s===x&&e.jsx(J,{formik:a,isEdit:!1,project:i}),s===te&&e.jsx(je,{formik:a,project:i}),s===re&&e.jsx(xe,{formik:a,project:i}),s===ne&&e.jsx(Pe,{formik:a,project:i}),s===me&&e.jsx(he,{formik:a,project:i}),s===ce&&e.jsx(Se,{formik:a,project:i}),s===le&&e.jsx(W,{formik:a}),s===pe&&e.jsx(X,{formik:a,setSection:r}),s===de&&e.jsx(Z,{formik:a}),s===fe&&e.jsx(ee,{formik:a}),s===ue&&e.jsx(ae,{formik:a}),s===ye&&e.jsx(oe,{formik:a,project:i}),s===m&&e.jsx(se,{yaml:F(),setYaml:o=>{a.setFieldValue("yaml",o)},children:e.jsx(Ee,{entity:"profile",docPath:"/profiles"})})]})},s)]}),e.jsxs(Ie,{children:[e.jsx("div",{className:"yaml-switch",children:e.jsx(A,{formik:a,section:s,setSection:r,disableReason:a.values.name?void 0:"Please enter a profile name before adding custom configuration"})}),e.jsx(t.Button,{appearance:"base",onClick:async()=>c(`${y}/ui/project/${encodeURIComponent(i)}/profiles`),children:"Cancel"}),e.jsx(t.ActionButton,{appearance:"positive",loading:a.isSubmitting,disabled:!a.isValid||a.isSubmitting||!a.values.name||Ne(a)||Ce(a),onClick:()=>{a.submitForm()},children:"Create"})]}),(d.panel===P.editNetworkDevice||d.panel===P.createNetworkDevice)&&e.jsx(Fe,{project:i,formik:a})]})};export{la as default};