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/DeleteStoragePoolBtn-BWh9dpGZ.js

import{u as N,B as f,O as E,c as w,a1 as B,d as i,r as T,t as _,K as $,J as F,j as e,s as I,y as g,R as h,w as L}from"./index-BFGypnt-.js";import{R as O}from"./useStoragePools-qBtKr1j9.js";import{S as Q}from"./StoragePoolRichChip-CxRTjvv2.js";const k=()=>{const{isFineGrained:t}=N();return{canDeletePool:s=>f(t,"can_delete",s?.access_entitlements),canEditPool:s=>f(t,"can_edit",s?.access_entitlements)}},K=({pool:t,project:a,shouldExpand:n=!1})=>{const s=E(),S=w(),y=B(),j=i.useNotify(),l=i.useToastNotification(),[c,r]=T.useState(!1),x=_(),{canDeletePool:b}=k(),{hasStorageAndNetworkOperations:C}=$(),D=F(),P=o=>{l.success(e.jsxs(e.Fragment,{children:["Storage pool ",e.jsx(g,{bold:!0,type:"pool",value:o})," ","deleted."]}))},u=()=>{x.invalidateQueries({queryKey:[L.storage]})},d=()=>{u();const o=`${h}/ui/project/${encodeURIComponent(a)}/storage/pool/${encodeURIComponent(t.name)}`;y.pathname.startsWith(o)&&S(`${h}/ui/project/${encodeURIComponent(a)}/storage/pools`),P(t.name)},m=o=>{u(),r(!1),j.failure(`Deleting storage pool ${t.name} failed`,o)},v=()=>{r(!0),O(t.name).then(o=>{C?(l.info(e.jsxs(e.Fragment,{children:["Deletion of storage pool"," ",e.jsx(Q,{poolName:t.name,projectName:a})," ","has started."]})),D.set(o.metadata.id,()=>{r(!1),d()},R=>{m(new Error(R))})):d()}).catch(o=>{m(o)})},p=()=>{if(!b(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(i.ConfirmationButton,{confirmationModalProps:{title:"Confirm delete",children:e.jsxs("p",{children:["This will permanently delete storage pool"," ",e.jsx(g,{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:v,message:"Delete storage"},appearance:n?"default":"base",className:I("u-no-margin--bottom",{"is-dense":!n,"has-icon":!s}),loading:c,shiftClickEnabled:!0,showShiftClickHint:!0,disabled:!!p()||c,onHoverText:p(),children:[(!s||!n)&&e.jsx(i.Icon,{name:"delete"}),n&&e.jsx("span",{children:"Delete pool"})]})};export{K as D,k as u};