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