Your IP : 216.73.216.189


Current Path : /proc/thread-self/root/snap/lxd/current/share/lxd-ui/assets/
Upload File :
Current File : //proc/thread-self/root/snap/lxd/current/share/lxd-ui/assets/DeleteStorageVolumeBtn-DIlt1DOO.js

import{u as D,B as l,d as u,r as j,t as B,J as C,K as Q,j as n,s as q,y as K,w as o}from"./index-BFGypnt-.js";import{h as R}from"./storage-volumes-CNe_c3nC.js";const k=()=>{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)}},L=({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=B(),{canDeleteVolume:p}=k(),v=C(),{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})},_=()=>{h(!0),R(e.name,e.pool,a,e.location).then(s=>{x?v.set(s.metadata.id,i,E=>{f(new Error(E))},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(K,{type:"volume",value:e.name,bold:!0}),".",n.jsx("br",{}),"This action cannot be undone, and can result in data loss."]}),confirmButtonLabel:"Delete",onConfirm:_},appearance:d,className:q("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{L as D,k as u};