| Current Path : /snap/lxd/38768/share/lxd-ui/assets/ |
| Current File : //snap/lxd/38768/share/lxd-ui/assets/DeleteStorageVolumeBtn-Cr5fXZmM.js |
import{u as D,au as l,d as u,r as j,v as C,E as Q,V as q,j as n,s as B,z as R,x as o}from"./index-BsQN_SZU.js";import{h as k}from"./storage-volumes-CG043sqG.js";const G=()=>{const{isFineGrained:a}=D();return{canDeleteVolume:t=>l(a,"can_delete",t?.access_entitlements),canEditVolume:t=>l(a,"can_edit",t?.access_entitlements),canManageStorageVolumeSnapshots:t=>l(a,"can_manage_snapshots",t?.access_entitlements),canManageVolumeBackups:t=>l(a,"can_manage_backups",t?.access_entitlements)}},w=({project:a,volume:e,onFinish:i,appearance:d="base",hasIcon:c=!0,label:t,classname:y,onClose:b})=>{const V=u.useNotify(),[m,h]=j.useState(!1),r=C(),{canDeleteVolume:p}=G(),v=Q(),{hasStorageAndProfileOperations:x}=q(),g=(()=>{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(e.used_by?.length??0)return"Remove all usages of the volume to delete it"})(),f=s=>{V.failure("Storage volume deletion failed",s)},S=()=>{i(),h(!1),r.invalidateQueries({queryKey:[o.isoVolumes]}),r.invalidateQueries({queryKey:[o.projects,a]}),r.invalidateQueries({queryKey:[o.storage,e.pool,o.volumes,a,e.location]}),r.invalidateQueries({predicate:s=>s.queryKey[0]===o.volumes})},E=()=>{h(!0),k(e.name,e.pool,a,e.location).then(s=>{x?v.set(s.metadata.id,i,_=>{f(new Error(_))},S):i()}).catch(f)};return n.jsxs(u.ConfirmationButton,{loading:m,confirmationModalProps:{close:b,title:"Confirm delete",children:n.jsxs("p",{children:["This will permanently delete volume"," ",n.jsx(R,{type:"volume",value:e.name,bold:!0}),".",n.jsx("br",{}),"This action cannot be undone, and can result in data loss."]}),confirmButtonLabel:"Delete",onConfirm:E},appearance:d,className:B("u-no-margin--bottom",y,{"has-icon":c}),shiftClickEnabled:!0,showShiftClickHint:!0,disabled:!p(e)||!!g||m,onHoverText:p(e)?g:"You do not have permission to delete this volume.",children:[c&&n.jsx(u.Icon,{name:"delete"}),t&&n.jsx("span",{children:t})]})};export{w as D,G as u};