mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 11:26:55 +00:00
fix(plugin-workflow): fix end logic when success (#3453)
This commit is contained in:
parent
2fc1604d78
commit
ad065431fb
@ -200,8 +200,7 @@ const useStyles = createStyles(({ css, token }) => {
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 0;
|
||||
height: 4em;
|
||||
padding: 1em 0;
|
||||
height: 6em;
|
||||
border-left: 1px dashed ${token.colorBgLayout};
|
||||
|
||||
.anticon {
|
||||
|
@ -35,12 +35,20 @@ describe('workflow > instructions > end', () => {
|
||||
},
|
||||
});
|
||||
|
||||
const n2 = await workflow.createNode({
|
||||
type: 'echo',
|
||||
upstreamId: n1.id,
|
||||
});
|
||||
|
||||
await n1.setDownstream(n2);
|
||||
|
||||
await plugin.trigger(workflow, {});
|
||||
|
||||
const [execution] = await workflow.getExecutions();
|
||||
expect(execution.status).toBe(EXECUTION_STATUS.RESOLVED);
|
||||
const [job] = await execution.getJobs();
|
||||
expect(job.status).toBe(JOB_STATUS.RESOLVED);
|
||||
const jobs = await execution.getJobs();
|
||||
expect(jobs.length).toBe(1);
|
||||
expect(jobs[0].status).toBe(JOB_STATUS.RESOLVED);
|
||||
});
|
||||
|
||||
it('failed', async () => {
|
||||
@ -51,12 +59,20 @@ describe('workflow > instructions > end', () => {
|
||||
},
|
||||
});
|
||||
|
||||
const n2 = await workflow.createNode({
|
||||
type: 'echo',
|
||||
upstreamId: n1.id,
|
||||
});
|
||||
|
||||
await n1.setDownstream(n2);
|
||||
|
||||
await plugin.trigger(workflow, {});
|
||||
|
||||
const [execution] = await workflow.getExecutions();
|
||||
expect(execution.status).toBe(EXECUTION_STATUS.FAILED);
|
||||
const [job] = await execution.getJobs();
|
||||
expect(job.status).toBe(JOB_STATUS.FAILED);
|
||||
const jobs = await execution.getJobs();
|
||||
expect(jobs.length).toBe(1);
|
||||
expect(jobs[0].status).toBe(JOB_STATUS.FAILED);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -9,9 +9,14 @@ interface Config {
|
||||
|
||||
export default class extends Instruction {
|
||||
async run(node: FlowNodeModel, prevJob, processor: Processor) {
|
||||
const { endStatus } = <Config>node.config;
|
||||
return {
|
||||
status: endStatus ?? JOB_STATUS.RESOLVED,
|
||||
};
|
||||
const { endStatus = JOB_STATUS.RESOLVED } = <Config>node.config;
|
||||
await processor.saveJob({
|
||||
status: endStatus,
|
||||
nodeId: node.id,
|
||||
nodeKey: node.key,
|
||||
upstreamId: prevJob?.id ?? null,
|
||||
});
|
||||
|
||||
return processor.exit(endStatus);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user