import{j as a}from"./@radix-B1sy0Lhr.js";import{S as j}from"./refresh-C8BXS3Fb.js";import{P as f}from"./Pagination-C1sE5Nzn.js";import{S as v}from"./SearchField-Byv1PtST.js";import{u as S}from"./all-pipeline-runs-query-CdvWtiAY.js";import{Q as m,r as c,R as b,U as y,V as N,W as R,X as u,T as p,a2 as k,z as i,B as C,Y as w,d as x}from"./index-CO6UN3UX.js";import{R as P,u as T,a as A}from"./ButtonGroup-DVhzbQxV.js";import{S as F}from"./terminal-C2tAF2XG.js";import{D as _}from"./DisplayDate-57lUNS79.js";import{g as D,E}from"./ExecutionStatus-CQbWovhV.js";import{L as l,f as B}from"./@react-router-CHjLNlgw.js";const I=[{id:"select",meta:{width:"1%"},header:({table:e})=>a.jsx(m,{id:"check-all",checked:e.getIsAllRowsSelected(),onCheckedChange:s=>e.toggleAllRowsSelected(s==="indeterminate"?!0:s)}),cell:({row:e})=>a.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:t,id:r}=e();return a.jsxs("div",{className:"group/copybutton flex items-center gap-2",children:[a.jsx(F,{className:`h-5 w-5 ${D(t)}`}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(l,{to:c.projects.runs.detail(r),className:"flex items-center gap-1",children:a.jsx("span",{className:"text-text-md font-semibold text-theme-text-primary",children:s})}),a.jsx(b,{children:a.jsxs(y,{children:[a.jsx(N,{className:"hover:text-theme-text-brand hover:underline",children:a.jsx(E,{status:t})}),a.jsx(R,{className:"z-20 capitalize",children:t})]})}),a.jsx(u,{copyText:s})]}),a.jsxs(l,{to:c.projects.runs.detail(r),className:"flex items-center gap-1",children:[a.jsx("p",{className:"text-text-xs text-theme-text-secondary",children:r.split("-")[0]}),a.jsx(u,{copyText:r})]})]})]})}},{id:"pipeline",header:"Pipeline",accessorFn:e=>{var s,t;return(t=(s=e.body)==null?void 0:s.pipeline)==null?void 0:t.name},cell:({getValue:e})=>{const s=e();return s?a.jsx(l,{to:c.projects.pipelines.namespace(s),children:a.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,t,r,n;return{name:(t=(s=e.body)==null?void 0:s.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:s,id:t}=e();return!s||!t?null:a.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 a.jsx(_,{dateString:s})}},{id:"author",header:"Author",accessorFn:e=>{var s,t;return{name:(t=(s=e.resources)==null?void 0:s.user)==null?void 0:t.name}},cell:({row:e})=>{var t,r,n;const s=(t=e.original.resources)==null?void 0:t.user;return s?a.jsx(k,{avatarUrl:((r=s.body)==null?void 0:r.avatar_url)??void 0,username:s.name,isServiceAccount:!!((n=s.body)!=null&&n.is_service_account)}):null}},{id:"admin_actions",header:"",meta:{width:"5%"},cell:({row:e})=>a.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 L(){const[e]=B(),{page:s,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:s,name:t,logical_operator:r,status:n}}function J({fixedQueryParams:e={}}){const{selectedRowCount:s,rowSelection:t,setRowSelection:r}=T(),n=L(),{data:o,refetch:h}=S({params:{...n,sort_by:"desc:updated",...e}});return a.jsxs("div",{className:"flex flex-col gap-5 pt-5",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[s?a.jsx(A,{}):a.jsx(v,{searchParams:n}),a.jsx("div",{className:"flex justify-between",children:a.jsxs(C,{intent:"primary",emphasis:"subtle",size:"md",onClick:()=>h(),children:[a.jsx(j,{className:"h-5 w-5 fill-theme-text-brand"}),"Refresh"]})})]}),a.jsxs("div",{className:"flex flex-col items-center gap-5",children:[a.jsx("div",{className:"w-full",children:o?a.jsx(w,{rowSelection:t,onRowSelectionChange:r,columns:I,getRowId:g=>g.id,data:o.items}):a.jsx(x,{className:"h-[500px] w-full"})}),o?o.total_pages>1&&a.jsx(f,{searchParams:n,paginate:o}):a.jsx(x,{className:"h-[36px] w-[300px]"})]})]})}export{J as R};
