import{d as s,r as g,l as v,j as i,b_ as b,q as n}from"./index-CzUo07dn.js";const q=({project:o,volume:e,onFinish:u,appearance:c="base",hasIcon:h=!0,label:r,classname:m})=>{const f=s.useNotify(),[y,l]=g.useState(!1),a=v(),d=(()=>{var t;if(e.name.includes("/"))return"Go to the instance detail page, to remove this snapshot";if(e.type==="container")return"Go to the instance detail page, to remove this container";if(e.type==="virtual-machine")return"Go to the instance detail page, to remove this virtual-machine";if(e.type==="image")return"Go to the image list, to remove this image";if(e.type!=="custom")return"Only custom volumes can be deleted";if(((t=e.used_by)==null?void 0:t.length)??0)return"Remove all usages of the volume to delete it"})(),p=()=>{l(!0),b(e.name,e.pool,o).then(u).catch(t=>{f.failure("Storage volume deletion failed",t)}).finally(()=>{l(!1),a.invalidateQueries({queryKey:[n.isoVolumes]}),a.invalidateQueries({queryKey:[n.projects,o]}),a.invalidateQueries({queryKey:[n.storage,e.pool,n.volumes,o]}),a.invalidateQueries({predicate:t=>t.queryKey[0]===n.volumes})})};return i.jsxs(s.ConfirmationButton,{loading:y,confirmationModalProps:{title:"Confirm delete",children:i.jsxs("p",{children:["This will permanently delete volume ",i.jsx("b",{children:e.name}),".",i.jsx("br",{}),"This action cannot be undone, and can result in data loss."]}),confirmButtonLabel:"Delete",onConfirm:p},appearance:c,className:m,shiftClickEnabled:!0,showShiftClickHint:!0,disabled:!!d,onHoverText:d,children:[h&&i.jsx(s.Icon,{name:"delete"}),r&&i.jsx("span",{children:r})]})};export{q as D};
