AlaK4X
Linux lhjmq-records 5.15.0-118-generic #128-Ubuntu SMP Fri Jul 5 09:28:59 UTC 2024 x86_64



Your IP : 18.223.238.150


Current Path : /snap/lxd/31333/share/lxd-ui/assets/
Upload File :
Current File : //snap/lxd/31333/share/lxd-ui/assets/CancelOperationBtn-5e4a9f41.js

import{v as i,d as l,r as m,i as f,j as c,q as u}from"./index-13b2882d.js";const h=e=>{var n,a,s;const t=(r,o)=>new Date(o.created_at).getTime()-new Date(r.created_at).getTime();(n=e.failure)==null||n.sort(t),(a=e.success)==null||a.sort(t),(s=e.running)==null||s.sort(t)},y=e=>new Promise((t,n)=>{fetch(`/1.0/operations?project=${e}&recursion=1`).then(i).then(a=>(h(a.metadata),t(a.metadata))).catch(n)}),g=()=>new Promise((e,t)=>{fetch("/1.0/operations?all-projects=true&recursion=1").then(i).then(n=>(h(n.metadata),e(n.metadata))).catch(t)}),p=e=>new Promise((t,n)=>{fetch(`/1.0/operations/${e}`,{method:"DELETE"}).then(i).then(t).catch(n)}),w=({operation:e,project:t})=>{const n=l.useNotify(),[a,s]=m.useState(!1),r=f(),o=()=>{s(!0),p(e.id).then(()=>{n.success("Operation cancelled")}).catch(d=>{n.failure("Operation cancellation failed",d)}).finally(()=>{s(!1),r.invalidateQueries({queryKey:t?[u.operations,t]:[u.operations]})})};return e.status!=="Running"?null:c.jsx(l.ConfirmationButton,{onHoverText:e.may_cancel?"Cancel operation":"Cannot cancel operation at this stage",className:"u-no-margin--bottom",loading:a,disabled:!e.may_cancel,confirmationModalProps:{title:"Confirm cancel",children:c.jsx("p",{children:"This will cancel the operation."}),confirmButtonLabel:"Cancel operation",onConfirm:o,cancelButtonLabel:"Go back"},shiftClickEnabled:!0,showShiftClickHint:!0,children:c.jsx("span",{children:"Cancel"})})};export{w as C,g as a,y as f};