import{j as a,r as f}from"./@radix-CFOkMR_E.js";import{P as j,m as g,z as o,k as y,l as b,j as P,n as N,F as v,r as i,T as u,h as S,D as k,S as p,o as R}from"./index-KsTz2dHG.js";import{c as T,L as c,g as h}from"./@react-router-CO-OsFwI.js";import{C as x,R as E}from"./CopyButton-B3sWVJ4Z.js";import{a as C}from"./@tanstack-k96lU_C-.js";import{o as F}from"./url-rGEp5Umh.js";import{S as _,P as w}from"./SearchField-CXoBknpt.js";import{S as D}from"./terminal-By9cErXc.js";import{D as A}from"./DisplayDate-DYgIjlDF.js";import{g as I,E as B}from"./ExecutionStatus-9zM7eaLh.js";import{I as q}from"./InlineAvatar-BvBtO2Dp.js";import"./@reactflow-DIYUhKYX.js";import"./copy-BXNk6BjL.js";import"./dots-horizontal-BObFzD5l.js";import"./chevron-right-double-CZBOf6JM.js";import"./check-circle-i56092KI.js";function L({namespace:e}){return a.jsx(j,{children:a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(g,{className:"h-5 w-5 fill-neutral-400"}),a.jsx("h1",{className:"text-display-xs font-semibold",children:decodeURIComponent(e)})]})})}const l=1,U=o.object({page:o.coerce.number().min(l).optional().default(l).catch(l),name:o.string().optional(),operator:o.enum(["and","or"]).optional()});function z(){const[e]=T(),{page:s,name:t,operator:r}=U.parse({page:e.get("page")||void 0,name:e.get("name")||void 0});return{page:s,name:t,logical_operator:r}}function G({params:e}){return["runs",e]}async function H({params:e}){const s=y(b.runs.all+"?"+F(e)),t=await P(s,{method:"GET",headers:{"Content-Type":"application/json"}});if(t.status===404&&N(),!t.ok)throw new v({message:"Error while fetching pipeline runs",status:t.status,statusText:t.statusText});return t.json()}function K(e,s){return C({queryKey:G(e),queryFn:()=>H(e),...s})}function Q(){return[{id:"run",header:"Run",accessorFn:e=>{var s;return{name:e.name,id:e.id,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(D,{className:`h-5 w-5 shrink-0 ${I(t)}`}),a.jsxs("div",{children:[a.jsxs(c,{to:i.runs.detail(r),className:"flex items-center gap-1",children:[a.jsx("h2",{className:"text-text-md font-semibold",children:s}),a.jsx(B,{status:t}),a.jsx(x,{copyText:s})]}),a.jsxs(c,{to:i.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(x,{copyText:r})]})]})]})}},{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(c,{to:i.stacks.overview,children:a.jsx(u,{rounded:!1,className:"inline-block",color:"turquoise",emphasis:"subtle",children:s})})}},{id:"repository",header:"Repository",accessorFn:e=>{var s,t,r,n,m,d;return{name:(r=(t=(s=e.body)==null?void 0:s.code_reference)==null?void 0:t.body)==null?void 0:r.code_repository.name,id:(d=(m=(n=e.body)==null?void 0:n.code_reference)==null?void 0:m.body)==null?void 0:d.code_repository.id}},cell:({getValue:e})=>{const{name:s,id:t}=e();return!s||!t?null:a.jsx("div",{children:a.jsx(u,{rounded:!1,className:"inline-block",color:"grey",emphasis:"subtle",children:s})})}},{id:"created",header:"Created at",accessorFn:e=>{var s;return(s=e.body)==null?void 0:s.created},cell:({getValue:e})=>a.jsx("p",{className:"text-text-sm text-theme-text-secondary",children:a.jsx(A,{dateString:e()})})},{id:"author",header:"Author",accessorFn:e=>{var s;return{author:(s=e.body)==null?void 0:s.user}},cell:({getValue:e})=>{const{author:s}=e();return a.jsx(q,{username:s.name})}}]}function O(){const{namespace:e}=h(),s=z(),t=Q(),{data:r,refetch:n}=K({params:{pipeline_name:decodeURIComponent(e),...s,sort_by:"desc:updated"}},{throwOnError:!0});return a.jsxs("div",{className:"flex flex-col gap-5 p-5",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx(_,{searchParams:s}),a.jsxs(S,{intent:"primary",emphasis:"subtle",size:"md",onClick:()=>n(),children:[a.jsx(E,{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:r?a.jsx(k,{columns:t,data:r.items}):a.jsx(p,{className:"h-[500px] w-full"})}),r?r.total_pages>1&&a.jsx(w,{searchParams:s,paginate:r}):a.jsx(p,{className:"h-[36px] w-[300px]"})]})]})}function ce(){const{namespace:e}=h(),{setCurrentBreadcrumbData:s}=R();return f.useEffect(()=>{e&&s({segment:"pipeline_detail",data:{name:e}})},[e]),a.jsxs("div",{children:[a.jsx(L,{namespace:e}),a.jsx(O,{})]})}export{ce as default};
