/
snap
/
lxd
/
current
/
share
/
lxd-ui
/
assets
/
File Upload :
llllll
Current File: //snap/lxd/current/share/lxd-ui/assets/ProfileDetail-BgNz91mO.js
import{bk as J,u as Z,ah as T,d as t,t as ee,G as se,p as S,l as V,c as F,r as y,j as e,f as Y,g as z,i as _,a6 as te,V as l,P as ie,Q as ne,T as B,R as q,q as A,bl as oe,v as G,L as H,y as ae,n as $,bm as re,Y as ce,bn as le,a1 as de,e as me}from"./index-B3cgCbnJ.js";import{y as ue,c as he,o as fe}from"./YamlSwitch-Bng19N-X.js";import{s as je,c as xe,b as pe,m as ge,d as ye,e as Ce,f as Pe,g as be,o as R,R as Ne,a as Re,I as ve,M as Ie,B as Se,C as Fe,Y as De,k as Ee}from"./FormMenuItem-BwEOqt61.js";import{p as we,Y as v,P as Ue,M as I,a as Le,D as Oe,N as Te,G as $e,b as ke,O as Me,R as Ve,S as Ye,c as ze,d as _e,B as Be,C as K}from"./ProfileDetailsForm-CsY5yJ4o.js";import{D as qe,N as Ae,G as Ge,P as He,O as Ke}from"./ProxyDeviceForm-DVEGshLd.js";import{g as k,F as Qe}from"./FormFooterLayout-ChlQYZN0.js";import{Y as We}from"./YamlNotification-C209eie-.js";import{F as Xe}from"./FormSubmitBtn-CI9Q_IyH.js";import{P as Je}from"./ProfileInstances-chD2vSK1.js";import{I as Ze}from"./ItemName-B_MTAAB6.js";import{N as es,D as ss}from"./NetworkListTable-Rl5yNR8Z.js";import{R as ts}from"./RenameHeader-7HM7rJrm.js";import{T as is}from"./TabLinks-BN40EEc5.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 M=(s,i)=>{const a=J(),r=new Set(["name","description","devices","config"]);return{...we(i),devices:be(i.devices),config:{...Pe(i),...Ce(i),...ye(i),...ge(i),...pe(i),...xe(i),...je(i),...k(s.config,a)},...k(s,r)}},D=()=>{const{isFineGrained:s}=Z();return{canDeleteProfile:r=>T(s,"can_delete",r==null?void 0:r.access_entitlements),canEditProfile:r=>T(s,"can_edit",r==null?void 0:r.access_entitlements)}},ns=({profile:s})=>{var O;const i=t.useNotify(),a=ee(),{hasStorageAndProfileOperations:r}=se(),m=t.useToastNotification(),{project:c,section:n}=S(),f=V(),j=F(),[u,g]=y.useState(0),{canEditProfile:h}=D();if(!c)return e.jsx(e.Fragment,{children:"Missing project"});const x=()=>{B("form-contents","p-bottom-controls")};y.useEffect(x,[(O=i.notification)==null?void 0:O.message,n]),t.useListener(window,x,"resize",!0);const C=Y().shape({name:z().required("Name is required")}),Q=h(s)?void 0:"You do not have permission to edit this profile",E=d=>{m.success(e.jsxs(e.Fragment,{children:["Profile"," ",e.jsx(q,{type:"profile",value:s.name,to:`/ui/project/${encodeURIComponent(c)}/profile/${encodeURIComponent(s.name)}`})," ","updated."]})),o.setValues(R(d))},w=d=>{i.failure("Profile update failed",d)},U=()=>{o.setSubmitting(!1),f.invalidateQueries({queryKey:[A.profiles]})},o=_({initialValues:R(s,Q),validationSchema:C,enableReinitialize:!0,onSubmit:d=>{const p=d.yaml?ue(d.yaml):M(s,d);p.etag=s.etag,te(p,c).then(b=>{r?a.set(b.metadata.id,()=>{E(p)},N=>{w(new Error(N))},U):(E(p),U())}).catch(w)}}),P=`/ui/project/${encodeURIComponent(c)}/profile/${encodeURIComponent(s.name)}/configuration`,L=d=>{j(d===I?P:`${P}/${l(d)}`)},W=()=>{const d=new Set(["used_by","etag"]),p=M(s,o.values),b=Object.fromEntries(Object.entries(p).filter(N=>!d.has(N[0])));return fe(b)},X=o.values.readOnly;return e.jsxs("div",{className:"edit-profile",children:[e.jsxs(t.Form,{onSubmit:o.handleSubmit,className:"form",children:[n!==l(v)&&e.jsx(Ue,{active:n??l(I),setActive:L,isDisabled:!1,formik:o}),e.jsx(t.Row,{className:"form-contents",children:e.jsxs(t.Col,{size:12,children:[(n===l(I)||!n)&&e.jsx(Le,{formik:o,isEdit:!0}),n===l(Oe)&&e.jsx(qe,{formik:o,project:c}),n===l(Te)&&e.jsx(Ae,{formik:o,project:c}),n===l($e)&&e.jsx(Ge,{formik:o,project:c}),n===l(ke)&&e.jsx(He,{formik:o,project:c}),n===l(Me)&&e.jsx(Ke,{formik:o,project:c}),n===l(Ve)&&e.jsx(Ne,{formik:o}),n===l(Ye)&&e.jsx(Re,{formik:o}),n===l(ze)&&e.jsx(ve,{formik:o}),n===l(_e)&&e.jsx(Ie,{formik:o}),n===l(Be)&&e.jsx(Se,{formik:o}),n===l(K)&&e.jsx(Fe,{formik:o},`yaml-form-${u}`),n===l(v)&&e.jsx(De,{yaml:W(),setYaml:d=>{Ee(o),o.setFieldValue("yaml",d)},readOnly:!!o.values.editRestriction,readOnlyMessage:o.values.editRestriction,children:e.jsx(We,{entity:"profile",docPath:"/profiles"})},`yaml-form-${u}`)]})},n)]}),e.jsxs(Qe,{children:[e.jsx(he,{formik:o,section:n,setSection:L}),X?null:e.jsxs(e.Fragment,{children:[e.jsx(t.Button,{appearance:"base",onClick:()=>{g(d=>d+1),o.setValues(R(s))},children:"Cancel"}),e.jsx(Xe,{formik:o,baseUrl:P,isYaml:n===l(v),disabled:ie(o)||ne(o)})]})]})]})},os=({profile:s})=>{const i=t.useNotify(),{project:a}=S();if(!a)return e.jsx(e.Fragment,{children:"Missing project"});const r=(j,u)=>{i.failure(j,u)},m=()=>{B("profile-overview-tab")};y.useEffect(m,[]),t.useListener(window,m,"resize",!0);const c=s.config["cloud-init.user-data"]||s.config["cloud-init.vendor-data"]||s.config["cloud-init.network-config"],f=oe(a,a==="default",s.used_by).length;return e.jsxs("div",{className:"profile-overview-tab",children:[e.jsxs(t.Row,{className:"section",children:[e.jsx(t.Col,{size:3,children:e.jsx("h2",{className:"p-heading--5",children:"General"})}),e.jsx(t.Col,{size:7,children:e.jsx("table",{children:e.jsxs("tbody",{children:[e.jsxs("tr",{children:[e.jsx("th",{className:"u-text--muted",children:"Name"}),e.jsx("td",{children:e.jsx(Ze,{item:s})})]}),e.jsxs("tr",{children:[e.jsx("th",{className:"u-text--muted",children:"Description"}),e.jsx("td",{children:s.description?s.description:"-"})]})]})})})]}),e.jsxs(t.Row,{className:"networks",children:[e.jsx(t.Col,{size:3,children:e.jsx("h2",{className:"p-heading--5",children:"Networks"})}),e.jsx(t.Col,{size:7,children:e.jsx(es,{devices:s.devices,onFailure:r})})]}),e.jsxs(t.Row,{className:"devices",children:[e.jsx(t.Col,{size:3,children:e.jsx("h2",{className:"p-heading--5",children:"Devices"})}),e.jsx(t.Col,{size:7,children:e.jsx(ss,{configBaseURL:`/ui/project/${encodeURIComponent(a)}/profile/${encodeURIComponent(s.name)}/configuration`,devices:s.devices})})]}),e.jsxs(t.Row,{className:"section",children:[e.jsx(t.Col,{size:3,children:e.jsx("h2",{className:"p-heading--5",children:"Limits"})}),e.jsx(t.Col,{size:7,children:e.jsx("table",{children:e.jsxs("tbody",{children:[e.jsxs("tr",{children:[e.jsx("th",{className:"u-text--muted",children:"CPU"}),e.jsx("td",{children:s.config["limits.cpu"]||"-"})]}),e.jsxs("tr",{children:[e.jsx("th",{className:"u-text--muted",children:"Memory"}),e.jsx("td",{children:s.config["limits.memory"]||"-"})]})]})})})]}),e.jsxs(t.Row,{className:G("section",{"u-hide":!c}),children:[e.jsx(t.Col,{size:3,children:e.jsx("h2",{className:"p-heading--5",children:"Cloud init"})}),e.jsx(t.Col,{size:7,className:"view-config",children:e.jsx(H,{to:`/ui/project/${encodeURIComponent(a)}/profile/${encodeURIComponent(s.name)}/configuration/${l(K)}`,children:"View configuration"})})]}),e.jsxs(t.Row,{className:"usage list-wrapper",children:[e.jsx(t.Col,{size:3,children:e.jsxs("h2",{className:"p-heading--5",children:["Usage (",f,")"]})}),e.jsx(t.Col,{size:7,children:f>0?e.jsx("table",{children:e.jsx("tbody",{children:e.jsx(Je,{profile:s,project:a,headingClassName:"u-text--muted"})})}):e.jsx(e.Fragment,{children:"-"})})]})]})},as=({profile:s,project:i})=>{const a=ae(),r=t.useNotify(),m=t.useToastNotification(),c=V(),[n,f]=y.useState(!1),j=F(),{canDeleteProfile:u}=D(),g=()=>{f(!0),re(s.name,i).then(()=>{c.invalidateQueries({queryKey:[A.projects,i]}),j(`/ui/project/${encodeURIComponent(i)}/profiles`),m.success(e.jsxs(e.Fragment,{children:["Profile ",e.jsx($,{bold:!0,type:"profile",value:s.name})," ","deleted."]}))}).catch(C=>{f(!1),r.failure("Profile deletion failed",C)})},h=s.name==="default",x=()=>u(s)?h?"The default profile cannot be deleted":"Delete profile":"You do not have permission to delete this profile";return e.jsxs(t.ConfirmationButton,{onHoverText:x(),className:G("u-no-margin--bottom",{"has-icon":!a}),disabled:!u(s)||h||n,loading:n,confirmationModalProps:{title:"Confirm delete",confirmButtonLabel:"Delete",onConfirm:g,children:e.jsxs("p",{children:["This will permanently delete profile"," ",e.jsx($,{type:"profile",value:s.name,bold:!0}),".",e.jsx("br",{}),"This action cannot be undone, and can result in data loss."]})},shiftClickEnabled:!0,showShiftClickHint:!0,children:[!a&&e.jsx(t.Icon,{name:"delete"}),e.jsx("span",{children:"Delete"})]})},rs=({name:s,profile:i,project:a})=>{const r=F(),m=t.useNotify(),c=t.useToastNotification(),n=y.useState(null),{canEditProfile:f}=D(),j=Y().shape({name:z().test("deduplicate","A profile with this name already exists",async h=>(i==null?void 0:i.name)===h||ce(h,a,n,"profiles")).required("Profile name is required")}),u=_({initialValues:{name:s,isRenaming:!1},validationSchema:j,onSubmit:h=>{if(s===h.name){u.setFieldValue("isRenaming",!1),u.setSubmitting(!1);return}le(s,h.name,a).then(()=>{r(`/ui/project/${encodeURIComponent(a)}/profile/${encodeURIComponent(h.name)}`),c.success(e.jsxs(e.Fragment,{children:["Profile ",e.jsx("strong",{children:s})," renamed to"," ",e.jsx(q,{type:"profile",value:h.name,to:`/ui/project/${encodeURIComponent(a)}/profile/${encodeURIComponent(h.name)}`}),"."]})),u.setFieldValue("isRenaming",!1)}).catch(x=>{m.failure("Renaming failed",x)}).finally(()=>{u.setSubmitting(!1)})}}),g=()=>{if(!f(i))return"You do not have permission to rename this profile";if(i&&i.name==="default")return"Cannot rename the default profile"};return e.jsx(ts,{name:s,parentItems:[e.jsx(H,{to:`/ui/project/${encodeURIComponent(a)}/profiles`,children:"Profiles"},1)],renameDisabledReason:g(),controls:i&&e.jsx(as,{profile:i,project:a},"delete"),isLoaded:!!i,formik:u})},cs=["Overview","Configuration"],qs=()=>{const s=t.useNotify(),{name:i,project:a,activeTab:r}=S();if(!i)return e.jsx(e.Fragment,{children:"Missing name"});if(!a)return e.jsx(e.Fragment,{children:"Missing project"});const{data:m,error:c,isLoading:n}=de(i,a);return c&&s.failure("Loading profile failed",c),e.jsxs(t.CustomLayout,{header:e.jsx(rs,{name:i,profile:m,project:a}),contentClassName:"detail-page",children:[e.jsx(me,{}),n&&e.jsx(t.Spinner,{className:"u-loader",text:"Loading profile details..."}),!n&&!m&&e.jsx(e.Fragment,{children:"Loading profile failed"}),!n&&m&&e.jsxs(t.Row,{children:[e.jsx(is,{tabs:cs,activeTab:r,tabUrl:`/ui/project/${encodeURIComponent(a)}/profile/${encodeURIComponent(i)}`}),!r&&e.jsx("div",{role:"tabpanel","aria-labelledby":"overview",children:e.jsx(os,{profile:m})}),r==="configuration"&&e.jsx("div",{role:"tabpanel","aria-labelledby":"configuration",children:e.jsx(ns,{profile:m})})]})]})};export{qs as default};
Copyright ©2k19 -
Hexid
|
Tex7ure