From 8dc86209df06dfd5cedc5f430e8727ea52930cb8 Mon Sep 17 00:00:00 2001 From: Fu Diwei Date: Tue, 21 Jan 2025 23:11:48 +0800 Subject: [PATCH] feat: support removing workflow runs --- internal/pkg/utils/certs/transformer.go | 23 ++------ ui/src/components/workflow/WorkflowRuns.tsx | 54 +++++++++++++++++-- ui/src/i18n/locales/en/nls.workflow.runs.json | 4 ++ ui/src/i18n/locales/zh/nls.workflow.runs.json | 4 ++ ui/src/pages/workflows/WorkflowList.tsx | 41 ++++++-------- ui/src/repository/workflowRun.ts | 4 ++ 6 files changed, 82 insertions(+), 48 deletions(-) diff --git a/internal/pkg/utils/certs/transformer.go b/internal/pkg/utils/certs/transformer.go index c3575b3e..cd1a2039 100644 --- a/internal/pkg/utils/certs/transformer.go +++ b/internal/pkg/utils/certs/transformer.go @@ -2,12 +2,11 @@ import ( "bytes" - "crypto/ecdsa" - "crypto/rsa" "encoding/pem" "errors" "time" + "github.com/go-acme/lego/v4/certcrypto" "github.com/pavlo-v-chernykh/keystore-go/v4" "software.sslmate.com/src/go-pkcs12" ) @@ -28,23 +27,9 @@ func TransformCertificateFromPEMToPFX(certPem string, privkeyPem string, pfxPass return nil, err } - var privkey interface{} - switch cert.PublicKey.(type) { - case *rsa.PublicKey: - { - privkey, err = ParsePKCS1PrivateKeyFromPEM(privkeyPem) - if err != nil { - return nil, err - } - } - - case *ecdsa.PublicKey: - { - privkey, err = ParseECPrivateKeyFromPEM(privkeyPem) - if err != nil { - return nil, err - } - } + privkey, err := certcrypto.ParsePEMPrivateKey([]byte(privkeyPem)) + if err != nil { + return nil, err } pfxData, err := pkcs12.LegacyRC2.Encode(privkey, cert, nil, pfxPassword) diff --git a/ui/src/components/workflow/WorkflowRuns.tsx b/ui/src/components/workflow/WorkflowRuns.tsx index ef9fd5ea..493f6396 100644 --- a/ui/src/components/workflow/WorkflowRuns.tsx +++ b/ui/src/components/workflow/WorkflowRuns.tsx @@ -4,17 +4,18 @@ import { CheckCircleOutlined as CheckCircleOutlinedIcon, ClockCircleOutlined as ClockCircleOutlinedIcon, CloseCircleOutlined as CloseCircleOutlinedIcon, + DeleteOutlined as DeleteOutlinedIcon, SelectOutlined as SelectOutlinedIcon, SyncOutlined as SyncOutlinedIcon, } from "@ant-design/icons"; import { useRequest } from "ahooks"; -import { Button, Empty, Table, type TableProps, Tag, notification } from "antd"; +import { Button, Empty, Modal, Table, type TableProps, Tag, Tooltip, notification } from "antd"; import dayjs from "dayjs"; import { ClientResponseError } from "pocketbase"; import { WORKFLOW_TRIGGERS } from "@/domain/workflow"; import { WORKFLOW_RUN_STATUSES, type WorkflowRunModel } from "@/domain/workflowRun"; -import { list as listWorkflowRuns } from "@/repository/workflowRun"; +import { list as listWorkflowRuns, remove as removeWorkflowRun } from "@/repository/workflowRun"; import { getErrMsg } from "@/utils/error"; import WorkflowRunDetailDrawer from "./WorkflowRunDetailDrawer"; @@ -27,6 +28,7 @@ export type WorkflowRunsProps = { const WorkflowRuns = ({ className, style, workflowId }: WorkflowRunsProps) => { const { t } = useTranslation(); + const [modalApi, ModelContextHolder] = Modal.useModal(); const [notificationApi, NotificationContextHolder] = notification.useNotification(); const tableColumns: TableProps["columns"] = [ @@ -118,7 +120,27 @@ const WorkflowRuns = ({ className, style, workflowId }: WorkflowRunsProps) => { width: 120, render: (_, record) => ( - } variant="text" />} /> + +