mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 05:29:26 +08:00
Merge branch 'main' into next
This commit is contained in:
commit
97d6a2e74d
@ -161,6 +161,23 @@ describe('workflow > triggers > collection', () => {
|
||||
expect(executions.length).toBe(1);
|
||||
expect(executions[0].context.data.title).toBe('c1');
|
||||
});
|
||||
|
||||
it('skipWorkflow', async () => {
|
||||
const workflow = await WorkflowModel.create({
|
||||
enabled: true,
|
||||
sync: true,
|
||||
type: 'collection',
|
||||
config: {
|
||||
mode: 1,
|
||||
collection: 'posts',
|
||||
},
|
||||
});
|
||||
|
||||
const post = await PostRepo.create({ values: { title: 't1' }, context: { skipWorkflow: true } });
|
||||
|
||||
const executions = await workflow.getExecutions();
|
||||
expect(executions.length).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('config.mode', () => {
|
||||
|
@ -53,13 +53,17 @@ export default class CollectionTrigger extends Trigger {
|
||||
|
||||
// async function, should return promise
|
||||
private static async handler(this: CollectionTrigger, workflow: WorkflowModel, data: Model, options) {
|
||||
const { skipWorkflow = false, stack } = options.context ?? {};
|
||||
if (skipWorkflow) {
|
||||
return;
|
||||
}
|
||||
const [dataSourceName] = parseCollectionName(workflow.config.collection);
|
||||
const transaction = this.workflow.useDataSourceTransaction(dataSourceName, options.transaction);
|
||||
const ctx = await this.prepare(workflow, data, { ...options, transaction });
|
||||
if (!ctx) {
|
||||
return;
|
||||
}
|
||||
const { stack } = options.context ?? {};
|
||||
|
||||
if (workflow.sync) {
|
||||
await this.workflow.trigger(workflow, ctx, {
|
||||
transaction,
|
||||
|
Loading…
x
Reference in New Issue
Block a user