@@ -12,6 +12,7 @@ import { ErrorFallback } from "../../Error";
1212import Github from "@/assets/icons/github.svg?react" ;
1313import { CopyButton } from "@/components/CopyButton" ;
1414import { transformToEllipsis } from "@/lib/strings" ;
15+ import { useCodeRepository } from "@/data/code-repositories/code-repositories-detail-query" ;
1516
1617type Props = {
1718 stepId : string ;
@@ -26,6 +27,15 @@ export function StepDetailsTab({ stepId, runId }: Props) {
2627 const { data, isError, isPending, error } = useStepDetail ( { stepId } ) ;
2728 const { data : pipelineRunData } = usePipelineRun ( { runId } ) ;
2829
30+ const repository = pipelineRunData ?. body ?. code_reference ?. body ?. code_repository ;
31+
32+ const { data : codeRepositoryData } = useCodeRepository (
33+ { repositoryId : repository ?. id as string } ,
34+ { throwOnError : true , enabled : ! ! repository ?. id }
35+ ) ;
36+
37+ const repositoryMetadata = codeRepositoryData ?. metadata ?. config ;
38+
2939 if ( isError ) return < ErrorFallback err = { error } /> ;
3040 if ( isPending ) return < Skeleton className = "h-[300px] w-full" /> ;
3141
@@ -36,6 +46,32 @@ export function StepDetailsTab({ stepId, runId }: Props) {
3646 const enable_artifact_metadata = data . metadata ?. config ?. enable_artifact_metadata ;
3747 const enable_artifact_visualization = data . metadata ?. config ?. enable_artifact_visualization ;
3848
49+ const getRepositoryLink = ( ) => {
50+ let name : string = repository ?. name as string ;
51+ let url : string | null = "" ;
52+
53+ if ( repository ?. body ?. source ?. attribute === "GitHubCodeRepository" ) {
54+ name = `${ repositoryMetadata ?. owner } /${ repositoryMetadata ?. repository } ` ;
55+ url = `https://www.github.com/${ name } ` ;
56+ } else if ( repository ?. body ?. source ?. attribute === "GitLabCodeRepository" ) {
57+ name = `${ repositoryMetadata ?. group } /${ repositoryMetadata ?. project } ` ;
58+ url = `https://www.gitlab.com/${ name } ` ;
59+ }
60+
61+ return (
62+ < a
63+ target = "_blank"
64+ rel = "noopener noreferrer"
65+ className = { `flex items-center ${ url ? "" : "pointer-events-none" } ` }
66+ onClick = { ( e ) => e . stopPropagation ( ) }
67+ href = { url }
68+ >
69+ < Github className = "mr-1 h-5 w-5 fill-theme-text-brand" />
70+ { name }
71+ </ a >
72+ ) ;
73+ } ;
74+
3975 return (
4076 < CollapsibleCard initialOpen title = "Details" >
4177 < dl className = "grid grid-cols-1 gap-x-[10px] gap-y-2 md:grid-cols-3 md:gap-y-4" >
@@ -112,7 +148,7 @@ export function StepDetailsTab({ stepId, runId }: Props) {
112148 </ Tag >
113149 }
114150 />
115- { pipelineRunData . body ?. code_reference && (
151+ { pipelineRunData . body ?. code_reference && repositoryMetadata && (
116152 < KeyValue
117153 label = "Repository/Commit"
118154 value = {
@@ -123,8 +159,7 @@ export function StepDetailsTab({ stepId, runId }: Props) {
123159 rounded = { false }
124160 emphasis = "subtle"
125161 >
126- < Github className = "mr-1 h-5 w-5 fill-theme-text-brand" />
127- zenml.io/zenml
162+ { getRepositoryLink ( ) }
128163 < div className = "ml-1 rounded-sm bg-neutral-200 px-1 py-0.25" >
129164 { transformToEllipsis (
130165 pipelineRunData ?. body ?. code_reference ?. body ?. commit as string ,
0 commit comments