import{j as t,S as r,h as l,a1 as u}from"./vendor-ClLR6ncd.js";import{d as c}from"./Cancel-BcN7wjUl.js";import{E as d,d as p,ar as m,i,o as x,L as h}from"./index-OtVJl4GC.js";import{E as n}from"./Messages-BRmQDxrZ.js";import{S as b}from"./SyncingMessage-Y9_Q8a92.js";import{a as f}from"./TypographyWithTooltip-BFAG3Va9.js";import"./lodash-ZyeDnt0e.js";import{T as g,a as j,u as y}from"./ui-erh8p_Di.js";import"./usePrevious-BP64N3hu.js";import"./OptionallyDenseMuiTable-D7b58l1V.js";import"./TableContainer-CN5gAdqf.js";import"./TableRow-CGDSOtFZ.js";import"./TableSortLabel-BJFq2axQ.js";const a=["admin","jobs"];function w(){return p(e=>{const o=new URL("/jobs",window.origin);return o.searchParams.append("jobId",e),i({url:o.toString(),method:"delete"})},{onSuccess:()=>{m.invalidateQueries(a)}})}const S=({catalog:e,name:o})=>e?`${e}/${o}`:o||"";function v(){return d(a,async()=>(await i({url:"/jobs"})).map(e=>({...e,ageInSeconds:Math.round(e.ageInSeconds),origin:S(e)})),{refetchInterval:5e3})}function s({str:e}){return t.jsx(f,{value:e,originalValue:e})}function C({row:e}){const{stopJobMutation:o}=y();return t.jsx(u,{disabled:o.isLoading,onClick:()=>o.mutate(e.uuid),children:t.jsx(c,{})})}const T=[{label:"Kind",key:"kind",sx:{width:"100px"}},{label:"Origin",key:"origin",sx:{width:"25%",maxWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},Component:s},{label:"Status",key:"status",sx:{width:"150px"}},{label:"Description",key:"description",Component:s,sx:{maxWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{label:"Active time (s)",key:"ageInSeconds",sx:{width:"170px"}},{label:"Cancel",sortable:!1,Component:C}],k={sx:{tableLayout:"fixed"}};function J({jobs:e}){const o=w();return t.jsxs(t.Fragment,{children:[t.jsx(n,{error:o.error,resetError:o.reset}),t.jsx(g,{value:{stopJobMutation:o},children:t.jsx(j,{rows:e,uniqueRowKey:"uuid",columns:T,tableProps:k,emptyRowsTitle:"There are no running jobs",initSortingColumn:"origin"})})]})}const E="Jobs";function D(){const e=v(),o=x();return e.isLoading?t.jsx("div",{style:{display:"flex",alignItems:"center",flexGrow:1},children:t.jsx(h,{})}):t.jsxs(r,{spacing:o,children:[t.jsxs(r,{direction:"row",spacing:4,children:[t.jsx(l,{variant:"h4",children:E}),t.jsx(b,{isFetching:e.isFetching,entityKind:"jobs"})]}),e.isError?t.jsx(n,{error:e.error,resetError:()=>{}}):t.jsx(J,{jobs:e.data})]})}export{D as default};
