/
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/UploadCustomIso-CDeVprqC.js
import{j as e,d as t,s as P,l as U,F as q,r as o,t as z,K as C,q as b}from"./index-dL2n30-Z.js";import{P as L}from"./ProgressBar-BDA2xlPC.js";import{S as Q}from"./StoragePoolSelector-BbIrdWMX.js";import{a as V}from"./storage-volumes-DY5ibnP4.js";const B=()=>e.jsx(e.Fragment,{children:e.jsx("div",{className:"p-notification--information",children:e.jsxs("div",{className:"p-notification__content",children:[e.jsx("h3",{className:"p-notification__title",children:"Some image formats need to be modified in order to work with LXD."}),e.jsx("p",{children:e.jsxs("a",{className:"p-notification__action",href:"https://ubuntu.com/tutorials/how-to-install-a-windows-11-vm-using-lxd#1-overview",target:"_blank",rel:"noopener noreferrer",children:["Windows ISO images",e.jsx(t.Icon,{className:"external-link-icon",name:"external-link"})]})})]})})}),K=n=>n.replace(/[^A-Za-z0-9.-]/g,"-"),N=n=>/^[A-Za-z0-9.-]+$/.test(n)||!n,R=({onCancel:n,onFinish:I})=>{const w=P(),y=U(),{project:u}=q(),[i,k]=o.useState(null),[l,x]=o.useState(""),[j,m]=o.useState(!1),[c,_]=o.useState(""),[a,p]=o.useState(null),[f,F]=o.useState(null),[h,d]=o.useState(null),S=(u==null?void 0:u.name)??"",A=()=>{f==null||f.abort(),n()},E=()=>{if(!i)return;d(null),m(!0);const s=new AbortController;F(s),V(c,i,l,S,p,s).then(r=>{w.set(r.metadata.id,()=>{I(l,c)},g=>{d(t.failure("Custom ISO upload failed",new Error(g)))},()=>{m(!1),p(null),y.invalidateQueries({queryKey:[b.storage,c,b.volumes,S]})})}).catch(r=>{var v;const g=new Error((v=r.response)==null?void 0:v.data.error);d(t.failure("Custom ISO upload failed",g)),m(!1),p(null)})},O=s=>{if(s.target.files){const r=s.target.files[0];k(r),x(K(r.name))}};return e.jsxs(e.Fragment,{children:[h?e.jsx(t.Notification,{title:h.title,severity:"negative",onDismiss:()=>{d(null)},children:h.message}):e.jsx(B,{}),e.jsxs("div",{className:z("custom-iso-form",{"u-hide":!!a}),children:[e.jsx(t.Input,{name:"iso",type:"file",id:"iso-image",label:"Local file",onChange:O,stacked:!0}),e.jsx(t.Input,{name:"name",type:"text",id:"name",label:"Alias",value:l,onChange:s=>{x(s.target.value)},disabled:i===null,error:l&&!N(l)?e.jsx("div",{className:"alias-error",children:"Only alphanumeric characters, periods or hyphens are allowed in this field"}):void 0,stacked:!0}),e.jsx(Q,{value:c,setValue:_,selectProps:{id:"storagePool",label:"Storage pool",disabled:i===null,stacked:!0}})]}),a&&e.jsxs(e.Fragment,{children:[e.jsx(L,{percentage:Math.floor(a.percentage)}),e.jsxs("p",{children:[C(a.loaded)," loaded of"," ",C(a.total??0)]}),a.loaded===a.total&&e.jsx(t.Spinner,{className:"u-loader",text:"Validating ISO"})]}),e.jsxs("footer",{className:"p-modal__footer",children:[e.jsx(t.Button,{appearance:"base",onClick:A,className:"u-no-margin--bottom",children:"Cancel"}),e.jsx(t.ActionButton,{appearance:"positive",loading:j,disabled:!i||!N(l)||j,className:"u-no-margin--bottom",onClick:E,children:"Upload"})]})]})};export{R as U};
Copyright ©2k19 -
Hexid
|
Tex7ure