import{j as a}from"./@radix-3bj3otF9.js";import{S as g}from"./refresh-BaK7e0kN.js";import{P as j}from"./Pagination-Du1A_aqP.js";import{S as f}from"./SearchField-Bd1JmJXg.js";import{u as v}from"./all-pipeline-runs-query-DjqFvEha.js";import{V as d,a3 as S,X as b,r as m,Y as N,Z as y,_ as R,$ as k,a0 as P,a1 as u,T as C,ac as T,ab as w,z as o,B as _,a4 as A,e as p}from"./index-Cs2FY84s.js";import{a as F,u as I,b as B}from"./ButtonGroup-C4ao6wx2.js";import{P as D}from"./pipeline-link-W-agDCn-.js";import{L as x,f as E}from"./@react-router-Ct_TgVUW.js";const z=[{id:"select",meta:{width:"1%"},header:({table:e})=>a.jsx(d,{id:"check-all",checked:e.getIsAllRowsSelected(),onCheckedChange:s=>e.toggleAllRowsSelected(s==="indeterminate"?!0:s)}),cell:({row:e})=>a.jsx(d,{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(S,{className:`h-5 w-5 ${b(t)}`}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(x,{to:m.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(N,{children:a.jsxs(y,{children:[a.jsx(R,{className:"hover:text-theme-text-brand hover:underline",children:a.jsx(k,{status:t})}),a.jsx(P,{className:"z-20 capitalize",children:t})]})}),a.jsx(u,{copyText:s})]}),a.jsxs(x,{to:m.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.resources)==null?void 0:s.pipeline)==null?void 0:t.name},cell:({row:e})=>{var r,n,i,c;const s=(n=(r=e.original.resources)==null?void 0:r.pipeline)==null?void 0:n.name,t=(c=(i=e.original.resources)==null?void 0:i.pipeline)==null?void 0:c.id;return!s||!t?null:a.jsx(D,{pipelineId:t,pipelineName:s})}},{id:"stack",header:"Stack",accessorFn:e=>{var s,t,r,n;return{name:(t=(s=e.resources)==null?void 0:s.stack)==null?void 0:t.name,id:(n=(r=e.resources)==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(C,{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(T,{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(w,{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(F,{id:e.original.id})}],l=1,L=o.object({page:o.coerce.number().min(l).optional().default(l).catch(l),name:o.string().optional(),operator:o.enum(["and","or"]).optional(),status:o.enum(["pending","running","completed"]).optional()});function $(){const[e]=E(),{page:s,name:t,operator:r,status:n}=L.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}=I(),n=$(),{data:i,refetch:c}=v({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(B,{}):a.jsx(f,{searchParams:n}),a.jsx("div",{className:"flex justify-between",children:a.jsxs(_,{intent:"primary",emphasis:"subtle",size:"md",onClick:()=>c(),children:[a.jsx(g,{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:i?a.jsx(A,{rowSelection:t,onRowSelectionChange:r,columns:z,getRowId:h=>h.id,data:i.items}):a.jsx(p,{className:"h-[500px] w-full"})}),i?i.total_pages>1&&a.jsx(j,{searchParams:n,paginate:i}):a.jsx(p,{className:"h-[36px] w-[300px]"})]})]})}export{J as R};
