fix: 修复首次创建任务运行时不自动设置当前运行情况的bug

This commit is contained in:
xiaojunnuo
2024-09-11 18:01:46 +08:00
parent 8ed16b3ea2
commit ecd83ee136
9 changed files with 106 additions and 9 deletions

View File

@@ -186,10 +186,15 @@ h1, h2, h3, h4, h5, h6 {
}
.disabled{
color: #c7c7c7;
}
.deleted{
color: #c7c7c7;
//删除线
text-decoration: line-through;
}
.cursor-move{
cursor: move !important;
}
.cursor-pointer{
cursor: pointer;
}

View File

@@ -51,11 +51,11 @@
<h4 class="title" :class="{ disabled: element.disabled, deleted: element.disabled }">{{ element.title }}</h4>
</div>
<div class="action">
<a key="disabled" @click="element.disabled = !!!element.disabled">{{ element.disabled ? "启用" : "禁用" }}</a>
<a key="edit" @click="stepEdit(currentTask, element, index)">编辑</a>
<a key="edit" @click="stepCopy(currentTask, element, index)">复制</a>
<a key="remove" @click="stepDelete(currentTask, index)">删除</a>
<fs-icon v-plus class="icon-button handle" title="拖动排序" icon="ion:move-outline"></fs-icon>
<a key="disabled" @click="element.disabled = !!!element.disabled">{{ element.disabled ? "启用" : "禁用" }}</a>
<fs-icon v-plus class="icon-button handle cursor-move" title="拖动排序" icon="ion:move-outline"></fs-icon>
</div>
</div>
</template>

View File

@@ -354,7 +354,7 @@ export default defineComponent({
await loadHistoryList();
}
if (!currentHistory.value) {
if (currentHistory.value != null) {
if (currentHistory.value.pipeline?.status?.status === "start") {
await loadCurrentHistoryDetail();
} else {
@@ -614,6 +614,9 @@ export default defineComponent({
saveLoading.value = true;
try {
if (props.options.doSave) {
if (pipeline.value.version == null) {
pipeline.value.version = 0;
}
pipeline.value.version++;
currentPipeline.value = pipeline.value;
await props.options.doSave(pipeline.value);

View File

@@ -1 +1,2 @@
export * from './plugin-k8s.js';
export * from './plugin-script.js';

View File

@@ -0,0 +1,58 @@
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput, TaskInstanceContext } from '@certd/pipeline';
import { CertInfo, CertReader } from '@certd/plugin-cert';
export type CustomScriptContext = {
CertReader: typeof CertReader;
self: CustomScriptPlugin;
} & TaskInstanceContext;
@IsTaskPlugin({
name: 'CustomScript',
title: '自定义js脚本',
desc: '测试',
group: pluginGroups.other.key,
default: {
strategy: {
runStrategy: RunStrategy.SkipWhenSucceed,
},
},
})
export class CustomScriptPlugin extends AbstractTaskPlugin {
@TaskInput({
title: '脚本',
helper: '自定义js脚本',
component: {
name: 'a-textarea',
vModel: 'value',
rows: 10,
style: 'background-color: #000c17;color: #fafafa;',
},
required: true,
})
script!: string;
@TaskInput({
title: '域名证书',
helper: '请选择前置任务输出的域名证书',
component: {
name: 'pi-output-selector',
from: 'CertApply',
},
required: true,
})
cert!: CertInfo;
async onInstance() {}
async execute(): Promise<void> {
this.logger.info('执行自定义脚本:\n', this.script);
const ctx: CustomScriptContext = {
CertReader,
self: this,
...this.ctx,
};
const AsyncFunction = Object.getPrototypeOf(async () => {}).constructor;
const func = new AsyncFunction('ctx', this.script);
return await func(ctx);
}
}
new CustomScriptPlugin();