%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/lxd/current/share/lxd-ui/assets/
Upload File :
Create Path :
Current File : //snap/lxd/current/share/lxd-ui/assets/instanceEdit-cf20bafe.js

import{f as M,b as P,s as q,c as F,d as S,p as w}from"./NetworkDevicesForm-bcf4be77.js";import{p as K,a as V}from"./DiskSizeSelector-dd5e138a.js";import{b as B,a as v}from"./formFields-fc140429.js";import{j as s,d as i,x as N,w as z,i as D,f as L,q as u,p as Q,L as T,b5 as O,I as R,n as $}from"./index-13b2882d.js";import{P as A}from"./ProfileSelector-b579b8c7.js";import{c as x,a as y,u as H}from"./index.esm-82c30f37.js";import{i as U}from"./settings-c23f9009.js";import{A as G}from"./AutoExpandingTextArea-3a779a81.js";const J=({close:e,migrate:a,instance:r,location:c,members:d})=>{const n=d.map(t=>t.server_name),p=x().shape({target:y().min(1,"This field is required")}),o=H({initialValues:{target:n.find(t=>t!==c)??""},validationSchema:p,onSubmit:t=>{a(t.target)}}),g=t=>{t.key==="Escape"&&e()};return s.jsx(i.Modal,{close:e,className:"migrate-instance-modal",title:`Migrate instance ${r}`,buttonRow:s.jsxs(s.Fragment,{children:[s.jsx(i.Button,{className:"u-no-margin--bottom",type:"button","aria-label":"cancel migrate",appearance:"base",onClick:e,children:"Cancel"}),s.jsx(i.Button,{className:"u-no-margin--bottom",appearance:"positive",onClick:o.submitForm,disabled:!o.isValid,children:"Migrate"})]}),onKeyDown:g,children:s.jsx(i.Form,{onSubmit:o.handleSubmit,children:s.jsx(i.Select,{id:"locationMember",label:"Move instance to cluster member",onChange:t=>void o.setFieldValue("target",t.target.value),value:o.values.target,options:n.map(t=>({label:t,value:t,disabled:t===c}))})})})},W=({instance:e,location:a,project:r,onFinish:c})=>{const d=N(),n=i.useNotify(),{openPortal:p,closePortal:o,isOpen:g,Portal:t}=z(),h=D(),{data:b=[],isLoading:j}=L({queryKey:[u.cluster,u.members],queryFn:Q});if(j)return s.jsx(T,{});const C=l=>{n.success(s.jsxs(s.Fragment,{children:["Migration finished for instance"," ",s.jsx(R,{item:{name:e},bold:!0})]})),c(l),h.invalidateQueries({queryKey:[u.instances,e]})},f=l=>{n.failure(`Migration failed on instance ${e}`,l)},I=l=>{f(new Error(l)),h.invalidateQueries({queryKey:[u.instances,e]})},E=l=>{O(e,r,l).then(m=>{d.set(m.metadata.id,()=>C(l),I),n.info("Migration started"),o()}).catch(m=>{f(m),o()})};return s.jsxs(s.Fragment,{children:[g&&s.jsx(t,{children:s.jsx(J,{close:o,migrate:E,instance:e,location:a,members:b})}),s.jsx(i.Button,{className:"instance-migrate",onClick:p,type:"button",children:"Migrate"})]})},X=e=>({name:e.name,description:e.description,type:e.instanceType,profiles:e.profiles}),ne=({formik:e,project:a})=>{const r=e.values.readOnly,{data:c}=$(),d=U(c);return s.jsxs("div",{className:"details",children:[s.jsx(i.Row,{children:s.jsxs(i.Col,{size:8,children:[s.jsx(i.Input,{id:"name",name:"name",type:"text",label:"Instance name",help:"Click the name in the header to rename the instance",placeholder:"Enter name",onBlur:e.handleBlur,onChange:e.handleChange,value:e.values.name,error:e.touched.name?e.errors.name:null,required:!0,disabled:!0}),s.jsx(G,{id:"description",name:"description",label:"Description",placeholder:"Enter description",onBlur:e.handleBlur,onChange:e.handleChange,value:e.values.description,dynamicHeight:!0,disabled:r})]})}),d&&s.jsxs(i.Row,{children:[s.jsx(i.Col,{size:8,children:s.jsx(i.Input,{id:"target",name:"target",type:"text",label:"Instance location",value:e.values.location,required:!0,disabled:!0})}),!r&&s.jsx(i.Col,{size:4,children:s.jsx(W,{instance:e.values.name,location:e.values.location,project:a,onFinish:n=>void e.setFieldValue("location",n)})})]}),s.jsx(A,{project:a,selected:e.values.profiles,setSelected:n=>void e.setFieldValue("profiles",n),isReadOnly:r})]})},_=e=>({name:e.name,description:e.description,devices:w(e.devices),limits_cpu:K(e.config["limits.cpu"]),limits_memory:V(e.config["limits.memory"]),limits_memory_swap:e.config["limits.memory.swap"],limits_disk_priority:e.config["limits.disk.priority"]?parseInt(e.config["limits.disk.priority"]):void 0,limits_processes:e.config["limits.processes"]?parseInt(e.config["limits.processes"]):void 0,security_protection_delete:e.config["security.protection.delete"],security_privileged:e.config["security.privileged"],security_protection_shift:e.config["security.protection.shift"],security_idmap_base:e.config["security.idmap.base"],security_idmap_size:e.config["security.idmap.size"]?parseInt(e.config["security.idmap.size"]):void 0,security_idmap_isolated:e.config["security.idmap.isolated"],security_devlxd:e.config["security.devlxd"],security_devlxd_images:e.config["security.devlxd.images"],security_secureboot:e.config["security.secureboot"],snapshots_pattern:e.config["snapshots.pattern"],snapshots_expiry:e.config["snapshots.expiry"],snapshots_schedule:e.config["snapshots.schedule"],snapshots_schedule_stopped:e.config["snapshots.schedule.stopped"],cloud_init_network_config:e.config["cloud-init.network-config"],cloud_init_user_data:e.config["cloud-init.user-data"],cloud_init_vendor_data:e.config["cloud-init.vendor-data"]}),re=e=>({instanceType:e.type,profiles:e.profiles,location:e.location,readOnly:!0,type:"instance",..._(e)}),oe=e=>({readOnly:!0,type:"profile",..._(e)}),ce=(e,a)=>{const r=B(),c=new Set(["name","description","type","profiles","devices","config"]);return{...X(a),devices:M(a.devices),config:{...P(a),...q(a),...F(a),...S(a),...v(e.config,r)},...v(e,c)}},le=x().shape({name:y().required("Instance name is required"),instanceType:y().required("Instance type is required")});export{ne as E,le as I,ce as a,oe as b,re as g};

Zerion Mini Shell 1.0