import{u as j,ai as u,w as p,k as x,d as o,r as S,h as D,j as t,s as P,l as d,dm as v,q as C}from"./index-lOezWVmi.js";const B=()=>{const{isFineGrained:s}=j();return{canDeletePool:e=>u(s,"can_delete",e==null?void 0:e.access_entitlements),canEditPool:e=>u(s,"can_edit",e==null?void 0:e.access_entitlements)}},N=({pool:s,project:i,shouldExpand:n=!1})=>{const e=p(),m=x(),f=o.useNotify(),g=o.useToastNotification(),[l,r]=S.useState(!1),h=D(),{canDeletePool:y}=B(),b=()=>{r(!0),v(s.name).then(()=>{h.invalidateQueries({queryKey:[C.storage]}),m(`/ui/project/${encodeURIComponent(i)}/storage/pools`),g.success(t.jsxs(t.Fragment,{children:["Storage pool ",t.jsx(d,{bold:!0,type:"pool",value:s.name})," ","deleted."]}))}).catch(a=>{r(!1),f.failure("Storage pool deletion failed",a)})},c=()=>{var a;if(!y(s))return"You do not have permission to delete this storage pool";if(((a=s.used_by)==null?void 0:a.length)??!1)return"Storage pool is in use"};return t.jsxs(o.ConfirmationButton,{confirmationModalProps:{title:"Confirm delete",children:t.jsxs("p",{children:["This will permanently delete storage pool"," ",t.jsx(d,{type:"pool",value:s.name,bold:!0}),".",t.jsx("br",{}),"This action cannot be undone, and can result in data loss."]}),confirmButtonLabel:"Delete pool",onConfirm:b,message:"Delete storage"},appearance:n?"default":"base",className:P("u-no-margin--bottom",{"is-dense":!n,"has-icon":!e}),loading:l,shiftClickEnabled:!0,showShiftClickHint:!0,disabled:!!c()||l,onHoverText:c(),children:[(!e||!n)&&t.jsx(o.Icon,{name:"delete"}),n&&t.jsx("span",{children:"Delete pool"})]})};export{N as D,B as u};
