| 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/StoragePools-DdGE3Ex8.js |
import{c as x,O as j,x as b,j as e,d as s,R as u,I as N,S,s as c,L as f,M as y,p as v}from"./index-BFGypnt-.js";import{D as C}from"./DeleteStoragePoolBtn-BWh9dpGZ.js";import{S as P}from"./StoragePoolSize-ChYxPd_8.js";import{H as I}from"./HelpLink-l4aaXUp-.js";import{P as l}from"./PageHeader-DZVSTM6q.js";import{u as L}from"./useStoragePools-qBtKr1j9.js";import{S as w}from"./StoragePoolClusterMember-BjRQEHXC.js";import"./StoragePoolRichChip-CxRTjvv2.js";import"./useClusterMembers-B29_ixY7.js";import"./cluster-members-CG6XHzn4.js";import"./Meter-VGEmUMfL.js";import"./ClusterMemberRichChip-h3WaiYeI.js";import"./ClusterMemberMemoryUsage-UO8J-hw2.js";const m=({project:i,className:a})=>{const o=x(),r=j(),{canCreateStoragePools:n}=b();return e.jsxs(s.Button,{appearance:"positive",className:a,hasIcon:!r,title:n()?"":"You do not have permission to create storage pools",onClick:async()=>o(`${u}/ui/project/${encodeURIComponent(i)}/storage/pools/create`),disabled:!n(),children:[!r&&e.jsx(s.Icon,{name:"plus",light:!0}),e.jsx("span",{children:"Create pool"})]})},O=()=>{const i=s.useNotify(),{project:a}=N(),o=S();if(!a)return e.jsx(e.Fragment,{children:"Missing project"});const{data:r=[],error:n,isLoading:d}=L();n&&i.failure("Loading storage pools failed",n);const p=[{content:"Name",sortKey:"name"},{content:"Driver",sortKey:"driver",className:"driver"},...o?[{content:"Cluster member",className:"cluster-member"}]:[],{content:"Size",className:c("size",{clustered:o})},{content:e.jsx(e.Fragment,{children:"Used by"}),sortKey:"usedBy",className:"u-align--right volumes-total"},{content:"Status",sortKey:"status",className:"status"},{"aria-label":"Actions",className:"u-align--right actions"}],g=r.map(t=>({key:t.name,columns:[{content:e.jsx(f,{to:`${u}/ui/project/${encodeURIComponent(a)}/storage/pool/${encodeURIComponent(t.name)}`,children:t.name}),role:"rowheader","aria-label":"Name"},{content:t.driver,role:"cell","aria-label":"Driver",className:"driver"},...o?[{content:e.jsx(w,{pool:t}),role:"cell","aria-label":"Cluster member",className:"cluster-member"}]:[],{content:e.jsx(P,{pool:t,hasMeterBar:!0}),role:"cell","aria-label":"Size",className:c("size",{clustered:o})},{content:t.used_by?.length??0,role:"cell",className:"u-align--right volumes-total","aria-label":"Volumes in all projects"},{content:t.status,role:"cell","aria-label":"Status",className:"status"},{content:e.jsx(C,{pool:t,project:a},t.name),role:"cell",className:"u-align--right actions","aria-label":"Actions"}],sortData:{name:t.name.toLowerCase(),driver:t.driver,status:t.status,usedBy:t.used_by?.length??0}}));if(d)return e.jsx(s.Spinner,{className:"u-loader",text:"Loading...",isMainComponent:!0});const h=r.length>0?e.jsx(s.Row,{children:e.jsx(s.ScrollableTable,{dependencies:[r],tableId:"storage-pool-table",belowIds:["status-bar"],children:e.jsx(s.MainTable,{id:"storage-pool-table",headers:p,rows:g,sortable:!0,className:"storage-pool-table"})})}):e.jsxs(s.EmptyState,{className:"empty-state",image:e.jsx(s.Icon,{name:"storage-pool",className:"empty-state-icon"}),title:"No pools found in this project",children:[e.jsx("p",{children:"Storage pools will appear here."}),e.jsx("p",{children:e.jsx(y,{docPath:"/explanation/storage/",hasExternalIcon:!0,children:"Learn more about storage pools, volumes and buckets"})}),e.jsx(m,{project:a,className:"empty-state-button"})]});return e.jsxs(s.CustomLayout,{contentClassName:"detail-page",header:e.jsxs(l,{children:[e.jsx(l.Left,{children:e.jsx(l.Title,{children:e.jsx(I,{docPath:"/explanation/storage/",title:"Learn more about storage pools, volumes and buckets",children:"Pools"})})}),e.jsx(l.BaseActions,{children:e.jsx(m,{project:a,className:"u-float-right u-no-margin--bottom"})})]}),children:[e.jsx(v,{}),e.jsx(s.Row,{children:h})]})};export{O as default};