import{t as u,j as r,s as y}from"./index-B-YXshIJ.js";import{b as p,c as d,e as c}from"./index-Brfj1MB8.js";import{D as f}from"./DrawerTabs-DX5akTbP.js";import{b as x}from"./query-hooks-C0Pc4MKj.js";import{S as i}from"./SortableTable-CuxGNXdn.js";import{d as b}from"./sseUrlConfigs-D9i3tP2o.js";import{H as j,S as k}from"./Empty-xeDFYrAd.js";import"./TabPanel-CcfErYAk.js";import"./AnimateHeight-DPr6lKJ-.js";import"./Icons-C9UDsqhh.js";import"./TinyAreaGraph-CpO36t7S.js";import"./Drawer-B-IR3T8V.js";import"./dialog-hooks-DGvq_AFU.js";import"./Filters-DsROmhj9.js";import"./MultiSelectDropdown-B42s6W_W.js";import"./react-select.esm-OagQDocY.js";import"./extends-vRGLuScH.js";const C=({item:a,pipelineType:o})=>{const t=x(),s=u.builds.getPipeLineBuildStatsForRepo.useQuery({queryContext:t,repositoryId:a.repositoryId,pipelineType:o});return r.jsx(i,{variant:"drawer",data:s.data,rowKey:e=>e.definitionId,isChild:!0,columns:[{title:"Name",key:"name",value:e=>r.jsxs(r.Fragment,{children:[r.jsx("a",{className:"link-text",href:e.definitionUrl.replace("/_apis/build/Definitions/","/_build?definitionId=").replace(/\?revision=(.*)/,""),target:"_blank",rel:"noreferrer",children:e.definitionName}),o===void 0&&!e.isYaml?r.jsx("span",{className:["inline-block ml-2 uppercase text-xs px-2 py-1 bg-red-100","rounded-sm text-red-400 font-semibold no-underline"].join(" "),children:"UI"}):null]}),sorter:p(e=>e.definitionName.toLocaleLowerCase())},{title:"Runs in the last 90 days",key:"runs",value:e=>e.buildsCount,sorter:d(e=>e.buildsCount)},{title:"Last used",key:"last-used-date",value:e=>e.latestBuildTimestamp?"".concat(y(new Date(e.latestBuildTimestamp)),", ").concat(new Date(e.latestBuildTimestamp).getFullYear()):"_",sorter:c(e=>e.latestBuildTimestamp||new Date(0))}],defaultSortColumnIndex:1})},m=a=>{const o=a==="yaml"?t=>t.yaml:a==="non-yaml"?t=>t.nonYaml:t=>t.total;return{rowKey:t=>t.repositoryId,variant:"drawer",columns:[{title:"Repositories",key:"repos",value:t=>t.name,sorter:p(t=>t.name.toLocaleLowerCase())},...a?[]:[{title:"Not using YAML",key:"non-yaml",value:t=>t.nonYaml,sorter:d(t=>t.nonYaml)}],{title:"Pipelines",key:"pipelines",value:o,sorter:d(o)}],ChildComponent:({item:t})=>r.jsx(C,{item:t,pipelineType:a}),defaultSortColumnIndex:1}},_=({totalPipelines:a,yamlPipelines:o})=>{const t=b(),s=u.repos.getRepoListingWithPipelineCount.useQuery({queryContext:t.queryContext,searchTerms:t.searchTerms,teams:t.teams});return r.jsx(f,{tabs:[{title:"Not using YAML (".concat(a-o,")"),key:"non-yaml",BodyComponent:()=>{var n;const e=(n=s==null?void 0:s.data)==null?void 0:n.filter(l=>l.nonYaml>0);return(e==null?void 0:e.length)===0?r.jsx("div",{className:"my-32",children:r.jsx(j,{body:"Looks like all repositories are using YAML pipelines"})}):r.jsx(i,{data:e,...m("non-yaml")})}},{title:"Using YAML (".concat(o,")"),key:"yaml",BodyComponent:()=>{var n;const e=(n=s==null?void 0:s.data)==null?void 0:n.filter(l=>l.yaml>0);return(e==null?void 0:e.length)===0?r.jsx("div",{className:"my-32",children:r.jsx(k,{heading:"No repositories found",body:"There are currently no repositories using YAML pipelines"})}):r.jsx(i,{data:e,...m("yaml")})}},{title:"All pipelines (".concat(a,")"),key:"all",BodyComponent:()=>r.jsx(i,{data:s==null?void 0:s.data,...m()})}]})};export{_ as default};
