| Current Path : /proc/thread-self/root/snap/lxd/current/share/lxd-ui/assets/ |
| Current File : //proc/thread-self/root/snap/lxd/current/share/lxd-ui/assets/StoragePoolDetail-D_DshpPb.js |
import{c as L,d as r,r as f,K as z,J as q,f as _,h as A,k as K,j as e,L as k,R as x,S as W,a2 as X,b as Z,t as ee,I as Q,E as te,a5 as C,w as y,b3 as se,p as oe,s as T}from"./index-BFGypnt-.js";import{R as re}from"./RenameHeader-yxEpJNaX.js";import{D as ae,u as ie}from"./DeleteStoragePoolBtn-BWh9dpGZ.js";import{t as ne,T as ce,l as le,U as me,V as de,W as ue,O as pe,w as he,h as ge,n as xe,S as je}from"./useStoragePools-qBtKr1j9.js";import{S as v}from"./StoragePoolRichChip-CxRTjvv2.js";import{S as fe}from"./StoragePoolSize-ChYxPd_8.js";import{S as Se}from"./StorageUsedBy-IXQzaZEP.js";import{S as be}from"./StoragePoolClusterMember-BjRQEHXC.js";import{t as Ne,a as E,M as V,Y as B,S as Ce}from"./StoragePoolForm-hvCxtFgL.js";import{u as ye}from"./useClusterMembers-B29_ixY7.js";import{F as ve}from"./FormFooterLayout-CMGxv4XX.js";import{y as Re,d as Pe}from"./YamlSwitch-BQqYYI1i.js";import{F as Fe}from"./FormSubmitBtn-NpEQWJ3F.js";import{T as $e}from"./TabLinks-BlmDr2on.js";import"./Meter-VGEmUMfL.js";import"./UsedByRow-oKHc8A5r.js";import"./UsedByItem-DETYWHDN.js";import"./useImages-DavKpFTt.js";import"./images-C6WqBeZG.js";import"./image-registries-YAuyq4CZ.js";import"./ProfileRichChip-XiLIeCE5.js";import"./ProfileResourceLimits-DkY60ueM.js";import"./useProfiles-CErbukD2.js";import"./ProjectRichChip-CtiU36yR.js";import"./ExpandableList-DK5_MQFC.js";import"./ClusterMemberRichChip-h3WaiYeI.js";import"./ClusterMemberMemoryUsage-UO8J-hw2.js";import"./cluster-members-CG6XHzn4.js";import"./DiskSizeSelector-C_YZZUSe.js";import"./AutoExpandingTextArea-WEdimI5c.js";import"./ScrollableForm-D-7nf2YI.js";import"./FormMenuItem-fhYfVpHc.js";import"./ClusterSpecificInput-BYM6R5do.js";import"./ConfigurationTable-CmO6jSmV.js";import"./ConfigFieldDescription-CY0sdTp6.js";import"./ScrollableConfigurationTable-Cdfv_OdM.js";import"./formChangeCount-Dw7v2KcL.js";const ke=({name:t,pool:i,project:a})=>{const n=L(),d=r.useNotify(),h=r.useToastNotification(),l=f.useState(null),{hasStorageAndNetworkOperations:u}=z(),j=q(),S=_().shape({name:A().test(...ne(a,l)).required("This field is required")}),b=c=>{const m=`${x}/ui/project/${encodeURIComponent(a)}/storage/pool/${encodeURIComponent(c)}`;n(m),h.success(e.jsxs(e.Fragment,{children:["Storage pool ",e.jsx("strong",{children:t})," renamed to"," ",e.jsx(v,{poolName:c,projectName:a})]}))},N=(c,m)=>{d.failure(`Renaming of storage pool ${c} failed`,m)},g=K({initialValues:{name:t,isRenaming:!1},validationSchema:S,onSubmit:c=>{if(t===c.name){g.setFieldValue("isRenaming",!1),g.setSubmitting(!1);return}ce(t,c.name).then(m=>{u?(h.info(e.jsxs(e.Fragment,{children:["Renaming of storage pool"," ",e.jsx(v,{poolName:c.name,projectName:a})," ","has started."]})),j.set(m.metadata.id,()=>{b(c.name)},R=>{N(c.name,new Error(R))})):b(c.name),g.setFieldValue("isRenaming",!1)}).catch(m=>{N(c.name,m)}).finally(()=>{g.setSubmitting(!1)})}});return e.jsx(re,{name:t,parentItems:[e.jsx(k,{to:`${x}/ui/project/${encodeURIComponent(a)}/storage/pools`,children:"Storage pools"},1)],controls:[e.jsx(ae,{pool:i,project:a,shouldExpand:!0},"delete")],isLoaded:!!i,formik:g,renameDisabledReason:"Cannot rename storage pools"})},Ie=({pool:t,project:i})=>{const a=()=>{X("storage-overview-tab")};f.useEffect(a,[i,t]),r.useListener(window,a,"resize",!0);const n=W(),d=le(t.driver);return e.jsxs("div",{className:"storage-overview-tab",children:[e.jsxs(r.Row,{className:"section",children:[e.jsx(r.Col,{size:3,children:e.jsx("h2",{className:"p-heading--5",children:"General"})}),e.jsx(r.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:t.name})]}),e.jsxs("tr",{children:[e.jsx("th",{className:"u-text--muted",children:"Status"}),e.jsx("td",{children:t.status})]}),e.jsxs("tr",{children:[e.jsx("th",{className:"u-text--muted",children:"Size"}),e.jsxs("td",{className:"cluster-member-with-meters",children:[d&&n&&e.jsx(be,{pool:t}),e.jsx(fe,{pool:t,hasMeterBar:!0})]})]}),e.jsxs("tr",{children:[e.jsx("th",{className:"u-text--muted",children:"Source"}),e.jsx("td",{children:t.config?.source??"-"})]}),e.jsxs("tr",{children:[e.jsx("th",{className:"u-text--muted",children:"Description"}),e.jsx("td",{children:t.description?t.description:"-"})]}),e.jsxs("tr",{children:[e.jsx("th",{className:"u-text--muted",children:"Driver"}),e.jsx("td",{children:t.driver})]})]})})})]}),e.jsxs(r.Row,{className:"section",children:[e.jsx(r.Col,{size:3,children:e.jsx("h2",{className:"p-heading--5",children:"Used by"})}),e.jsx(r.Col,{size:7,children:e.jsx(Se,{storage:t})})]})]})},Ue=({pool:t})=>{const i=L(),a=r.useNotify(),{data:n}=Z(),d=r.useToastNotification(),h=ee(),{project:l,section:u}=Q(),j=f.useState(null),{data:S=[]}=ye(),[b,N]=f.useState(0),{canEditPool:g}=ie(),{hasRemoteDropSource:c,hasStorageAndNetworkOperations:m}=z(),R=q();if(!l)return e.jsx(e.Fragment,{children:"Missing project"});const{data:I=[],error:P}=me(t.name);f.useEffect(()=>{P&&a.failure("Loading storage pool from cluster members failed",P)},[P]);const H=_().shape({name:A().test("deduplicate","A pool with this name already exists",async s=>s===t.name||te(s,l,j,"storage-pools")).required("This field is required")}),Y=g(t)?void 0:"You do not have permission to edit this pool",U=s=>{h.invalidateQueries({queryKey:[y.storage],predicate:o=>o.queryKey[0]===y.volumes||o.queryKey[0]===y.storage}),t.driver===he&&s.ceph_rbd_du==="false"&&h.removeQueries({predicate:o=>o.queryKey[0]===y.storage&&o.queryKey[1]===t.name})},w=(s,o)=>{U(o),p.setSubmitting(!1),d.success(e.jsxs(e.Fragment,{children:["Storage pool"," ",e.jsx(v,{poolName:s,projectName:l})," ","updated."]}))},M=(s,o,O)=>{U(s),p.setSubmitting(!1),d.failure(`Update of storage pool ${o} failed`,O)},p=K({initialValues:E(t,I,Y),validationSchema:H,enableReinitialize:!0,onSubmit:s=>{const o=s.yaml?Re(s.yaml):Ne(s,c);(S.length>0?async()=>de(o,S,m,s.sourcePerClusterMember,s.zfsPoolNamePerClusterMember,s.sizePerClusterMember):async()=>ue(o))().then($=>{m?(d.info(e.jsxs(e.Fragment,{children:["Update of storage pool"," ",e.jsx(v,{poolName:o.name,projectName:l})," ","has started."]})),R.set($.metadata.id,()=>{w(o.name,s)},J=>{M(s,o.name,new Error(J))})):w(o.name,s)}).catch($=>{M(s,o.name,$)})}}),F=`${x}/ui/project/${encodeURIComponent(l)}/storage/pool/${encodeURIComponent(t.name)}/configuration`,D=s=>{i(s===V?F:`${F}/${C(s)}`)},G=pe(n).has(p.values.driver)?C(V):C(B);return e.jsxs("div",{className:"edit-storage-pool",children:[e.jsx(Ce,{formik:p,section:u??G,setSection:D,version:b}),e.jsxs(ve,{children:[e.jsx(Pe,{formik:p,section:u,setSection:D}),p.values.readOnly?null:e.jsxs(e.Fragment,{children:[e.jsx(r.Button,{appearance:"base",onClick:()=>{N(s=>s+1),p.setValues(E(t,I))},children:"Cancel"}),e.jsx(Fe,{formik:p,baseUrl:F,isYaml:u===C(B),disabled:!p.values.name})]})]})]})},xt=()=>{const{name:t,project:i,activeTab:a}=Q();if(!t)return e.jsx(e.Fragment,{children:"Missing name"});if(!i)return e.jsx(e.Fragment,{children:"Missing project"});const{data:n,error:d,isLoading:h}=ge(t),l=n?.driver!==xe,u=je(n?.driver||"");if(h)return e.jsx(r.Spinner,{className:"u-loader",text:"Loading...",isMainComponent:!0});if(!n)return e.jsx(se,{entityType:"pool",entityName:t,errorMessage:d?.message});const j=["Overview","Configuration",{component:()=>e.jsxs(k,{to:l?`${x}/ui/project/${encodeURIComponent(i)}/storage/volumes?pool=${encodeURIComponent(n.name)}`:"#",className:T("p-tabs__link",{"is-disabled":!l}),title:l?"Volumes":"Volumes are not supported on this pool",children:["Volumes ",e.jsx(r.Icon,{name:"external-link"})]}),label:"Volumes"},{component:()=>e.jsxs(k,{to:u?`${x}/ui/project/${encodeURIComponent(i)}/storage/buckets?pool=${encodeURIComponent(n.name)}`:"#",className:T("p-tabs__link",{"is-disabled":!u}),title:u?"Buckets":"Buckets are not supported on this pool",children:["Buckets ",e.jsx(r.Icon,{name:"external-link"})]}),label:"Buckets"}];return e.jsxs(r.CustomLayout,{header:e.jsx(ke,{name:t,pool:n,project:i}),contentClassName:"detail-page",children:[e.jsx(oe,{}),e.jsxs(r.Row,{children:[e.jsx($e,{tabs:j,activeTab:a,tabUrl:`${x}/ui/project/${encodeURIComponent(i)}/storage/pool/${encodeURIComponent(t)}`}),!a&&e.jsx("div",{role:"tabpanel","aria-labelledby":"overview",children:e.jsx(Ie,{pool:n,project:i})}),a==="configuration"&&e.jsx("div",{role:"tabpanel","aria-labelledby":"configuration",children:e.jsx(Ue,{pool:n})})]})]})};export{xt as default};