%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/ProfileDetail-1a7135fe.js

import{d as i,m as P,i as I,e as S,r as p,j as e,A as R,aY as U,q as D,c as y,G as u,aZ as _,I as E,a_ as A,a$ as B,aa as k,b0 as H,al as Y,b1 as G,z as Q,b2 as W,ae as Z,f as J,b3 as X,C as ee,b as se,L as ie,ap as te,b4 as ae}from"./index-13b2882d.js";import{c as O,a as $,u as M}from"./index.esm-82c30f37.js";import{S as ne,u as T}from"./updateMaxHeight-325b3cd4.js";import{y as oe,Y as re,h as le,a as ce,d as de}from"./instanceValidation-45cfba9a.js";import{f as me,b as ue,s as he,c as fe,d as je,D as xe,N as ge,R as pe,S as ye,a as be,C as Ne}from"./NetworkDevicesForm-bcf4be77.js";import{P as Ce,M as C,D as ve,N as Pe,R as Se,S as De,a as we,C as z,Y as L}from"./ProfileFormMenu-3458e77a.js";import{p as Le,P as Fe}from"./ProfileDetailsForm-809e7c02.js";import{g as Ie,a as F}from"./formFields-fc140429.js";import{b as v}from"./instanceEdit-cf20bafe.js";import{R as Re}from"./RenameHeader-c74d9adb.js";import"./instanceConfigInheritance-fbf987f8.js";import"./StorageVolumeForm-228515f8.js";import"./StorageVolumeFormMenu-e90b9f5c.js";import"./FormMenuItem-c8a1a121.js";import"./ConfigurationTable-1a9d4d6f.js";import"./ConfigFieldDescription-00c1a193.js";import"./DiskSizeSelector-dd5e138a.js";import"./networks-5caac489.js";import"./AutoExpandingTextArea-3a779a81.js";import"./ProfileSelector-b579b8c7.js";import"./settings-c23f9009.js";const Ee=({profile:s,featuresProfiles:a})=>{var w;const n=i.useNotify(),{project:l,activeSection:o}=P(),h=I(),c=S(),[x,m]=p.useState(!0);if(!l)return e.jsx(e.Fragment,{children:"Missing project"});const d=()=>{T("form-contents","p-bottom-controls")};p.useEffect(d,[(w=n.notification)==null?void 0:w.message,o]),R("resize",d);const f=O().shape({name:$().required("Name is required")}),t=M({initialValues:v(s),validationSchema:f,onSubmit:r=>{const j=r.yaml?oe(r.yaml):b(r);j.etag=s.etag,U(j,l).then(()=>{n.success("Profile updated."),t.setValues(v(j))}).catch(g=>{n.failure("Profile update failed",g)}).finally(()=>{t.setSubmitting(!1),h.invalidateQueries({queryKey:[D.profiles]})})}}),b=r=>{const j=Ie(),g=new Set(["name","description","devices","config"]);return{...Le(r),devices:me(r.devices),config:{...ue(r),...he(r),...fe(r),...je(r),...F(s.config,j)},...F(s,g)}},V=r=>{t.values.yaml&&r!==L&&t.setFieldValue("yaml",void 0);const j=`/ui/project/${l}/profiles/detail/${s.name}/configuration`;c(r===C?j:`${j}/${u(r)}`)},q=()=>{m(r=>!r)},K=()=>{const r=new Set(["used_by","etag"]),j=Object.fromEntries(Object.entries(s).filter(g=>!r.has(g[0])));return de(j)},N=t.values.readOnly;return e.jsxs("div",{className:"edit-profile",children:[!a&&e.jsxs(i.Notification,{severity:"caution",title:"Inherited profile",children:["Modifications are only available in the"," ",e.jsx(y,{to:`/ui/project/default/profiles/detail/${s.name}/configuration`,children:"default project"}),"."]}),e.jsxs(i.Form,{onSubmit:t.handleSubmit,stacked:!0,className:"form",children:[e.jsx(Ce,{active:o??u(C),setActive:V,isConfigOpen:x,toggleConfigOpen:q,hasName:!0,formik:t}),e.jsx(i.Row,{className:"form-contents",children:e.jsxs(i.Col,{size:12,children:[(o===u(C)||!o)&&e.jsx(Fe,{formik:t,isEdit:!0}),o===u(ve)&&e.jsx(xe,{formik:t,project:l}),o===u(Pe)&&e.jsx(ge,{formik:t,project:l}),o===u(Se)&&e.jsx(pe,{formik:t}),o===u(De)&&e.jsx(ye,{formik:t}),o===u(we)&&e.jsx(be,{formik:t}),o===u(z)&&e.jsx(Ne,{formik:t}),o===u(L)&&e.jsx(re,{yaml:K(),setYaml:r=>void t.setFieldValue("yaml",r),isReadOnly:N,children:!N&&e.jsx(i.Notification,{severity:"caution",title:"Before you edit the YAML",children:"Changes will be discarded, when switching back to the guided forms."})})]})},o)]}),e.jsxs("div",{className:"p-bottom-controls",id:"form-footer",children:[e.jsx("hr",{}),e.jsx(i.Row,{className:"u-align--right",children:e.jsx(i.Col,{size:12,children:N?e.jsx(i.Button,{appearance:"positive",disabled:!a,onClick:()=>void t.setFieldValue("readOnly",!1),children:"Edit profile"}):e.jsxs(e.Fragment,{children:[e.jsx(i.Button,{appearance:"base",onClick:()=>t.setValues(v(s)),children:"Cancel"}),e.jsx(ne,{isSubmitting:t.isSubmitting,isDisabled:!t.isValid||le(t)||ce(t),buttonLabel:"Save changes",onClick:()=>void t.submitForm()})]})})})]})]})},ke=({profile:s,featuresProfiles:a})=>{const{project:n}=P();if(!n)return e.jsx(e.Fragment,{children:"Missing project"});const l=()=>{T("profile-overview-tab")};p.useEffect(l,[]),R("resize",l);const o=s.config["cloud-init.user-data"]||s.config["cloud-init.vendor-data"]||s.config["cloud-init.network-config"],c=_(n,n==="default",s.used_by).length;return e.jsxs("div",{className:"profile-overview-tab",children:[!a&&e.jsxs(i.Notification,{severity:"caution",title:"Inherited profile",children:["Modifications are only available in the"," ",e.jsx(y,{to:`/ui/project/default/profiles/detail/${s.name}`,children:"default project"}),"."]}),e.jsxs(i.Row,{className:"section",children:[e.jsx(i.Col,{size:3,children:e.jsx("h2",{className:"p-heading--5",children:"General"})}),e.jsx(i.Col,{size:7,children:e.jsx("table",{children:e.jsxs("tbody",{children:[e.jsxs("tr",{children:[e.jsx("th",{className:"p-muted-heading",children:"Name"}),e.jsx("td",{children:e.jsx(E,{item:s})})]}),e.jsxs("tr",{children:[e.jsx("th",{className:"p-muted-heading",children:"Description"}),e.jsx("td",{children:s.description?s.description:"-"})]})]})})})]}),e.jsxs(i.Row,{className:"section",children:[e.jsx(i.Col,{size:3,children:e.jsx("h2",{className:"p-heading--5",children:"Devices"})}),e.jsx(i.Col,{size:7,children:e.jsx("table",{children:e.jsxs("tbody",{children:[e.jsxs("tr",{className:"list-wrapper",children:[e.jsx("th",{className:"p-muted-heading",children:"Networks"}),e.jsx("td",{children:e.jsx(A,{profile:s})})]}),e.jsxs("tr",{className:"list-wrapper",children:[e.jsx("th",{className:"p-muted-heading",children:"Storage"}),e.jsx("td",{children:e.jsx(B,{profile:s})})]})]})})})]}),e.jsxs(i.Row,{className:"section",children:[e.jsx(i.Col,{size:3,children:e.jsx("h2",{className:"p-heading--5",children:"Limits"})}),e.jsx(i.Col,{size:7,children:e.jsx("table",{children:e.jsxs("tbody",{children:[e.jsxs("tr",{children:[e.jsx("th",{className:"p-muted-heading",children:"CPU"}),e.jsx("td",{children:s.config["limits.cpu"]||"-"})]}),e.jsxs("tr",{children:[e.jsx("th",{className:"p-muted-heading",children:"Memory"}),e.jsx("td",{children:s.config["limits.memory"]||"-"})]})]})})})]}),e.jsxs(i.Row,{className:k("section",{"u-hide":!o}),children:[e.jsx(i.Col,{size:3,children:e.jsx("h2",{className:"p-heading--5",children:"Cloud init"})}),e.jsx(i.Col,{size:7,className:"view-config",children:e.jsx(y,{to:`/ui/project/${n}/profiles/detail/${s.name}/configuration/${u(z)}`,children:"View configuration"})})]}),e.jsxs(i.Row,{className:"usage list-wrapper",children:[e.jsx(i.Col,{size:3,children:e.jsxs("h2",{className:"p-heading--5",children:["Usage (",c,")"]})}),e.jsx(i.Col,{size:7,children:c>0?e.jsx("table",{children:e.jsx("tbody",{children:e.jsx(H,{profile:s,project:n,headingClassName:"p-muted-heading"})})}):e.jsx(e.Fragment,{children:"-"})})]})]})},Oe=({profile:s,project:a,featuresProfiles:n})=>{const l=Y(),o=i.useNotify(),h=I(),[c,x]=p.useState(!1),m=S(),d=()=>{x(!0),G(s.name,a).then(()=>{h.invalidateQueries({queryKey:[D.projects,a]}),m(`/ui/project/${a}/profiles`,o.queue(o.success(`Profile ${s.name} deleted.`)))}).catch(b=>{x(!1),o.failure("Profile deletion failed",b)})},f=s.name==="default",t=()=>n?f?"The default profile cannot be deleted":"Delete profile":"Modifications are only available in the default project";return e.jsxs(i.ConfirmationButton,{onHoverText:t(),appearance:l?"base":"default",className:k("u-no-margin--bottom",{"has-icon":l}),disabled:f||!n,loading:c,confirmationModalProps:{title:"Confirm delete",confirmButtonLabel:"Delete",onConfirm:d,children:e.jsxs("p",{children:["This will permanently delete profile"," ",e.jsx(E,{item:s,bold:!0}),".",e.jsx("br",{}),"This action cannot be undone, and can result in data loss."]})},shiftClickEnabled:!0,showShiftClickHint:!0,children:[l&&e.jsx(i.Icon,{name:"delete"}),!l&&e.jsx("span",{children:"Delete"})]})},$e=({name:s,profile:a,project:n,featuresProfiles:l})=>{const o=S(),h=i.useNotify(),c=p.useState(null),x=O().shape({name:$().test("deduplicate","A profile with this name already exists",d=>(a==null?void 0:a.name)===d||Q(d,n,c,"profiles")).required("Profile name is required")}),m=M({initialValues:{name:s,isRenaming:!1},validationSchema:x,onSubmit:d=>{if(s===d.name){m.setFieldValue("isRenaming",!1),m.setSubmitting(!1);return}W(s,d.name,n).then(()=>{o(`/ui/project/${n}/profiles/detail/${d.name}`,h.queue(h.success("Profile renamed."))),m.setFieldValue("isRenaming",!1)}).catch(f=>{h.failure("Renaming failed",f)}).finally(()=>m.setSubmitting(!1))}});return e.jsx(Re,{name:s,parentItems:[e.jsx(y,{to:`/ui/project/${n}/profiles`,children:"Profiles"},1)],renameDisabledReason:a&&a.name==="default"?"Cannot rename the default profile":void 0,controls:a&&e.jsx(Oe,{profile:a,project:n,featuresProfiles:l},"delete"),isLoaded:!!a,formik:m})},Me=["Overview","Configuration"],as=()=>{const s=i.useNotify(),{name:a,project:n,activeTab:l}=P();if(!a)return e.jsx(e.Fragment,{children:"Missing name"});if(!n)return e.jsx(e.Fragment,{children:"Missing project"});const{project:o,isLoading:h}=Z(),{data:c,error:x,isLoading:m}=J({queryKey:[D.profiles,"detail",a],queryFn:()=>ae(a,n)});x&&s.failure("Loading profile failed",x);const d=m||h,f=X(o);return e.jsxs(ee,{header:e.jsx($e,{name:a,profile:c,project:n,featuresProfiles:f}),contentClassName:"detail-page",children:[e.jsx(se,{}),d&&e.jsx(ie,{text:"Loading profile details..."}),!d&&!c&&e.jsx(e.Fragment,{children:"Loading profile failed"}),!d&&c&&e.jsxs(i.Row,{children:[e.jsx(te,{tabs:Me,activeTab:l,tabUrl:`/ui/project/${n}/profiles/detail/${a}`}),!l&&e.jsx("div",{role:"tabpanel","aria-labelledby":"overview",children:e.jsx(ke,{profile:c,featuresProfiles:f})}),l==="configuration"&&e.jsx("div",{role:"tabpanel","aria-labelledby":"configuration",children:e.jsx(Ee,{profile:c,featuresProfiles:f})})]})]})};export{as as default};

Zerion Mini Shell 1.0