|
| 1 | +import ChevronDown from "@/assets/icons/chevron-down.svg?react"; |
| 2 | +import Info from "@/assets/icons/info.svg?react"; |
| 3 | +import { Codesnippet } from "@/components/CodeSnippet"; |
| 4 | +import { CopyButton } from "@/components/CopyButton"; |
| 5 | +import { Key, Value } from "@/components/KeyValue"; |
| 6 | +import { RepoBadge } from "@/components/repositories/RepoBadge"; |
| 7 | +import { usePipelineRun } from "@/data/pipeline-runs/pipeline-run-detail-query"; |
| 8 | +import { Metadata, MetadataMap } from "@/types/common"; |
| 9 | +import { |
| 10 | + CollapsibleContent, |
| 11 | + CollapsibleHeader, |
| 12 | + CollapsiblePanel, |
| 13 | + CollapsibleTrigger, |
| 14 | + Tooltip, |
| 15 | + TooltipContent, |
| 16 | + TooltipProvider, |
| 17 | + TooltipTrigger |
| 18 | +} from "@zenml-io/react-component-library/components/client"; |
| 19 | +import { Skeleton } from "@zenml-io/react-component-library/components/server"; |
| 20 | +import { useState } from "react"; |
| 21 | +import { useParams } from "react-router-dom"; |
| 22 | + |
| 23 | +export function InfoCollapsible() { |
| 24 | + const { runId } = useParams() as { runId: string }; |
| 25 | + |
| 26 | + const [open, setOpen] = useState(true); |
| 27 | + const { data, isError, isPending } = usePipelineRun({ runId }); |
| 28 | + |
| 29 | + const orchestrator_url: Metadata | undefined = (data?.metadata?.run_metadata as MetadataMap) |
| 30 | + ?.orchestrator_url; |
| 31 | + const orchestrator_run_id = data?.metadata?.orchestrator_run_id; |
| 32 | + |
| 33 | + if (isError) return null; |
| 34 | + if (isPending) return <Skeleton className="h-[200px]" />; |
| 35 | + |
| 36 | + return ( |
| 37 | + <CollapsiblePanel open={open} onOpenChange={setOpen}> |
| 38 | + <CollapsibleHeader className="flex items-center gap-[10px]"> |
| 39 | + <CollapsibleTrigger className="flex w-full"> |
| 40 | + <ChevronDown |
| 41 | + className={` ${ |
| 42 | + open ? "" : "-rotate-90" |
| 43 | + } mr-2 h-5 w-5 rounded-md fill-neutral-500 transition-transform duration-200 hover:bg-neutral-200`} |
| 44 | + /> |
| 45 | + Info |
| 46 | + </CollapsibleTrigger> |
| 47 | + </CollapsibleHeader> |
| 48 | + <CollapsibleContent className="border-t border-theme-border-moderate bg-theme-surface-primary px-5 py-3"> |
| 49 | + <dl className="grid grid-cols-1 gap-x-[10px] gap-y-2 md:grid-cols-3 md:gap-y-4"> |
| 50 | + <Key>Orchestrator URL</Key> |
| 51 | + <Value> |
| 52 | + {orchestrator_url ? ( |
| 53 | + <div className="group/copybutton flex items-center gap-0.5"> |
| 54 | + <a |
| 55 | + className="truncate underline transition-all duration-200 hover:decoration-transparent" |
| 56 | + rel="noopener noreferrer" |
| 57 | + target="_blank" |
| 58 | + href={orchestrator_url.body.value} |
| 59 | + > |
| 60 | + {orchestrator_url.body.value} |
| 61 | + </a> |
| 62 | + <CopyButton copyText={orchestrator_url.body.value} /> |
| 63 | + </div> |
| 64 | + ) : ( |
| 65 | + "Not available" |
| 66 | + )} |
| 67 | + </Value> |
| 68 | + <Key>Orchestrator Run ID</Key> |
| 69 | + <Value> |
| 70 | + {orchestrator_run_id ? ( |
| 71 | + <div className="group/copybutton flex items-center gap-0.5"> |
| 72 | + {orchestrator_run_id} |
| 73 | + <CopyButton copyText={orchestrator_run_id} /> |
| 74 | + </div> |
| 75 | + ) : ( |
| 76 | + "Not available" |
| 77 | + )} |
| 78 | + </Value> |
| 79 | + <Key> |
| 80 | + <div className="flex items-center space-x-0.5 truncate"> |
| 81 | + <span className="truncate">Repository/Commit</span> |
| 82 | + <TooltipProvider> |
| 83 | + <Tooltip> |
| 84 | + <TooltipTrigger className="cursor-default"> |
| 85 | + <Info className="h-3 w-3 fill-theme-text-secondary" /> |
| 86 | + <span className="sr-only">Info</span> |
| 87 | + </TooltipTrigger> |
| 88 | + <TooltipContent className="w-full max-w-md whitespace-normal"> |
| 89 | + Git hash of code repository. Only set if pipeline was run in a clean git |
| 90 | + repository connected to your ZenML server. |
| 91 | + </TooltipContent> |
| 92 | + </Tooltip> |
| 93 | + </TooltipProvider> |
| 94 | + </div> |
| 95 | + </Key> |
| 96 | + <Value> |
| 97 | + {data.body?.code_reference ? ( |
| 98 | + <RepoBadge |
| 99 | + repositoryId={data.body?.code_reference.body?.code_repository.id} |
| 100 | + commit={data.body.code_reference.body?.commit} |
| 101 | + /> |
| 102 | + ) : ( |
| 103 | + "Not available" |
| 104 | + )} |
| 105 | + </Value> |
| 106 | + <Key className={data.metadata?.code_path ? "col-span-3" : ""}> |
| 107 | + <div className="flex items-center space-x-0.5 truncate"> |
| 108 | + <span>Code Path</span> |
| 109 | + <TooltipProvider> |
| 110 | + <Tooltip> |
| 111 | + <TooltipTrigger className="cursor-default"> |
| 112 | + <Info className="h-3 w-3 fill-theme-text-secondary" /> |
| 113 | + <span className="sr-only">Info</span> |
| 114 | + </TooltipTrigger> |
| 115 | + <TooltipContent className="w-full max-w-md whitespace-normal"> |
| 116 | + Path to where code was uploaded in the artifact store. Only set on a pipeline |
| 117 | + with a non-local orchestrator and if Repository/Commit is not set |
| 118 | + </TooltipContent> |
| 119 | + </Tooltip> |
| 120 | + </TooltipProvider> |
| 121 | + </div> |
| 122 | + </Key> |
| 123 | + <Value className={data.metadata?.code_path ? "col-span-3 h-auto" : ""}> |
| 124 | + {data.metadata?.code_path ? ( |
| 125 | + <Codesnippet code={data.metadata.code_path} /> |
| 126 | + ) : ( |
| 127 | + "Not available" |
| 128 | + )} |
| 129 | + </Value> |
| 130 | + </dl> |
| 131 | + </CollapsibleContent> |
| 132 | + </CollapsiblePanel> |
| 133 | + ); |
| 134 | +} |
0 commit comments