import{j as s,d as c,b0 as f,r as x}from"./index-lOezWVmi.js";import{S}from"./StoragePoolSize-BD_icnzk.js";const j=({pool:e})=>s.jsxs("div",{className:"label",children:[s.jsx("span",{title:e.name||"-",className:"resource u-truncate",children:e.name||"-"},"name"),s.jsx("span",{title:e.driver||"-",className:"resource-driver u-truncate",children:e.driver||"-"},"driver"),s.jsx("span",{title:"Usage",className:"resource-usage u-truncate",children:s.jsx(S,{pool:e},e.name)},"usage")]}),b=()=>{const e=["name","driver","usage"];if(e.length<2)return null;const t=e.map(o=>s.jsx("span",{className:"resource u-no-margin--bottom",children:o},o));return s.jsx("div",{className:"header",children:t})},E=({value:e,setValue:t,selectProps:o,invalidDrivers:l,project:u})=>{const d=c.useNotify(),{data:g=[],error:i,isLoading:m}=f(!0,u),r=g.filter(a=>!(l!=null&&l.includes(a.driver)));if(x.useEffect(()=>{!e&&r.length>0&&t(r[0].name)},[e,r]),m)return s.jsx(c.Spinner,{className:"u-loader",text:"Loading storage pools..."});i&&d.failure("Loading storage pools failed",i);const h=()=>{const a=[];return r&&(r.forEach(n=>{a.push({label:s.jsx(j,{pool:n}),value:n.name,disabled:!1,text:`${n.name} (${n.driver})`})}),r.length===0&&a.unshift({label:"No storage pool available",value:"",disabled:!0})),a},p=a=>{t(a)};return s.jsx(c.CustomSelect,{name:"pool","aria-label":"Storage Pool",searchable:"auto",...o,options:h(),onChange:p,value:e,dropdownClassName:"storage-pool-select-dropdown",header:s.jsx(b,{})})};export{E as S};
