import{j as t}from"./@radix-Cdvw4jJ8.js";import{S as j}from"./refresh-BcTM09NW.js";import{P as f}from"./Pagination-CWnEpSpN.js";import{S as v}from"./SearchField-BtUi6cYl.js";import{u as S}from"./all-pipeline-runs-query-DpKw9WL9.js";import{C as m,r as l,T as b,q as N,s as y,t as R,v as u,w as p,G as k,z as i,B as C,x as w,g as x}from"./index-BgEfQ3_G.js";import{R as P,u as T,a as F}from"./ButtonGroup-4sPZDv70.js";import{S as A}from"./terminal-XFL_4QN-.js";import{D}from"./DisplayDate-8RESqe5H.js";import{g as E,E as B}from"./ExecutionStatus-BuhNAE9w.js";import{L as c,f as I}from"./@react-router-DeDfXbUF.js";const _=[{id:"select",meta:{width:"1%"},header:({table:e})=>t.jsx(m,{id:"check-all",checked:e.getIsAllRowsSelected(),onCheckedChange:s=>e.toggleAllRowsSelected(s==="indeterminate"?!0:s)}),cell:({row:e})=>t.jsx(m,{id:`check-${e.id}`,checked:e.getIsSelected(),onCheckedChange:e.getToggleSelectedHandler()})},{id:"name",header:"Run",accessorFn:e=>{var s;return{id:e.id,name:e.name,status:(s=e.body)==null?void 0:s.status}},cell:({getValue:e})=>{const{name:s,status:a,id:r}=e();return t.jsxs("div",{className:"group/copybutton flex items-center gap-2",children:[t.jsx(A,{className:`h-5 w-5 ${E(a)}`}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(c,{to:l.projects.runs.detail(r),className:"flex items-center gap-1",children:t.jsx("span",{className:"text-text-md font-semibold text-theme-text-primary",children:s})}),t.jsx(b,{children:t.jsxs(N,{children:[t.jsx(y,{className:"hover:text-theme-text-brand hover:underline",children:t.jsx(B,{status:a})}),t.jsx(R,{className:"z-20 capitalize",children:a})]})}),t.jsx(u,{copyText:s})]}),t.jsxs(c,{to:l.projects.runs.detail(r),className:"flex items-center gap-1",children:[t.jsx("p",{className:"text-text-xs text-theme-text-secondary",children:r.split("-")[0]}),t.jsx(u,{copyText:r})]})]})]})}},{id:"pipeline",header:"Pipeline",accessorFn:e=>{var s,a;return(a=(s=e.body)==null?void 0:s.pipeline)==null?void 0:a.name},cell:({getValue:e})=>{const s=e();return s?t.jsx(c,{to:l.projects.pipelines.namespace(s),children:t.jsx(p,{color:"purple",className:"inline-flex items-center gap-0.5 truncate",rounded:!1,emphasis:"subtle",children:s})}):null}},{id:"stack",header:"Stack",accessorFn:e=>{var s,a,r,n;return{name:(a=(s=e.body)==null?void 0:s.stack)==null?void 0:a.name,id:(n=(r=e.body)==null?void 0:r.stack)==null?void 0:n.id}},cell:({getValue:e})=>{const{name:s,id:a}=e();return!s||!a?null:t.jsx(p,{rounded:!1,className:"inline-block",color:"turquoise",emphasis:"subtle",children:s})}},{id:"created-at",header:"Created at",accessorFn:e=>{var s;return{date:(s=e.body)==null?void 0:s.created}},cell:({getValue:e})=>{const{date:s}=e();return t.jsx(D,{dateString:s})}},{id:"author",header:"Author",accessorFn:e=>{var s,a;return{name:(a=(s=e.resources)==null?void 0:s.user)==null?void 0:a.name}},cell:({getValue:e})=>{const{name:s}=e();return s?t.jsx(k,{username:s}):null}},{id:"admin_actions",header:"",meta:{width:"5%"},cell:({row:e})=>t.jsx(P,{id:e.original.id})}],d=1,z=i.object({page:i.coerce.number().min(d).optional().default(d).catch(d),name:i.string().optional(),operator:i.enum(["and","or"]).optional(),status:i.enum(["pending","running","completed"]).optional()});function q(){const[e]=I(),{page:s,name:a,operator:r,status:n}=z.parse({page:e.get("page")||void 0,name:e.get("name")||void 0,operator:e.get("operator")||void 0,status:e.get("status")||void 0});return{page:s,name:a,logical_operator:r,status:n}}function W({fixedQueryParams:e={}}){const{selectedRowCount:s,rowSelection:a,setRowSelection:r}=T(),n=q(),{data:o,refetch:h}=S({params:{...n,sort_by:"desc:updated",...e}});return t.jsxs("div",{className:"flex flex-col gap-5 pt-5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[s?t.jsx(F,{}):t.jsx(v,{searchParams:n}),t.jsx("div",{className:"flex justify-between",children:t.jsxs(C,{intent:"primary",emphasis:"subtle",size:"md",onClick:()=>h(),children:[t.jsx(j,{className:"h-5 w-5 fill-theme-text-brand"}),"Refresh"]})})]}),t.jsxs("div",{className:"flex flex-col items-center gap-5",children:[t.jsx("div",{className:"w-full",children:o?t.jsx(w,{rowSelection:a,onRowSelectionChange:r,columns:_,getRowId:g=>g.id,data:o.items}):t.jsx(x,{className:"h-[500px] w-full"})}),o?o.total_pages>1&&t.jsx(f,{searchParams:n,paginate:o}):t.jsx(x,{className:"h-[36px] w-[300px]"})]})]})}export{W as R};
