| Current Path : /snap/lxd/38768/share/lxd-ui/assets/ |
| Current File : //snap/lxd/38768/share/lxd-ui/assets/StoragePoolDetail-Bp_avqxf.js |
import{c as k,d as s,r as j,f as M,h as U,ak as q,k as D,ef as E,R as x,j as e,L as y,Q as _,dI as A,a3 as K,b as Y,v as H,C as w,t as Q,eg as G,a9 as J,eh as W,ei as X,x as f,dN as Z,e0 as ee,a6 as S,dC as te,dt as se,ed as oe,bm as re,p as ae,s as P}from"./index-BsQN_SZU.js";import{R as ie}from"./RenameHeader-BdCO5Nid.js";import{D as ne,u as le}from"./DeleteStoragePoolBtn-IU1yXGAf.js";import{S as T}from"./StoragePoolRichChip-Daex_aZU.js";import{S as ce}from"./StoragePoolSize-BNbqTfwA.js";import{S as me}from"./StorageUsedBy-DAoQcJUS.js";import{S as de}from"./StoragePoolClusterMember-BaBZgKZ2.js";import{a as F,t as ue,M as I,Y as $,S as pe}from"./StoragePoolForm-BroxRsS_.js";import{F as he}from"./FormFooterLayout-CcbL_-PB.js";import{y as xe,Y as ge}from"./YamlSwitch-BStSXJFs.js";import{F as je}from"./FormSubmitBtn-DEfKgZu7.js";import{T as fe}from"./TabLinks-N89T_JJh.js";import"./Meter-cq8smrSm.js";import"./UsedByRow-DlstYIKs.js";import"./UsedByItem-DYTdOZkC.js";import"./SshKeyForm-BNz7yPwa.js";import"./limits-yeXZOxhv.js";import"./AutoExpandingTextArea-Bd-45rZK.js";import"./formFields-DzJouV_d.js";import"./scroll-Dc7Cgzms.js";import"./ProjectRichChip-DZzjTfq6.js";import"./ConfigFieldDescription-CjXKAIpa.js";import"./snapshots-LtzKNDw1.js";import"./ExpandableList-DsGr0BpD.js";import"./ClusterMemberRichChip-Di9w-E3M.js";import"./ClusterMemberMemoryUsage-DYUQFY0n.js";import"./DiskSizeSelector-C9kWj54D.js";import"./ClusterSpecificInput-7EvfCd3b.js";import"./formChangeCount-Kjdextdt.js";const Se=({name:t,pool:i,project:o})=>{const a=k(),d=s.useNotify(),h=s.useToastNotification(),n=j.useState(null),l=M().shape({name:U().test(...q(o,n)).required("This field is required")}),c=D({initialValues:{name:t,isRenaming:!1},validationSchema:l,onSubmit:u=>{if(t===u.name){c.setFieldValue("isRenaming",!1),c.setSubmitting(!1);return}E(t,u.name).then(()=>{const g=`${x}/ui/project/${encodeURIComponent(o)}/storage/pool/${encodeURIComponent(u.name)}`;a(g),h.success(e.jsxs(e.Fragment,{children:["Storage pool ",e.jsx("strong",{children:t})," renamed to"," ",e.jsx(T,{poolName:u.name,projectName:o})]})),c.setFieldValue("isRenaming",!1)}).catch(g=>{d.failure("Renaming failed",g)}).finally(()=>{c.setSubmitting(!1)})}});return e.jsx(ie,{name:t,parentItems:[e.jsx(y,{to:`${x}/ui/project/${encodeURIComponent(o)}/storage/pools`,children:"Storage pools"},1)],controls:[e.jsx(ne,{pool:i,project:o,shouldExpand:!0},"delete")],isLoaded:!0,renameDisabledReason:"Cannot rename storage pools"})},be=({pool:t,project:i})=>{const o=()=>{K("storage-overview-tab")};j.useEffect(o,[i,t]),s.useListener(window,o,"resize",!0);const a=_(),d=A(t.driver);return e.jsxs("div",{className:"storage-overview-tab",children:[e.jsxs(s.Row,{className:"section",children:[e.jsx(s.Col,{size:3,children:e.jsx("h2",{className:"p-heading--5",children:"General"})}),e.jsx(s.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&&a&&e.jsx(de,{pool:t}),e.jsx(ce,{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(s.Row,{className:"section",children:[e.jsx(s.Col,{size:3,children:e.jsx("h2",{className:"p-heading--5",children:"Used by"})}),e.jsx(s.Col,{size:7,children:e.jsx(me,{storage:t})})]})]})},Ce=({pool:t})=>{const i=k(),o=s.useNotify(),{data:a}=Y(),d=s.useToastNotification(),h=H(),{project:n,section:l}=w(),c=j.useState(null),{data:u=[]}=Q(),[g,L]=j.useState(0),{canEditPool:O}=le();if(!n)return e.jsx(e.Fragment,{children:"Missing project"});const{data:v=[],error:b}=G(t.name);j.useEffect(()=>{b&&o.failure("Loading storage pool from cluster members failed",b)},[b]);const V=M().shape({name:U().test("deduplicate","A pool with this name already exists",async r=>r===t.name||J(r,n,c,"storage-pools")).required("This field is required")}),z=O(t)?void 0:"You do not have permission to edit this pool",m=D({initialValues:F(t,v,z),validationSchema:V,enableReinitialize:!0,onSubmit:r=>{const N=r.yaml?xe(r.yaml):ue(r);(u.length>0?async()=>W(N,u,r.sourcePerClusterMember,r.zfsPoolNamePerClusterMember,r.sizePerClusterMember):async()=>X(N))().then(()=>{d.success(e.jsxs(e.Fragment,{children:["Storage pool"," ",e.jsx(T,{poolName:N.name,projectName:n})," ","updated."]}))}).catch(p=>{o.failure("Storage pool update failed",p)}).finally(()=>{m.setSubmitting(!1),h.invalidateQueries({queryKey:[f.storage],predicate:p=>p.queryKey[0]===f.volumes||p.queryKey[0]===f.storage}),t.driver===Z&&r.ceph_rbd_du==="false"&&h.removeQueries({predicate:p=>p.queryKey[0]===f.storage&&p.queryKey[1]===t.name})})}}),C=`${x}/ui/project/${encodeURIComponent(n)}/storage/pool/${encodeURIComponent(t.name)}/configuration`,R=r=>{i(r===I?C:`${C}/${S(r)}`)},B=ee(a).has(m.values.driver)?S(I):S($);return e.jsxs("div",{className:"edit-storage-pool",children:[e.jsx(pe,{formik:m,section:l??B,setSection:R,version:g}),e.jsxs(he,{children:[e.jsx(ge,{formik:m,section:l,setSection:R}),m.values.readOnly?null:e.jsxs(e.Fragment,{children:[e.jsx(s.Button,{appearance:"base",onClick:()=>{L(r=>r+1),m.setValues(F(t,v))},children:"Cancel"}),e.jsx(je,{formik:m,baseUrl:C,isYaml:l===S($),disabled:!m.values.name})]})]})]})},Ze=()=>{const{name:t,project:i,activeTab:o}=w();if(!t)return e.jsx(e.Fragment,{children:"Missing name"});if(!i)return e.jsx(e.Fragment,{children:"Missing project"});const{data:a,error:d,isLoading:h}=te(t),n=a?.driver!==se,l=oe(a?.driver||"");if(h)return e.jsx(s.Spinner,{className:"u-loader",text:"Loading...",isMainComponent:!0});if(!a)return e.jsx(re,{entityType:"pool",entityName:t,errorMessage:d?.message});const c=["Overview","Configuration",{component:()=>e.jsxs(y,{to:n?`${x}/ui/project/${encodeURIComponent(i)}/storage/volumes?pool=${encodeURIComponent(a.name)}`:"#",className:P("p-tabs__link",{"is-disabled":!n}),title:n?"Volumes":"Volumes are not supported on this pool",children:["Volumes ",e.jsx(s.Icon,{name:"external-link"})]}),label:"Volumes"},{component:()=>e.jsxs(y,{to:l?`${x}/ui/project/${encodeURIComponent(i)}/storage/buckets?pool=${encodeURIComponent(a.name)}`:"#",className:P("p-tabs__link",{"is-disabled":!l}),title:l?"Buckets":"Buckets are not supported on this pool",children:["Buckets ",e.jsx(s.Icon,{name:"external-link"})]}),label:"Buckets"}];return e.jsxs(s.CustomLayout,{header:e.jsx(Se,{name:t,pool:a,project:i}),contentClassName:"detail-page",children:[e.jsx(ae,{}),e.jsxs(s.Row,{children:[e.jsx(fe,{tabs:c,activeTab:o,tabUrl:`${x}/ui/project/${encodeURIComponent(i)}/storage/pool/${encodeURIComponent(t)}`}),!o&&e.jsx("div",{role:"tabpanel","aria-labelledby":"overview",children:e.jsx(be,{pool:a,project:i})}),o==="configuration"&&e.jsx("div",{role:"tabpanel","aria-labelledby":"configuration",children:e.jsx(Ce,{pool:a})})]})]})};export{Ze as default};