import{j as s}from"./@radix-AvWw-1nd.js";import{S as x}from"./refresh-CupyU1Vs.js";import{S as h,P as j}from"./SearchField-DfNxVtjV.js";import{u as f}from"./all-pipeline-runs-query-B509kMlL.js";import{N as g,r as o,T as b,H as v,J as y,K as N,L as m,M as u,z as i,f as S,O as P,S as p}from"./index-DWoLoYDY.js";import{a as R,b as T,u as k,c as F}from"./RunSelector-CYmRHGdm.js";import{D as w}from"./DisplayDate-C5Aw-Yca.js";import{g as C,E as D}from"./ExecutionStatus-DHiK3Am-.js";import{I as E}from"./InlineAvatar-Bk4QLPTU.js";import{L as l,d as _}from"./@react-router-BUo5vhN4.js";const A=[{id:"check",header:"",meta:{width:"1%"},accessorFn:e=>({id:e.id}),cell:({getValue:e})=>{const{id:a}=e();return s.jsx(R,{id:a})}},{id:"name",header:"Run",accessorFn:e=>{var a;return{id:e.id,name:e.name,status:(a=e.body)==null?void 0:a.status}},cell:({getValue:e})=>{const{name:a,status:t,id:r}=e();return s.jsxs("div",{className:"group/copybutton flex items-center gap-2",children:[s.jsx(g,{className:`h-5 w-5 ${C(t)}`}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(l,{to:o.runs.detail(r),className:"flex items-center gap-1",children:s.jsx("span",{className:"text-text-md font-semibold text-theme-text-primary",children:a})}),s.jsx(b,{children:s.jsxs(v,{children:[s.jsx(y,{className:"hover:text-theme-text-brand hover:underline",children:s.jsx(D,{status:t})}),s.jsx(N,{className:"z-20 capitalize",children:t})]})}),s.jsx(m,{copyText:a})]}),s.jsxs(l,{to:o.runs.detail(r),className:"flex items-center gap-1",children:[s.jsx("p",{className:"text-text-xs text-theme-text-secondary",children:r.split("-")[0]}),s.jsx(m,{copyText:r})]})]})]})}},{id:"pipeline",header:"Pipeline",accessorFn:e=>{var a,t;return(t=(a=e.body)==null?void 0:a.pipeline)==null?void 0:t.name},cell:({getValue:e})=>{const a=e();return a?s.jsx(l,{to:o.pipelines.namespace(a),children:s.jsx(u,{color:"purple",className:"inline-flex items-center gap-0.5 truncate",rounded:!1,emphasis:"subtle",children:a})}):null}},{id:"stack",header:"Stack",accessorFn:e=>{var a,t,r,n;return{name:(t=(a=e.body)==null?void 0:a.stack)==null?void 0:t.name,id:(n=(r=e.body)==null?void 0:r.stack)==null?void 0:n.id}},cell:({getValue:e})=>{const{name:a,id:t}=e();return!a||!t?null:s.jsx(u,{rounded:!1,className:"inline-block",color:"turquoise",emphasis:"subtle",children:a})}},{id:"created-at",header:"Created at",accessorFn:e=>{var a;return{date:(a=e.body)==null?void 0:a.created}},cell:({getValue:e})=>{const{date:a}=e();return s.jsx(w,{dateString:a})}},{id:"author",header:"Author",accessorFn:e=>{var a,t,r,n,d;return{name:((r=(t=(a=e.body)==null?void 0:a.user)==null?void 0:t.body)==null?void 0:r.full_name)||((d=(n=e.body)==null?void 0:n.user)==null?void 0:d.name)}},cell:({getValue:e})=>{const{name:a}=e();return s.jsx(E,{username:a})}},{id:"admin_actions",header:"",meta:{width:"5%"},cell:({row:e})=>s.jsx(T,{id:e.original.id})}],c=1,z=i.object({page:i.coerce.number().min(c).optional().default(c).catch(c),name:i.string().optional(),operator:i.enum(["and","or"]).optional(),status:i.enum(["pending","running","completed"]).optional()});function B(){const[e]=_(),{page:a,name:t,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:a,name:t,logical_operator:r,status:n}}function $({fixedQueryParams:e={}}){const{selectedRuns:a}=k(),t=B(),{data:r,refetch:n}=f({params:{...t,sort_by:"desc:updated",...e}});return s.jsxs("div",{className:"mt-5 flex flex-col gap-5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[a.length?s.jsx(F,{}):s.jsx(h,{searchParams:t}),s.jsx("div",{className:"flex justify-between",children:s.jsxs(S,{intent:"primary",emphasis:"subtle",size:"md",onClick:()=>n(),children:[s.jsx(x,{className:"h-5 w-5 fill-theme-text-brand"}),"Refresh"]})})]}),s.jsxs("div",{className:"flex flex-col items-center gap-5",children:[s.jsx("div",{className:"w-full",children:r?s.jsx(P,{columns:A,data:r.items}):s.jsx(p,{className:"h-[500px] w-full"})}),r?r.total_pages>1&&s.jsx(j,{searchParams:t,paginate:r}):s.jsx(p,{className:"h-[36px] w-[300px]"})]})]})}export{$ as R};
