From 75c89b3d0be4f179d641b04d87a1422590f3d482 Mon Sep 17 00:00:00 2001 From: Fu Diwei Date: Mon, 10 Feb 2025 12:13:54 +0800 Subject: [PATCH] feat(ui): display artifact certificates in WorkflowRunDetail --- internal/repository/workflow_output.go | 19 ++- .../components/workflow/WorkflowRunDetail.tsx | 110 +++++++++++++++++- ui/src/components/workflow/WorkflowRuns.tsx | 2 +- .../workflow/node/NotifyNodeConfigForm.tsx | 2 +- .../components/workflow/node/UploadNode.tsx | 3 +- .../workflow/node/UploadNodeConfigForm.tsx | 4 +- ui/src/domain/workflowRun.ts | 2 +- ui/src/i18n/locales/en/nls.workflow.runs.json | 8 +- ui/src/i18n/locales/zh/nls.workflow.runs.json | 8 +- ui/src/pages/accesses/AccessList.tsx | 2 +- ui/src/pages/certificates/CertificateList.tsx | 2 +- ui/src/pages/dashboard/Dashboard.tsx | 8 +- ui/src/pages/workflows/WorkflowList.tsx | 2 +- ui/src/repository/certificate.ts | 17 +++ 14 files changed, 170 insertions(+), 19 deletions(-) diff --git a/internal/repository/workflow_output.go b/internal/repository/workflow_output.go index e75b2cb7..4cee625c 100644 --- a/internal/repository/workflow_output.go +++ b/internal/repository/workflow_output.go @@ -61,7 +61,22 @@ func (r *WorkflowOutputRepository) SaveWithCertificate(ctx context.Context, work workflowOutput.UpdatedAt = record.GetDateTime("updated").Time() } - if certificate != nil { + if certificate == nil { + panic("certificate is nil") + } else { + if certificate.WorkflowId != "" && certificate.WorkflowId != workflowOutput.WorkflowId { + return workflowOutput, fmt.Errorf("certificate #%s is not belong to workflow #%s", certificate.Id, workflowOutput.WorkflowId) + } + if certificate.WorkflowRunId != "" && certificate.WorkflowRunId != workflowOutput.RunId { + return workflowOutput, fmt.Errorf("certificate #%s is not belong to workflow run #%s", certificate.Id, workflowOutput.RunId) + } + if certificate.WorkflowNodeId != "" && certificate.WorkflowNodeId != workflowOutput.NodeId { + return workflowOutput, fmt.Errorf("certificate #%s is not belong to workflow node #%s", certificate.Id, workflowOutput.NodeId) + } + if certificate.WorkflowOutputId != "" && certificate.WorkflowOutputId != workflowOutput.Id { + return workflowOutput, fmt.Errorf("certificate #%s is not belong to workflow output #%s", certificate.Id, workflowOutput.Id) + } + certificate.WorkflowId = workflowOutput.WorkflowId certificate.WorkflowRunId = workflowOutput.RunId certificate.WorkflowNodeId = workflowOutput.NodeId @@ -143,5 +158,5 @@ func (r *WorkflowOutputRepository) saveRecord(workflowOutput *domain.WorkflowOut return record, err } - return record, err + return record, nil } diff --git a/ui/src/components/workflow/WorkflowRunDetail.tsx b/ui/src/components/workflow/WorkflowRunDetail.tsx index db9610f7..d2a20a5f 100644 --- a/ui/src/components/workflow/WorkflowRunDetail.tsx +++ b/ui/src/components/workflow/WorkflowRunDetail.tsx @@ -1,9 +1,17 @@ +import { useState } from "react"; import { useTranslation } from "react-i18next"; -import { Alert, Typography } from "antd"; +import { SelectOutlined as SelectOutlinedIcon } from "@ant-design/icons"; +import { useRequest } from "ahooks"; +import { Alert, Button, Divider, Empty, Table, type TableProps, Tooltip, Typography, notification } from "antd"; import dayjs from "dayjs"; +import { ClientResponseError } from "pocketbase"; +import CertificateDetailDrawer from "@/components/certificate/CertificateDetailDrawer"; import Show from "@/components/Show"; +import { type CertificateModel } from "@/domain/certificate"; import { WORKFLOW_RUN_STATUSES, type WorkflowRunModel } from "@/domain/workflowRun"; +import { listByWorkflowRunId as listCertificateByWorkflowRunId } from "@/repository/certificate"; +import { getErrMsg } from "@/utils/error"; export type WorkflowRunDetailProps = { className?: string; @@ -45,8 +53,108 @@ const WorkflowRunDetail = ({ data, ...props }: WorkflowRunDetailProps) => { })} + + + + + + ); }; +const WorkflowRunArtifacts = ({ runId }: { runId: string }) => { + const { t } = useTranslation(); + + const [notificationApi, NotificationContextHolder] = notification.useNotification(); + + const tableColumns: TableProps["columns"] = [ + { + key: "$index", + align: "center", + fixed: "left", + width: 50, + render: (_, __, index) => index + 1, + }, + { + key: "type", + title: t("workflow_run_artifact.props.type"), + render: () => t("workflow_run_artifact.props.type.certificate"), + }, + { + key: "name", + title: t("workflow_run_artifact.props.name"), + ellipsis: true, + render: (_, record) => { + return ( + + {record.subjectAltNames} + + ); + }, + }, + { + key: "$action", + align: "end", + width: 120, + render: (_, record) => ( + + +