mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 08:26:21 +00:00
fix(plugin-workflow): hide condition configuration in destroy collection event (#4952)
This commit is contained in:
parent
a70ef41c1c
commit
6cbaa212bb
@ -160,10 +160,10 @@ export default class extends Trigger {
|
|||||||
'x-component-props': {},
|
'x-component-props': {},
|
||||||
'x-reactions': [
|
'x-reactions': [
|
||||||
{
|
{
|
||||||
dependencies: ['collection'],
|
dependencies: ['collection', 'mode'],
|
||||||
fulfill: {
|
fulfill: {
|
||||||
state: {
|
state: {
|
||||||
visible: '{{!!$deps[0]}}',
|
visible: `{{!!$deps[0] && !($deps[1] & ${COLLECTION_TRIGGER_MODE.DELETED})}}`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -434,6 +434,29 @@ describe('workflow > triggers > collection', () => {
|
|||||||
expect(executions.length).toBe(1);
|
expect(executions.length).toBe(1);
|
||||||
expect(executions[0].context.data.title).toBe('t1');
|
expect(executions[0].context.data.title).toBe('t1');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('condition will not effect destroy', async () => {
|
||||||
|
const workflow = await WorkflowModel.create({
|
||||||
|
enabled: true,
|
||||||
|
type: 'collection',
|
||||||
|
config: {
|
||||||
|
mode: 4,
|
||||||
|
collection: 'posts',
|
||||||
|
condition: {
|
||||||
|
title: 't1',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const post1 = await PostRepo.create({ values: { title: 't1' } });
|
||||||
|
await PostRepo.destroy({ filterByTk: post1.id });
|
||||||
|
|
||||||
|
await sleep(500);
|
||||||
|
|
||||||
|
const executions = await workflow.getExecutions();
|
||||||
|
expect(executions.length).toBe(1);
|
||||||
|
expect(executions[0].context.data.title).toBe('t1');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('config.appends', () => {
|
describe('config.appends', () => {
|
||||||
|
@ -68,7 +68,7 @@ async function handler(this: CollectionTrigger, workflow: WorkflowModel, data: M
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: if no configured condition, or not match, do not trigger
|
// NOTE: if no configured condition, or not match, do not trigger
|
||||||
if (isValidFilter(condition)) {
|
if (isValidFilter(condition) && !(mode & MODE_BITMAP.DESTROY)) {
|
||||||
// TODO: change to map filter format to calculation format
|
// TODO: change to map filter format to calculation format
|
||||||
// const calculation = toCalculation(condition);
|
// const calculation = toCalculation(condition);
|
||||||
const count = await repository.count({
|
const count = await repository.count({
|
||||||
|
Loading…
Reference in New Issue
Block a user