0x1949 Team - FAZEMRX - MANAGER
Edit File: OperationList-b576a26c.js
import{j as e,aA as y,I as S,d as c,f as b,W as d,B as I,b as w,L as F,q as O}from"./index-13b2882d.js";import{C as R,a as v}from"./CancelOperationBtn-5e4a9f41.js";import{a as u,g as A}from"./operations-beb03b33.js";const L=({operation:a})=>{const t=u(a),n=A(a);if(!n)return null;const i=["Restarting instance","Starting instance","Stopping instance","Unfreezing instance","Freezing instance","Snapshotting instance","Restoring snapshot","Updating instance","Renaming instance","Executing command","Showing console"];return(a.status==="Success"&&a.description==="Creating instance"||i.includes(a.description))&&t?e.jsx(y,{instance:{name:n,project:t}}):e.jsx(S,{item:{name:n}})},k=()=>{const a=c.useNotify(),{data:t,error:n,isLoading:i}=b({queryKey:[O.operations],queryFn:v});n&&a.failure("Loading operations failed",n);const l=(t==null?void 0:t.failure)??[],g=(t==null?void 0:t.running)??[],j=(t==null?void 0:t.success)??[],r=l.concat(g).concat(j),x=[{content:"Time",className:"time",sortKey:"created_at"},{content:"Action",className:"action",sortKey:"action"},{content:"Info",className:"info"},{content:"Status",className:"status",sortKey:"status"},{"aria-label":"Actions",className:"cancel u-align--right"}],h=s=>({Cancelled:"status-failed-small",Failure:"status-failed-small",Running:"status-in-progress-small",Success:"status-succeeded-small"})[s],N=r.map(s=>{const o=u(s);return{columns:[{content:e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:["Initiated: ",d(s.created_at)]}),e.jsxs("div",{className:"u-text--muted",children:["Last update: ",d(s.updated_at)]})]}),role:"rowheader","aria-label":"Time",className:"time"},{content:e.jsxs(e.Fragment,{children:[e.jsx("div",{children:s.description}),e.jsx("div",{className:"u-truncate u-text--muted",children:e.jsx(L,{operation:s})}),e.jsxs("div",{className:"u-text--muted u-truncate",title:o,children:["Project: ",o]})]}),role:"rowheader","aria-label":"Action",className:"action"},{content:e.jsxs(e.Fragment,{children:[e.jsx("div",{children:s.err}),Object.entries(s.metadata??{}).map(([f,m],p)=>e.jsxs("span",{title:JSON.stringify(m),children:[f,": ",JSON.stringify(m)]},p))]}),role:"rowheader","aria-label":"Info",className:"info"},{content:e.jsxs(e.Fragment,{children:[e.jsx(c.Icon,{name:h(s.status),className:"status-icon"}),s.status]}),role:"rowheader","aria-label":"Status",className:"status"},{content:e.jsx(R,{operation:s}),role:"rowheader",className:"u-align--right cancel","aria-label":"Actions"}],sortData:{created_at:s.created_at,action:s.description,status:s.status}}});return e.jsx(e.Fragment,{children:e.jsxs(I,{title:"Ongoing operations",children:[e.jsx(w,{}),e.jsxs(c.Row,{children:[r.length>0&&e.jsx(c.MainTable,{headers:x,rows:N,paginate:30,responsive:!0,sortable:!0,className:"operation-list",emptyStateMsg:i?e.jsx(F,{text:"Loading operations..."}):"No data to display"}),!i&&r.length===0&&e.jsx(c.EmptyState,{className:"empty-state",image:e.jsx(c.Icon,{name:"status",className:"empty-state-icon"}),title:"No operations found",children:e.jsx("p",{children:"There are no ongoing operations."})})]})]})})};export{k as default};