diff --git a/packages/core/pipeline/src/core/executor.ts b/packages/core/pipeline/src/core/executor.ts index daba79ec5..1825fb081 100644 --- a/packages/core/pipeline/src/core/executor.ts +++ b/packages/core/pipeline/src/core/executor.ts @@ -36,6 +36,8 @@ export class Executor { options: ExecutorOptions; abort: AbortController = new AbortController(); + _inited = false; + onChanged: (history: RunHistory) => Promise; constructor(options: ExecutorOptions) { this.options = options; @@ -50,6 +52,10 @@ export class Executor { } async init() { + if (this._inited) { + return; + } + this._inited = true; const lastRuntime = await this.pipelineContext.getObj(`lastRuntime`); this.lastRuntime = lastRuntime; this.lastStatusMap = new RunnableCollection(lastRuntime?.pipeline); @@ -315,4 +321,8 @@ export class Executor { } } } + + clearLastStatus(stepId: string) { + this.lastStatusMap.clearById(stepId); + } } diff --git a/packages/core/pipeline/src/core/run-history.ts b/packages/core/pipeline/src/core/run-history.ts index a3f634820..df26cbef6 100644 --- a/packages/core/pipeline/src/core/run-history.ts +++ b/packages/core/pipeline/src/core/run-history.ts @@ -166,6 +166,14 @@ export class RunnableCollection { }); } + clearById(id: string) { + const runnable = this.collection[id]; + if (runnable?.status) { + runnable.status.status = ResultType.none; + runnable.status.result = ResultType.none; + } + } + add(runnable: Runnable) { this.collection[runnable.id] = runnable; } diff --git a/packages/ui/certd-client/src/style/common.less b/packages/ui/certd-client/src/style/common.less index 2f78e5168..fc950097b 100644 --- a/packages/ui/certd-client/src/style/common.less +++ b/packages/ui/certd-client/src/style/common.less @@ -45,6 +45,10 @@ h1, h2, h3, h4, h5, h6 { vertical-align: 0 !important; } +.pointer{ + cursor: pointer; +} + .flex-center{ display: flex; justify-content: center; @@ -122,3 +126,8 @@ h1, h2, h3, h4, h5, h6 { padding-bottom:3px; border-bottom: 1px solid #dedede; } + + +.color-blue{ + color: #1890ff; +} \ No newline at end of file diff --git a/packages/ui/certd-client/src/views/certd/pipeline/api.ts b/packages/ui/certd-client/src/views/certd/pipeline/api.ts index ffc64ffd8..e10c24339 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/api.ts +++ b/packages/ui/certd-client/src/views/certd/pipeline/api.ts @@ -59,11 +59,11 @@ export function Save(pipelineEntity: any) { }); } -export function Trigger(id: any) { +export function Trigger(id: any, stepId?: string) { return request({ url: apiPrefix + "/trigger", method: "post", - params: { id } + params: { id, stepId } }); } diff --git a/packages/ui/certd-client/src/views/certd/pipeline/crud.tsx b/packages/ui/certd-client/src/views/certd/pipeline/crud.tsx index c97ec8b0a..6488839e4 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/crud.tsx +++ b/packages/ui/certd-client/src/views/certd/pipeline/crud.tsx @@ -2,7 +2,7 @@ import * as api from "./api"; import { useI18n } from "vue-i18n"; import { computed, ref } from "vue"; import { useRouter } from "vue-router"; -import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud"; +import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery, UserPageRes, useUi } from "@fast-crud/fast-crud"; import { statusUtil } from "/@/views/certd/pipeline/pipeline/utils/util.status"; import { nanoid } from "nanoid"; import { message, Modal } from "ant-design-vue"; @@ -29,9 +29,16 @@ export default function ({ crudExpose, context: { certdFormRef } }: CreateCrudOp }; const addRequest = async ({ form }: AddReq) => { - form.content = JSON.stringify({ - title: form.title - }); + if (form.content == null) { + form.content = JSON.stringify({ + title: form.title + }); + } else { + const content = JSON.parse(form.content); + content.title = form.title; + form.content = JSON.stringify(content); + } + const res = await api.AddObj(form); lastResRef.value = res; return res; @@ -136,6 +143,18 @@ export default function ({ crudExpose, context: { certdFormRef } }: CreateCrudOp router.push({ path: "/certd/pipeline/detail", query: { id: row.id, editMode: "false" } }); } }, + copy: { + click: async (context) => { + const { ui } = useUi(); + // @ts-ignore + const row = context[ui.tableColumn.row]; + row.title = row.title + "_copy"; + await crudExpose.openCopy({ + row: row, + index: context.index + }); + } + }, config: { order: 1, title: null, diff --git a/packages/ui/certd-client/src/views/certd/pipeline/detail.vue b/packages/ui/certd-client/src/views/certd/pipeline/detail.vue index 1512fd4ad..a9df38a27 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/detail.vue +++ b/packages/ui/certd-client/src/views/certd/pipeline/detail.vue @@ -54,9 +54,9 @@ export default defineComponent({ content: JSON.stringify(pipelineConfig) }); }, - async doTrigger(options: { pipelineId: number }) { - const { pipelineId } = options; - await api.Trigger(pipelineId); + async doTrigger(options: { pipelineId: number; stepId?: string }) { + const { pipelineId, stepId } = options; + await api.Trigger(pipelineId, stepId); } }; diff --git a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/history-timeline-item.vue b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/history-timeline-item.vue index 9e2fdfab5..d9dcf5a44 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/history-timeline-item.vue +++ b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/history-timeline-item.vue @@ -5,7 +5,7 @@

- + {{ status.label }} 当前 diff --git a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/status-show.vue b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/status-show.vue index 7d9e1cd33..140979c2d 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/status-show.vue +++ b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/status-show.vue @@ -1,5 +1,5 @@