/
snap
/
lxd
/
current
/
share
/
lxd-ui
/
assets
/
File Upload :
llllll
Current File: //snap/lxd/current/share/lxd-ui/assets/ProfileDetail-CN6GMykp.js
import{bg as Q,u as W,af as U,n as X,d as t,o as S,l as k,c as F,r as C,j as e,f as M,g as V,i as Y,a5 as J,R as z,q as _,L as P,V as l,P as Z,Q as ee,T as B,bh as se,t as q,x as te,m as T,bi as ie,Y as oe,bj as ne,F as ae,a0 as re,bk as ce,e as le}from"./index-dL2n30-Z.js";import{y as de,c as me,o as ue}from"./YamlSwitch-BRMLXARm.js";import{s as fe,c as he,b as je,m as xe,d as pe,e as ge,f as ye,g as Ce,o as I,R as Pe,a as be,I as Ne,M as Re,B as Ie,C as ve,Y as De,k as Se}from"./FormMenuItem-DRePjRCl.js";import{p as Fe,Y as v,P as Ee,M as D,a as we,D as Le,N as Ue,G as Te,b as Oe,O as $e,R as ke,S as Me,c as Ve,d as Ye,B as ze,C as H}from"./ProfileDetailsForm-yMOvd-7e.js";import{D as _e,N as Be,G as qe,P as He,O as Ke}from"./ProxyDeviceForm-sOuk1c-t.js";import{g as O,F as Ae}from"./FormFooterLayout-Bmq4RXkd.js";import{Y as Ge}from"./YamlNotification-BqA1Vb41.js";import{F as Qe}from"./FormSubmitBtn-D3jUuO6-.js";import{P as We}from"./ProfileInstances-BWXkQIYI.js";import{I as Xe}from"./ItemName-BzCTqTL3.js";import{N as Je,D as Ze}from"./NetworkListTable-CiRLc8LA.js";import{R as es}from"./RenameHeader-BZc6vaTG.js";import{T as ss}from"./TabLinks-BqmE_r1L.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 $=(s,i)=>{const r=Q(),n=new Set(["name","description","devices","config"]);return{...Fe(i),devices:Ce(i.devices),config:{...ye(i),...ge(i),...pe(i),...xe(i),...je(i),...he(i),...fe(i),...O(s.config,r)},...O(s,n)}},E=()=>{const{isFineGrained:s}=W();return{canDeleteProfile:n=>U(s,"can_delete",n==null?void 0:n.access_entitlements),canEditProfile:n=>U(s,"can_edit",n==null?void 0:n.access_entitlements)}},ts=({profile:s,featuresProfiles:i})=>{var L;const r=X(),n=t.useNotify(),x=t.useToastNotification(),{project:c,section:o}=S(),j=k(),u=F(),[f,d]=C.useState(0),{canEditProfile:p}=E();if(!c)return e.jsx(e.Fragment,{children:"Missing project"});const m=()=>{B("form-contents","p-bottom-controls")};C.useEffect(m,[(L=n.notification)==null?void 0:L.message,o]),t.useListener(window,m,"resize",!0);const g=M().shape({name:V().required("Name is required")}),b=p(s)?void 0:"You do not have permission to edit this profile",a=Y({initialValues:I(s,b),validationSchema:g,enableReinitialize:!0,onSubmit:h=>{const y=h.yaml?de(h.yaml):$(s,h);y.etag=s.etag,J(y,c).then(()=>{x.success(e.jsxs(e.Fragment,{children:["Profile"," ",e.jsx(z,{type:"profile",value:s.name,to:`/ui/project/${encodeURIComponent(c)}/profile/${encodeURIComponent(s.name)}`})," ","updated."]})),a.setValues(I(y))}).catch(R=>{n.failure("Profile update failed",R)}).finally(()=>{a.setSubmitting(!1),j.invalidateQueries({queryKey:[_.profiles]})})}}),N=`/ui/project/${encodeURIComponent(c)}/profile/${encodeURIComponent(s.name)}/configuration`,w=h=>{u(h===D?N:`${N}/${l(h)}`)},K=()=>{const h=new Set(["used_by","etag"]),y=$(s,a.values),R=Object.fromEntries(Object.entries(y).filter(G=>!h.has(G[0])));return ue(R)},A=a.values.readOnly;return e.jsxs("div",{className:"edit-profile",children:[!i&&e.jsxs(t.Notification,{severity:"caution",title:"Inherited profile",children:["Modifications are only available in the"," ",e.jsx(P,{to:`/ui/project/default/profile/${encodeURIComponent(s.name)}/configuration`,children:"default project"}),"."]}),e.jsxs(t.Form,{onSubmit:a.handleSubmit,className:"form",children:[o!==l(v)&&e.jsx(Ee,{active:o??l(D),setActive:w,isDisabled:!1,formik:a}),e.jsx(t.Row,{className:"form-contents",children:e.jsxs(t.Col,{size:12,children:[(o===l(D)||!o)&&e.jsx(we,{formik:a,isEdit:!0}),o===l(Le)&&e.jsx(_e,{formik:a,project:c}),o===l(Ue)&&e.jsx(Be,{formik:a,project:c}),o===l(Te)&&e.jsx(qe,{formik:a,project:c}),o===l(Oe)&&e.jsx(He,{formik:a,project:c}),o===l($e)&&e.jsx(Ke,{formik:a,project:c}),o===l(ke)&&e.jsx(Pe,{formik:a}),o===l(Me)&&e.jsx(be,{formik:a}),o===l(Ve)&&e.jsx(Ne,{formik:a}),o===l(Ye)&&e.jsx(Re,{formik:a}),o===l(ze)&&e.jsx(Ie,{formik:a}),o===l(H)&&e.jsx(ve,{formik:a},`yaml-form-${f}`),o===l(v)&&e.jsx(De,{yaml:K(),setYaml:h=>{Se(a),a.setFieldValue("yaml",h)},readOnly:!!a.values.editRestriction,readOnlyMessage:a.values.editRestriction,children:e.jsx(Ge,{entity:"profile",href:`${r}/profiles`})},`yaml-form-${f}`)]})},o)]}),e.jsxs(Ae,{children:[e.jsx(me,{formik:a,section:o,setSection:w}),A?null:e.jsxs(e.Fragment,{children:[e.jsx(t.Button,{appearance:"base",onClick:()=>{d(h=>h+1),a.setValues(I(s))},children:"Cancel"}),e.jsx(Qe,{formik:a,baseUrl:N,isYaml:o===l(v),disabled:Z(a)||ee(a)})]})]})]})},is=({profile:s,featuresProfiles:i})=>{const r=t.useNotify(),{project:n}=S();if(!n)return e.jsx(e.Fragment,{children:"Missing project"});const x=(f,d)=>{r.failure(f,d)},c=()=>{B("profile-overview-tab")};C.useEffect(c,[]),t.useListener(window,c,"resize",!0);const o=s.config["cloud-init.user-data"]||s.config["cloud-init.vendor-data"]||s.config["cloud-init.network-config"],u=se(n,n==="default",s.used_by).length;return e.jsxs("div",{className:"profile-overview-tab",children:[!i&&e.jsxs(t.Notification,{severity:"caution",title:"Inherited profile",children:["Modifications are only available in the"," ",e.jsx(P,{to:`/ui/project/default/profile/${encodeURIComponent(s.name)}`,children:"default project"}),"."]}),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(Xe,{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(Je,{devices:s.devices,onFailure:x})})]}),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(Ze,{configBaseURL:`/ui/project/${encodeURIComponent(n)}/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:q("section",{"u-hide":!o}),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(P,{to:`/ui/project/${encodeURIComponent(n)}/profile/${encodeURIComponent(s.name)}/configuration/${l(H)}`,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 (",u,")"]})}),e.jsx(t.Col,{size:7,children:u>0?e.jsx("table",{children:e.jsx("tbody",{children:e.jsx(We,{profile:s,project:n,headingClassName:"u-text--muted"})})}):e.jsx(e.Fragment,{children:"-"})})]})]})},os=({profile:s,project:i,featuresProfiles:r})=>{const n=te(),x=t.useNotify(),c=t.useToastNotification(),o=k(),[j,u]=C.useState(!1),f=F(),{canDeleteProfile:d}=E(),p=()=>{u(!0),ie(s.name,i).then(()=>{o.invalidateQueries({queryKey:[_.projects,i]}),f(`/ui/project/${encodeURIComponent(i)}/profiles`),c.success(e.jsxs(e.Fragment,{children:["Profile ",e.jsx(T,{bold:!0,type:"profile",value:s.name})," ","deleted."]}))}).catch(b=>{u(!1),x.failure("Profile deletion failed",b)})},m=s.name==="default",g=()=>d(s)?r?m?"The default profile cannot be deleted":"Delete profile":"Modifications are only available in the default project":"You do not have permission to delete this profile";return e.jsxs(t.ConfirmationButton,{onHoverText:g(),className:q("u-no-margin--bottom",{"has-icon":!n}),disabled:!d(s)||m||!r||j,loading:j,confirmationModalProps:{title:"Confirm delete",confirmButtonLabel:"Delete",onConfirm:p,children:e.jsxs("p",{children:["This will permanently delete profile"," ",e.jsx(T,{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:[!n&&e.jsx(t.Icon,{name:"delete"}),e.jsx("span",{children:"Delete"})]})},ns=({name:s,profile:i,project:r,featuresProfiles:n})=>{const x=F(),c=t.useNotify(),o=t.useToastNotification(),j=C.useState(null),{canEditProfile:u}=E(),f=M().shape({name:V().test("deduplicate","A profile with this name already exists",async m=>(i==null?void 0:i.name)===m||oe(m,r,j,"profiles")).required("Profile name is required")}),d=Y({initialValues:{name:s,isRenaming:!1},validationSchema:f,onSubmit:m=>{if(s===m.name){d.setFieldValue("isRenaming",!1),d.setSubmitting(!1);return}ne(s,m.name,r).then(()=>{x(`/ui/project/${encodeURIComponent(r)}/profile/${encodeURIComponent(m.name)}`),o.success(e.jsxs(e.Fragment,{children:["Profile ",e.jsx("strong",{children:s})," renamed to"," ",e.jsx(z,{type:"profile",value:m.name,to:`/ui/project/${encodeURIComponent(r)}/profile/${encodeURIComponent(m.name)}`}),"."]})),d.setFieldValue("isRenaming",!1)}).catch(g=>{c.failure("Renaming failed",g)}).finally(()=>{d.setSubmitting(!1)})}}),p=()=>{if(!u(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(es,{name:s,parentItems:[e.jsx(P,{to:`/ui/project/${encodeURIComponent(r)}/profiles`,children:"Profiles"},1)],renameDisabledReason:p(),controls:i&&e.jsx(os,{profile:i,project:r,featuresProfiles:n},"delete"),isLoaded:!!i,formik:d})},as=["Overview","Configuration"],Ys=()=>{const s=t.useNotify(),{name:i,project:r,activeTab:n}=S();if(!i)return e.jsx(e.Fragment,{children:"Missing name"});if(!r)return e.jsx(e.Fragment,{children:"Missing project"});const{project:x,isLoading:c}=ae(),{data:o,error:j,isLoading:u}=re(i,r);j&&s.failure("Loading profile failed",j);const f=u||c,d=ce(x);return e.jsxs(t.CustomLayout,{header:e.jsx(ns,{name:i,profile:o,project:r,featuresProfiles:d}),contentClassName:"detail-page",children:[e.jsx(le,{}),f&&e.jsx(t.Spinner,{className:"u-loader",text:"Loading profile details..."}),!f&&!o&&e.jsx(e.Fragment,{children:"Loading profile failed"}),!f&&o&&e.jsxs(t.Row,{children:[e.jsx(ss,{tabs:as,activeTab:n,tabUrl:`/ui/project/${encodeURIComponent(r)}/profile/${encodeURIComponent(i)}`}),!n&&e.jsx("div",{role:"tabpanel","aria-labelledby":"overview",children:e.jsx(is,{profile:o,featuresProfiles:d})}),n==="configuration"&&e.jsx("div",{role:"tabpanel","aria-labelledby":"configuration",children:e.jsx(ts,{profile:o,featuresProfiles:d})})]})]})};export{Ys as default};
Copyright ©2k19 -
Hexid
|
Tex7ure