import{f as b,d as o,k as h,r as y,l as j,j as e,z as x,bX as S,q as v}from"./index-Cziemgsu.js";import{I as C}from"./ItemName-CywOV74d.js";import{u as D}from"./useSmallScreen-D8fuSDvX.js";import{R as N}from"./ResourceLabel-C4flS097.js";const T=({pool:t,project:l,shouldExpand:s=!1})=>{var r;const a=D(),c=b(),d=o.useNotify(),m=h(),[u,n]=y.useState(!1),f=j(),g=()=>{n(!0),S(t.name).then(()=>{f.invalidateQueries({queryKey:[v.storage]}),c(`/ui/project/${l}/storage/pools`),m.success(e.jsxs(e.Fragment,{children:["Storage pool ",e.jsx(N,{bold:!0,type:"pool",value:t.name})," ","deleted."]}))}).catch(p=>{n(!1),d.failure("Storage pool deletion failed",p)})},i=(((r=t.used_by)==null?void 0:r.length)??0)>0?"Storage pool is in use":void 0;return e.jsxs(o.ConfirmationButton,{confirmationModalProps:{title:"Confirm delete",children:e.jsxs("p",{children:["This will permanently delete storage ",e.jsx(C,{item:t,bold:!0}),".",e.jsx("br",{}),"This action cannot be undone, and can result in data loss."]}),confirmButtonLabel:"Delete pool",onConfirm:g,message:"Delete storage"},appearance:s?"default":"base",className:x("u-no-margin--bottom",{"is-dense":!s,"has-icon":!a}),loading:u,shiftClickEnabled:!0,showShiftClickHint:!0,disabled:!!i,onHoverText:i,children:[(!a||!s)&&e.jsx(o.Icon,{name:"delete"}),s&&e.jsx("span",{children:"Delete pool"})]})};export{T as D};
