import{f as j,j as e,d as s,n as S,o as y,g as w,e as v,L,C as k,q as P,ak as C}from"./index-CzUo07dn.js";import{D as V}from"./DeleteStoragePoolBtn-258rZMSt.js";import{S as B}from"./StoragePoolSize-DCNPXe9o.js";import{u as D}from"./useSmallScreen-DnOiQRh8.js";import{S as I}from"./ScrollableTable-COas1_r_.js";import{H as K}from"./HelpLink-INVHAe6u.js";import{N as $}from"./NotificationRow-IVGrYQV6.js";import{P as c}from"./PageHeader-BgT4a4mM.js";import"./ItemName-BD8ROnMM.js";import"./ResourceLabel-BjY7hGvx.js";import"./ResourceIcon-CQum9kVZ.js";const h=({project:r,className:n})=>{const t=j(),o=D();return e.jsxs(s.Button,{appearance:"positive",className:n,hasIcon:!o,onClick:()=>t(`/ui/project/${r}/storage/pools/create`),children:[!o&&e.jsx(s.Icon,{name:"plus",light:!0}),e.jsx("span",{children:"Create pool"})]})},z=({project:r,pool:n,children:t,...o})=>{const l=j(),m=()=>{l(`/ui/project/${r}/storage/volumes?pool=${n}`)};return e.jsx(s.Button,{onClick:m,...o,children:t})},G=()=>{const r=S(),n=s.useNotify(),{project:t}=y();if(!t)return e.jsx(e.Fragment,{children:"Missing project"});const{data:o=[],error:l,isLoading:m}=w({queryKey:[P.storage],queryFn:()=>C()});l&&n.failure("Loading storage pools failed",l);const x=t==="default",f=[{content:"Name",sortKey:"name"},{content:"Driver",sortKey:"driver"},{content:"Size",className:"size"},{content:e.jsxs(e.Fragment,{children:["Volumes",e.jsx("br",{}),"(this project)"]}),sortKey:"projectVolumes",className:"u-align--right"},{content:e.jsxs(e.Fragment,{children:["Volumes",e.jsx("br",{}),"(all projects)"]}),sortKey:"allVolumes",className:"u-align--right"},{content:"Status",sortKey:"status"},{"aria-label":"Actions",className:"u-align--right actions"}],b=o.map(a=>{var p;const u=((p=a.used_by)==null?void 0:p.filter(i=>!i.startsWith("/1.0/profiles")))??[],d=u.filter(i=>x?!i.includes("project="):i.includes("project="+t)).length,g=u.length;return{columns:[{content:e.jsx(v,{to:`/ui/project/${t}/storage/pool/${a.name}`,children:a.name}),role:"rowheader","aria-label":"Name"},{content:a.driver,role:"rowheader","aria-label":"Driver"},{content:e.jsx(B,{pool:a,hasMeterBar:!0}),role:"rowheader","aria-label":"Size",className:"size"},{content:e.jsx(z,{project:t,pool:a.name,appearance:"link",className:"u-no-margin--bottom",children:d}),role:"rowheader",className:"u-align--right","aria-label":"Volumes in this projects"},{content:g,role:"rowheader",className:"u-align--right","aria-label":"Volumes in all projects"},{content:a.status,role:"rowheader","aria-label":"Status"},{content:e.jsx(V,{pool:a,project:t},a.name),role:"rowheader",className:"u-align--right actions","aria-label":"Actions"}],sortData:{name:a.name.toLowerCase(),driver:a.driver,status:a.status,projectVolumes:d,allVolumes:g}}});if(m)return e.jsx(L,{text:"Loading storage pools..."});const N=o.length>0?e.jsx(s.Row,{children:e.jsx(I,{dependencies:[o],tableId:"storage-pool-table",belowIds:["status-bar"],children:e.jsx(s.MainTable,{id:"storage-pool-table",headers:f,rows:b,sortable:!0,className:"storage-pool-table"})})}):e.jsxs(s.EmptyState,{className:"empty-state",image:e.jsx(s.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.jsxs("a",{href:`${r}/explanation/storage/`,target:"_blank",rel:"noopener noreferrer",children:["Learn more about storage",e.jsx(s.Icon,{className:"external-link-icon",name:"external-link"})]})}),e.jsx(h,{project:t,className:"empty-state-button"})]});return e.jsxs(k,{contentClassName:"detail-page",header:e.jsxs(c,{children:[e.jsx(c.Left,{children:e.jsx(c.Title,{children:e.jsx(K,{href:`${r}/explanation/storage/`,title:"Learn more about storage pools, volumes and buckets",children:"Pools"})})}),e.jsx(c.BaseActions,{children:e.jsx(h,{project:t,className:"u-float-right u-no-margin--bottom"})})]}),children:[e.jsx($,{}),e.jsx(s.Row,{children:N})]})};export{G as default};
