/
snap
/
lxd
/
current
/
share
/
lxd-ui
/
assets
/
File Upload :
llllll
Current File: //snap/lxd/current/share/lxd-ui/assets/StoragePoolDetail-BFKoFv9e.js
import{c as k,d as o,r as x,f as U,g as M,a7 as q,i as $,cZ as E,j as e,R as L,L as y,E as O,cz as _,T as K,b as Y,l as A,p as D,k as H,c_ as G,Y as Q,c$ as X,d0 as Z,q as f,cC as J,cP as W,V as S,d1 as ee,co as te,cX as se,e as oe,v as R}from"./index-B3cgCbnJ.js";import{R as ae}from"./RenameHeader-7HM7rJrm.js";import{D as re,u as ie}from"./DeleteStoragePoolBtn-DgrSzU4b.js";import{S as ne}from"./StoragePoolSize-34u3KM6q.js";import{S as le}from"./StorageUsedBy-CGXxcZ7s.js";import{S as ce}from"./StoragePoolClusterMember-C_lGzG9t.js";import{a as P,t as de,M as I,Y as F,S as me}from"./StoragePoolForm-BqqQdWs0.js";import{F as ue}from"./FormFooterLayout-ChlQYZN0.js";import{y as pe,c as he}from"./YamlSwitch-Bng19N-X.js";import{F as ge}from"./FormSubmitBtn-CI9Q_IyH.js";import{T as xe}from"./TabLinks-BN40EEc5.js";import"./Meter-v0AAwaqr.js";import"./ExpandableList-DwC4iUKg.js";import"./UsedByItem-BtsI6fTe.js";import"./storageBucket-Ct9MZnMG.js";import"./DiskSizeSelector-CIkNkBL4.js";import"./limits-CLEFMbq-.js";import"./AutoExpandingTextArea-BmFqLvbw.js";import"./FormMenuItem-BwEOqt61.js";import"./scroll-BEbDVMxI.js";import"./instanceOptions-D4bz_1Ev.js";import"./ConfigFieldDescription-C9KDhW5s.js";import"./snapshots-Bt9cFkFc.js";import"./ClusterSpecificInput-C86z5N6a.js";const je=({name:t,pool:i,project:a})=>{const d=k(),s=o.useNotify(),l=o.useToastNotification(),n=x.useState(null),m=U().shape({name:M().test(...q(a,n)).required("This field is required")}),c=$({initialValues:{name:t,isRenaming:!1},validationSchema:m,onSubmit:u=>{if(t===u.name){c.setFieldValue("isRenaming",!1),c.setSubmitting(!1);return}E(t,u.name).then(()=>{const g=`/ui/project/${encodeURIComponent(a)}/storage/pool/${encodeURIComponent(u.name)}`;d(g),l.success(e.jsxs(e.Fragment,{children:["Storage pool ",e.jsx("strong",{children:t})," renamed to"," ",e.jsx(L,{type:"pool",value:u.name,to:g}),"."]})),c.setFieldValue("isRenaming",!1)}).catch(g=>{s.failure("Renaming failed",g)}).finally(()=>{c.setSubmitting(!1)})}});return e.jsx(ae,{name:t,parentItems:[e.jsx(y,{to:`/ui/project/${encodeURIComponent(a)}/storage/pools`,children:"Storage pools"},1)],controls:[e.jsx(re,{pool:i,project:a,shouldExpand:!0},"delete")],isLoaded:!0,renameDisabledReason:"Cannot rename storage pools"})},fe=({pool:t,project:i})=>{var l,n;const a=()=>{K("storage-overview-tab")};x.useEffect(a,[i,t]),o.useListener(window,a,"resize",!0);const d=O(),s=_(t.driver);return e.jsxs("div",{className:"storage-overview-tab",children:[e.jsxs(o.Row,{className:"section",children:[e.jsx(o.Col,{size:3,children:e.jsx("h2",{className:"p-heading--5",children:"General"})}),e.jsx(o.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:[s&&d&&e.jsx(ce,{pool:t}),e.jsx(ne,{pool:t,hasMeterBar:!0})]})]}),e.jsxs("tr",{children:[e.jsx("th",{className:"u-text--muted",children:"Source"}),e.jsx("td",{children:((l=t.config)==null?void 0:l.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(o.Row,{className:"section",children:[e.jsx(o.Col,{size:3,children:e.jsxs("h2",{className:"p-heading--5",children:["Used by (",((n=t.used_by)==null?void 0:n.length)??0,")"]})}),e.jsx(o.Col,{size:7,children:e.jsx(le,{storage:t,project:i})})]})]})},Se=({pool:t})=>{const i=k(),a=o.useNotify(),{data:d}=Y(),s=o.useToastNotification(),l=A(),{project:n,section:m}=D(),c=x.useState(null),{data:u=[]}=H(),[g,w]=x.useState(0),{canEditPool:V}=ie();if(!n)return e.jsx(e.Fragment,{children:"Missing project"});const{data:v=[],error:b}=G(t.name);x.useEffect(()=>{b&&a.failure("Loading storage pool from cluster members failed",b)},[b]);const z=U().shape({name:M().test("deduplicate","A pool with this name already exists",async r=>r===t.name||Q(r,n,c,"storage-pools")).required("This field is required")}),B=V(t)?void 0:"You do not have permission to edit this pool",p=$({initialValues:P(t,v,B),validationSchema:z,enableReinitialize:!0,onSubmit:r=>{const j=r.yaml?pe(r.yaml):de(r);(u.length>0?async()=>X(j,u,r.sourcePerClusterMember,r.zfsPoolNamePerClusterMember,r.sizePerClusterMember):async()=>Z(j))().then(()=>{s.success(e.jsxs(e.Fragment,{children:["Storage pool"," ",e.jsx(L,{type:"pool",value:j.name,to:`/ui/project/${encodeURIComponent(n)}/storage/pool/${encodeURIComponent(j.name)}`})," ","updated."]}))}).catch(h=>{a.failure("Storage pool update failed",h)}).finally(()=>{p.setSubmitting(!1),l.invalidateQueries({queryKey:[f.storage],predicate:h=>h.queryKey[0]===f.volumes||h.queryKey[0]===f.storage}),t.driver===J&&r.ceph_rbd_du==="false"&&l.removeQueries({predicate:h=>h.queryKey[0]===f.storage&&h.queryKey[1]===t.name})})}}),C=`/ui/project/${encodeURIComponent(n)}/storage/pool/${encodeURIComponent(t.name)}/configuration`,N=r=>{i(r===I?C:`${C}/${S(r)}`)},T=W(d).has(p.values.driver)?S(I):S(F);return e.jsxs("div",{className:"edit-storage-pool",children:[e.jsx(me,{formik:p,section:m??T,setSection:N,version:g}),e.jsxs(ue,{children:[e.jsx(he,{formik:p,section:m,setSection:N}),p.values.readOnly?null:e.jsxs(e.Fragment,{children:[e.jsx(o.Button,{appearance:"base",onClick:()=>{w(r=>r+1),p.setValues(P(t,v))},children:"Cancel"}),e.jsx(ge,{formik:p,baseUrl:C,isYaml:m===S(F),disabled:!p.values.name})]})]})]})},Ae=()=>{const t=o.useNotify(),{name:i,project:a,activeTab:d}=D();if(!i)return e.jsx(e.Fragment,{children:"Missing name"});if(!a)return e.jsx(e.Fragment,{children:"Missing project"});const{data:s,error:l,isLoading:n}=ee(i),m=(s==null?void 0:s.driver)!==te,c=se((s==null?void 0:s.driver)||"");if(l&&t.failure("Loading storage details failed",l),n)return e.jsx(o.Spinner,{className:"u-loader",text:"Loading...",isMainComponent:!0});if(!s)return e.jsx(e.Fragment,{children:"Loading storage details failed"});const u=["Overview","Configuration",{component:()=>e.jsxs(y,{to:m?`/ui/project/${encodeURIComponent(a)}/storage/volumes?pool=${encodeURIComponent(s.name)}`:"#",className:R("p-tabs__link",{"is-disabled":!m}),title:m?"Volumes":"Volumes are not supported on this pool",children:["Volumes ",e.jsx(o.Icon,{name:"external-link"})]}),label:"Volumes"},{component:()=>e.jsxs(y,{to:c?`/ui/project/${encodeURIComponent(a)}/storage/buckets?pool=${encodeURIComponent(s.name)}`:"#",className:R("p-tabs__link",{"is-disabled":!c}),title:c?"Buckets":"Buckets are not supported on this pool",children:["Buckets ",e.jsx(o.Icon,{name:"external-link"})]}),label:"Buckets"}];return e.jsxs(o.CustomLayout,{header:e.jsx(je,{name:i,pool:s,project:a}),contentClassName:"detail-page",children:[e.jsx(oe,{}),e.jsxs(o.Row,{children:[e.jsx(xe,{tabs:u,activeTab:d,tabUrl:`/ui/project/${encodeURIComponent(a)}/storage/pool/${encodeURIComponent(i)}`}),!d&&e.jsx("div",{role:"tabpanel","aria-labelledby":"overview",children:e.jsx(fe,{pool:s,project:a})}),d==="configuration"&&e.jsx("div",{role:"tabpanel","aria-labelledby":"configuration",children:e.jsx(Se,{pool:s})})]})]})};export{Ae as default};
Copyright ©2k19 -
Hexid
|
Tex7ure