|
| 1 | +import PipelineIcon from "@/assets/icons/pipeline.svg?react"; |
| 2 | +import RunIcon from "@/assets/icons/terminal.svg?react"; |
| 3 | +import { CopyButton } from "@/components/CopyButton"; |
| 4 | +import { |
| 5 | + ExecutionStatusIcon, |
| 6 | + getExecutionStatusColor, |
| 7 | + getExecutionStatusTagColor |
| 8 | +} from "@/components/ExecutionStatus"; |
| 9 | +import { routes } from "@/router/routes"; |
| 10 | +import { ExecutionStatus } from "@/types/pipeline-runs"; |
| 11 | +import { Pipeline } from "@/types/pipelines"; |
| 12 | +import { ColumnDef } from "@tanstack/react-table"; |
| 13 | +import { |
| 14 | + Tag, |
| 15 | + Tooltip, |
| 16 | + TooltipContent, |
| 17 | + TooltipProvider, |
| 18 | + TooltipTrigger |
| 19 | +} from "@zenml-io/react-component-library"; |
| 20 | +import { Link } from "react-router-dom"; |
| 21 | +import { PipelineDropdown } from "./PipelineDropdown"; |
| 22 | +import { PipelinesSelector } from "./PipelinesSelector"; |
| 23 | + |
| 24 | +export function getPipelineColumns(): ColumnDef<Pipeline>[] { |
| 25 | + return [ |
| 26 | + { |
| 27 | + id: "check", |
| 28 | + header: "", |
| 29 | + meta: { |
| 30 | + width: "1%" |
| 31 | + }, |
| 32 | + cell: ({ row }) => { |
| 33 | + return <PipelinesSelector id={row.original.id} />; |
| 34 | + } |
| 35 | + }, |
| 36 | + { |
| 37 | + id: "name", |
| 38 | + header: "Pipeline", |
| 39 | + cell: ({ row }) => { |
| 40 | + return ( |
| 41 | + <div className="group/copybutton flex items-center gap-2"> |
| 42 | + <PipelineIcon |
| 43 | + className={`h-5 w-5 ${getExecutionStatusColor(row.original.body?.latest_run_status)}`} |
| 44 | + /> |
| 45 | + <div> |
| 46 | + <div className="flex items-center gap-1"> |
| 47 | + <Link |
| 48 | + to={routes.pipelines.namespace(encodeURIComponent(row.original.name))} |
| 49 | + className="flex items-center gap-1" |
| 50 | + > |
| 51 | + <span className="text-text-md font-semibold text-theme-text-primary"> |
| 52 | + {row.original.name} |
| 53 | + </span> |
| 54 | + </Link> |
| 55 | + <TooltipProvider> |
| 56 | + <Tooltip> |
| 57 | + <TooltipTrigger className="hover:text-theme-text-brand hover:underline"> |
| 58 | + <ExecutionStatusIcon status={row.original.body?.latest_run_status} /> |
| 59 | + </TooltipTrigger> |
| 60 | + <TooltipContent className="z-20 capitalize"> |
| 61 | + {row.original.body?.latest_run_status} |
| 62 | + </TooltipContent> |
| 63 | + </Tooltip> |
| 64 | + </TooltipProvider> |
| 65 | + |
| 66 | + <CopyButton copyText={row.original.name} /> |
| 67 | + </div> |
| 68 | + <Link |
| 69 | + to={routes.pipelines.namespace(encodeURIComponent(row.original.name))} |
| 70 | + className="flex items-center gap-1" |
| 71 | + > |
| 72 | + <p className="text-text-xs text-theme-text-secondary"> |
| 73 | + {row.original.id.split("-")[0]} |
| 74 | + </p> |
| 75 | + <CopyButton copyText={row.original.id} /> |
| 76 | + </Link> |
| 77 | + </div> |
| 78 | + </div> |
| 79 | + ); |
| 80 | + } |
| 81 | + }, |
| 82 | + { |
| 83 | + id: "latest-run", |
| 84 | + header: "Latest Run", |
| 85 | + accessorFn: (row) => ({ |
| 86 | + status: row.body?.latest_run_status, |
| 87 | + runId: row.body?.latest_run_id |
| 88 | + }), |
| 89 | + cell: ({ getValue }) => { |
| 90 | + const { runId, status } = getValue<{ |
| 91 | + runId?: string; |
| 92 | + status?: ExecutionStatus; |
| 93 | + }>(); |
| 94 | + |
| 95 | + if (!runId || !status) return <div>No run</div>; |
| 96 | + |
| 97 | + return ( |
| 98 | + <Link to={routes.runs.detail(runId)}> |
| 99 | + <Tag |
| 100 | + emphasis="subtle" |
| 101 | + rounded={false} |
| 102 | + className="inline-flex items-center gap-0.5" |
| 103 | + color={getExecutionStatusTagColor(status)} |
| 104 | + > |
| 105 | + <RunIcon className={`h-3 w-3 fill-current`} /> |
| 106 | + {runId?.split("-")[0]} |
| 107 | + </Tag> |
| 108 | + </Link> |
| 109 | + ); |
| 110 | + } |
| 111 | + }, |
| 112 | + { |
| 113 | + id: "admin_actions", |
| 114 | + header: "", |
| 115 | + meta: { |
| 116 | + width: "5%" |
| 117 | + }, |
| 118 | + cell: ({ row }) => { |
| 119 | + return <PipelineDropdown id={row.original.id} />; |
| 120 | + } |
| 121 | + } |
| 122 | + ]; |
| 123 | +} |
0 commit comments