import{s as x,U as b,p as N,j as e,d as t,R as d,H as S,a3 as f,fo as y,bP as v,K as m,L as C,fp as P,fq as L,D as I,e as w}from"./index-C88DWJny.js";import{D as R}from"./DeleteStoragePoolBtn-CazjBA0R.js";import{H as B}from"./HelpLink-c8Zoz7ma.js";import{P as l}from"./PageHeader-6_Og6mu3.js";const u=({project:i,className:a})=>{const o=x(),n=b(),{canCreateStoragePools:r}=N();return e.jsxs(t.Button,{appearance:"positive",className:a,hasIcon:!n,title:r()?"":"You do not have permission to create storage pools",onClick:async()=>o(`${d}/ui/project/${encodeURIComponent(i)}/storage/pools/create`),disabled:!r(),children:[!n&&e.jsx(t.Icon,{name:"plus",light:!0}),e.jsx("span",{children:"Create pool"})]})},E=()=>{const i=t.useNotify(),{project:a}=S(),o=f(),n=y();if(!a)return e.jsx(e.Fragment,{children:"Missing project"});const{data:r=[],error:c,isLoading:g}=v(!0,a);c&&i.failure("Loading storage pools failed",c);const p=[{content:"Name",sortKey:"name"},{content:"Driver",sortKey:"driver",className:"driver"},...o?[{content:"Cluster member",className:"cluster-member"}]:[],{content:"Size",className:m("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=>({key:s.name,columns:[{content:e.jsx(C,{to:`${d}/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(P,{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:m("size",{clustered:o})},{content:s.used_by?.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(R,{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:s.used_by?.length??0}}));if(g)return e.jsx(t.Spinner,{className:"u-loader",text:"Loading...",isMainComponent:!0});const j=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:"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(I,{docPath:"/explanation/storage/",hasExternalIcon:!0,children:"Learn more about storage pools, volumes and buckets"})}),n&&e.jsx(u,{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(B,{docPath:"/explanation/storage/",title:"Learn more about storage pools, volumes and buckets",children:"Pools"})})}),e.jsx(l.BaseActions,{children:n&&e.jsx(u,{project:a,className:"u-float-right u-no-margin--bottom"})})]}),children:[e.jsx(w,{}),e.jsx(t.Row,{children:j})]})};export{E as default};
