/
snap
/
lxd
/
36883
/
share
/
lxd-ui
/
assets
/
File Upload :
llllll
Current File: //snap/lxd/36883/share/lxd-ui/assets/DeleteStorageVolumeBtn-BmZXpQg5.js
import{u as j,ah as c,d,r as q,l as C,t as Q,G as B,j as s,v as G,n as R,q as i}from"./index-B3cgCbnJ.js";import{h as k}from"./storage-volumes-BlpH9Ab1.js";const K=()=>{const{isFineGrained:a}=j();return{canDeleteVolume:e=>c(a,"can_delete",e==null?void 0:e.access_entitlements),canEditVolume:e=>c(a,"can_edit",e==null?void 0:e.access_entitlements),canManageStorageVolumeSnapshots:e=>c(a,"can_manage_snapshots",e==null?void 0:e.access_entitlements),canManageVolumeBackups:e=>c(a,"can_manage_backups",e==null?void 0:e.access_entitlements)}},T=({project:a,volume:t,onFinish:o,appearance:u="base",hasIcon:l=!0,label:e,classname:y,onClose:b})=>{const V=d.useNotify(),[h,m]=q.useState(!1),r=C(),{canDeleteVolume:p}=K(),x=Q(),{hasStorageAndProfileOperations:S}=B(),g=(()=>{var n;if(t.name.includes("/"))return"Go to the instance detail page, to remove this snapshot";if(t.type==="container")return"Go to the instance detail page, to remove this container";if(t.type==="virtual-machine")return"Go to the instance detail page, to remove this virtual-machine";if(t.type==="image")return"Go to the image list, to remove this image";if(t.type!=="custom")return"Only custom volumes can be deleted";if(((n=t.used_by)==null?void 0:n.length)??0)return"Remove all usages of the volume to delete it"})(),f=n=>{V.failure("Storage volume deletion failed",n)},_=()=>{o(),m(!1),r.invalidateQueries({queryKey:[i.isoVolumes]}),r.invalidateQueries({queryKey:[i.projects,a]}),r.invalidateQueries({queryKey:[i.storage,t.pool,i.volumes,a,t.location]}),r.invalidateQueries({predicate:n=>n.queryKey[0]===i.volumes})},E=()=>{m(!0),k(t.name,t.pool,a,t.location).then(n=>{S?x.set(n.metadata.id,o,D=>{f(new Error(D))},_):o()}).catch(f)};return s.jsxs(d.ConfirmationButton,{loading:h,confirmationModalProps:{close:b,title:"Confirm delete",children:s.jsxs("p",{children:["This will permanently delete volume"," ",s.jsx(R,{type:"volume",value:t.name,bold:!0}),".",s.jsx("br",{}),"This action cannot be undone, and can result in data loss."]}),confirmButtonLabel:"Delete",onConfirm:E},appearance:u,className:G("u-no-margin--bottom",y,{"has-icon":l}),shiftClickEnabled:!0,showShiftClickHint:!0,disabled:!p(t)||!!g||h,onHoverText:p(t)?g:"You do not have permission to delete this volume.",children:[l&&s.jsx(d.Icon,{name:"delete"}),e&&s.jsx("span",{children:e})]})};export{T as D,K as u};
Copyright ©2k19 -
Hexid
|
Tex7ure