import{k as j,w as x,i as N,j as e,d as t,n as S,E as f,b0 as y,s as u,L as v,b3 as C}from"./index-lOezWVmi.js";import{D as P}from"./DeleteStoragePoolBtn-igdPuBb1.js";import{S as L}from"./StoragePoolSize-BD_icnzk.js";import{H as w}from"./HelpLink-8_zL-2ID.js";import{N as I}from"./NotificationRow-DdxAfFhk.js";import{P as l}from"./PageHeader-DVTHSBni.js";import{S as k}from"./StoragePoolClusterMember-DtezwXmQ.js";import"./Meter-CCMCY0F-.js";const d=({project:i,className:a})=>{const o=j(),r=x(),{canCreateStoragePools:n}=N();return e.jsxs(t.Button,{appearance:"positive",className:a,hasIcon:!r,title:n()?"":"You do not have permission to create storage pools",onClick:async()=>o(`/ui/project/${encodeURIComponent(i)}/storage/pools/create`),disabled:!n(),children:[!r&&e.jsx(t.Icon,{name:"plus",light:!0}),e.jsx("span",{children:"Create pool"})]})},A=()=>{const i=t.useNotify(),{project:a}=S(),o=f();if(!a)return e.jsx(e.Fragment,{children:"Missing project"});const{data:r=[],error:n,isLoading:g}=y(!0,a);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:u("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"}],h=r.map(s=>{var c,m;return{key:s.name,columns:[{content:e.jsx(v,{to:`/ui/project/${encodeURIComponent(a)}/storage/pool/${encodeURIComponent(s.name)}`,children:s.name}),role:"rowheader","aria-label":"Name"},{content:s.driver,role:"cell","aria-label":"Driver",className:"driver"},...o?[{content:e.jsx(k,{pool:s}),role:"cell","aria-label":"Cluster member",className:"cluster-member"}]:[],{content:e.jsx(L,{pool:s,hasMeterBar:!0}),role:"cell","aria-label":"Size",className:u("size",{clustered:o})},{content:((c=s.used_by)==null?void 0:c.length)??0,role:"cell",className:"u-align--right volumes-total","aria-label":"Volumes in all projects"},{content:s.status,role:"cell","aria-label":"Status",className:"status"},{content:e.jsx(P,{pool:s,project:a},s.name),role:"cell",className:"u-align--right actions","aria-label":"Actions"}],sortData:{name:s.name.toLowerCase(),driver:s.driver,status:s.status,usedBy:((m=s.used_by)==null?void 0:m.length)??0}}});if(g)return e.jsx(t.Spinner,{className:"u-loader",text:"Loading...",isMainComponent:!0});const b=r.length>0?e.jsx(t.Row,{children:e.jsx(t.ScrollableTable,{dependencies:[r],tableId:"storage-pool-table",belowIds:["status-bar"],children:e.jsx(t.MainTable,{id:"storage-pool-table",headers:p,rows:h,sortable:!0,className:"storage-pool-table"})})}):e.jsxs(t.EmptyState,{className:"empty-state",image:e.jsx(t.Icon,{name:"switcher-dashboard",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(C,{docPath:"/explanation/storage/",hasExternalIcon:!0,children:"Learn more about storage pools, volumes and buckets"})}),e.jsx(d,{project:a,className:"empty-state-button"})]});return e.jsxs(t.CustomLayout,{contentClassName:"detail-page",header:e.jsxs(l,{children:[e.jsx(l.Left,{children:e.jsx(l.Title,{children:e.jsx(w,{docPath:"/explanation/storage/",title:"Learn more about storage pools, volumes and buckets",children:"Pools"})})}),e.jsx(l.BaseActions,{children:e.jsx(d,{project:a,className:"u-float-right u-no-margin--bottom"})})]}),children:[e.jsx(I,{}),e.jsx(t.Row,{children:b})]})};export{A as default};
