1+ import Pipelines from "@/assets/icons/pipeline.svg?react" ;
12import Spinner from "@/assets/icons/spinner.svg?react" ;
3+ import Run from "@/assets/icons/terminal-square.svg?react" ;
24import { DisplayDate } from "@/components/DisplayDate" ;
35import { ErrorFallback } from "@/components/Error" ;
6+ import { ExecutionStatusIcon , getExecutionStatusTagColor } from "@/components/ExecutionStatus" ;
47import { InlineAvatar } from "@/components/InlineAvatar" ;
58import { Key , KeyValue , Value } from "@/components/KeyValue" ;
69import { useArtifactVersion } from "@/data/artifact-versions/artifact-version-detail-query" ;
710import { useComponentDetail } from "@/data/components/component-detail-query" ;
11+ import { usePipelineRun } from "@/data/pipeline-runs/pipeline-run-detail-query" ;
812import { useStepDetail } from "@/data/steps/step-detail-query" ;
13+ import { routes } from "@/router/routes" ;
914import {
1015 Skeleton ,
1116 Tag ,
@@ -14,95 +19,124 @@ import {
1419 TooltipProvider ,
1520 TooltipTrigger
1621} from "@zenml-io/react-component-library" ;
22+ import { Link } from "react-router-dom" ;
1723import { Codesnippet } from "../../CodeSnippet" ;
1824import { CollapsibleCard } from "../../CollapsibleCard" ;
19- import { ArtifactIcon } from "@/components/ArtifactIcon" ;
20- import { ArtifactVersionBody } from "@/types/artifact-versions" ;
21- import { getExecutionStatusTagColor } from "@/components/ExecutionStatus" ;
22- import Run from "@/assets/icons/terminal-square.svg?react" ;
2325
2426type Props = {
2527 artifactVersionId : string ;
2628} ;
2729
2830export function DetailsCard ( { artifactVersionId } : Props ) {
29- const {
30- data : artifactVersion ,
31- isPending : isArtifactVersionPending ,
32- isError : isArtifactVersionError ,
33- error
34- } = useArtifactVersion ( { versionId : artifactVersionId } ) ;
31+ const artifactVersion = useArtifactVersion ( { versionId : artifactVersionId } ) ;
32+
33+ const producerRunId = artifactVersion . data ?. body ?. producer_pipeline_run_id ;
34+
35+ const pipelineRun = usePipelineRun (
36+ {
37+ runId : producerRunId as string
38+ } ,
39+ { throwOnError : true , enabled : ! ! producerRunId }
40+ ) ;
3541
36- const producerId = artifactVersion ?. metadata ?. producer_step_run_id ;
37- const { data : stepData } = useStepDetail (
42+ const producerId = artifactVersion . data ?. metadata ?. producer_step_run_id ;
43+ const stepDetail = useStepDetail (
3844 {
3945 stepId : producerId !
4046 } ,
4147 { enabled : ! ! producerId }
4248 ) ;
4349
44- if ( isArtifactVersionPending ) return < Skeleton className = "h-[500px] w-full" /> ;
45- if ( isArtifactVersionError ) return < ErrorFallback err = { error } /> ;
50+ if ( artifactVersion . isPending || pipelineRun . isPending )
51+ return < Skeleton className = "h-[500px] w-full" /> ;
52+ if ( artifactVersion . isError || pipelineRun . isError )
53+ return < ErrorFallback err = { artifactVersion . error ! || pipelineRun . error ! } /> ;
4654
4755 return (
4856 < CollapsibleCard initialOpen title = "Details" >
4957 < dl className = "grid grid-cols-1 gap-x-[10px] gap-y-2 md:grid-cols-3 md:gap-y-4" >
50- { artifactVersion . metadata ?. producer_step_run_id && (
51- < KeyValue
52- label = "Producer Step"
53- value = {
58+ < KeyValue
59+ label = "Pipeline"
60+ value = {
61+ < Link
62+ to = { routes . pipelines . namespace (
63+ encodeURIComponent ( pipelineRun . data . body ?. pipeline ?. name as string )
64+ ) }
65+ >
5466 < Tag
55- color = "grey "
67+ color = "purple "
5668 className = "inline-flex items-center gap-0.5"
5769 rounded = { false }
5870 emphasis = "subtle"
5971 >
60- { stepData ?. body ?. status === "running" ? (
61- < Spinner className = "mr-1 h-4 w-4 border-[2px]" />
62- ) : (
63- < ArtifactIcon
64- artifactType = { artifactVersion . body ?. type as ArtifactVersionBody [ "type" ] }
65- className = "mr-1 h-4 w-4 fill-current"
66- />
67- ) }
68- { stepData ? stepData ?. name : < Skeleton className = "h-5 w-5" /> }
72+ < Pipelines className = "mr-1 h-4 w-4 fill-theme-text-brand" />
73+ { pipelineRun . data . body ?. pipeline ?. name }
74+
75+ < div className = "rounded-sm bg-primary-50 px-1 py-0.25" >
76+ { pipelineRun . data . body ?. pipeline ?. body ?. version }
77+ </ div >
6978 </ Tag >
79+ </ Link >
80+ }
81+ />
82+ { artifactVersion . data . body ?. producer_pipeline_run_id && pipelineRun . data . body ?. status && (
83+ < KeyValue
84+ label = "Producer Run"
85+ value = {
86+ < Link to = { routes . runs . detail ( artifactVersion . data . body ?. producer_pipeline_run_id ) } >
87+ < Tag
88+ color = { getExecutionStatusTagColor ( pipelineRun . data . body ?. status ) }
89+ className = "inline-flex items-center gap-0.5"
90+ rounded = { false }
91+ emphasis = "subtle"
92+ >
93+ { pipelineRun . data . body ?. status === "running" ? (
94+ < Spinner className = "mr-1 h-4 w-4 border-[2px]" />
95+ ) : (
96+ < Run className = { `mr-1 h-4 w-4 fill-current` } />
97+ ) }
98+
99+ { artifactVersion . data . body ?. producer_pipeline_run_id }
100+ </ Tag >
101+ </ Link >
70102 }
71103 />
72104 ) }
73- { artifactVersion . body ?. producer_pipeline_run_id && (
105+ { artifactVersion . data . body ?. artifact . id && (
74106 < KeyValue
75- label = "Producer Run "
107+ label = "Producer Step "
76108 value = {
77- < Tag
78- color = { getExecutionStatusTagColor ( stepData ?. body ?. status ) }
79- className = "inline-flex items-center gap-0.5"
80- rounded = { false }
81- emphasis = "subtle"
82- >
83- { stepData ?. body ?. status === "running" ? (
84- < Spinner className = "mr-1 h-4 w-4 border-[2px]" />
109+ < >
110+ { stepDetail . data ? (
111+ < Tag
112+ color = { getExecutionStatusTagColor ( "completed" ) }
113+ className = "inline-flex items-center gap-0.5"
114+ rounded = { false }
115+ emphasis = "subtle"
116+ >
117+ < ExecutionStatusIcon className = "mr-1 fill-current" status = { "completed" } />
118+ { stepDetail . data . name }
119+ </ Tag >
85120 ) : (
86- < Run className = { `mr-1 h-4 w-4 fill-current` } />
121+ < Skeleton className = "h-full w-[150px]" />
87122 ) }
88- { artifactVersion . body ?. producer_pipeline_run_id }
89- </ Tag >
123+ </ >
90124 }
91125 />
92126 ) }
93127
94- < KeyValue label = "Type" value = { artifactVersion . body ?. type } />
128+ < KeyValue label = "Type" value = { artifactVersion . data . body ?. type } />
95129 < KeyValue
96130 label = "Author"
97131 value = {
98132 < div className = "inline-flex items-center gap-1" >
99- < InlineAvatar username = { artifactVersion . body ?. user ?. name || "" } />
133+ < InlineAvatar username = { artifactVersion . data . body ?. user ?. name || "" } />
100134 </ div >
101135 }
102136 />
103137 < KeyValue
104138 label = "Updated"
105- value = { < DisplayDate dateString = { artifactVersion . body ! . updated || "" } /> }
139+ value = { < DisplayDate dateString = { artifactVersion . data . body ? .updated || "" } /> }
106140 />
107141 </ dl >
108142 </ CollapsibleCard >
0 commit comments