fix(plugin-workflow): hide condition configuration in destroy collection event (#4952)

This commit is contained in:
Junyi 2024-07-27 14:35:57 +08:00 committed by GitHub
parent a70ef41c1c
commit 6cbaa212bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 26 additions and 3 deletions

View File

@ -160,10 +160,10 @@ export default class extends Trigger {
'x-component-props': {},
'x-reactions': [
{
dependencies: ['collection'],
dependencies: ['collection', 'mode'],
fulfill: {
state: {
visible: '{{!!$deps[0]}}',
visible: `{{!!$deps[0] && !($deps[1] & ${COLLECTION_TRIGGER_MODE.DELETED})}}`,
},
},
},

View File

@ -434,6 +434,29 @@ describe('workflow > triggers > collection', () => {
expect(executions.length).toBe(1);
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', () => {

View File

@ -68,7 +68,7 @@ async function handler(this: CollectionTrigger, workflow: WorkflowModel, data: M
}
// 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
// const calculation = toCalculation(condition);
const count = await repository.count({