Fix using strings for flow trigger collections (#17441)

This commit is contained in:
Nitwel
2023-02-08 18:59:23 +01:00
committed by GitHub
parent fea0a8a20f
commit acd4078239
2 changed files with 21 additions and 18 deletions

View File

@@ -144,26 +144,28 @@ class FlowManager {
for (const flow of flowTrees) {
if (flow.trigger === 'event') {
const events: string[] = flow.options?.scope
? toArray(flow.options.scope)
.map((scope: string) => {
if (['items.create', 'items.update', 'items.delete'].includes(scope)) {
return (
flow.options?.collections?.map((collection: string) => {
if (collection.startsWith('directus_')) {
const action = scope.split('.')[1];
return collection.substring(9) + '.' + action;
}
let events: string[] = [];
return `${collection}.${scope}`;
}) ?? []
);
}
if (flow.options?.scope) {
events = toArray(flow.options.scope)
.map((scope: string) => {
if (['items.create', 'items.update', 'items.delete'].includes(scope)) {
if (!flow.options?.collections) return [];
return scope;
})
.flat()
: [];
return toArray(flow.options.collections).map((collection: string) => {
if (collection.startsWith('directus_')) {
const action = scope.split('.')[1];
return collection.substring(9) + '.' + action;
}
return `${collection}.${scope}`;
});
}
return scope;
})
.flat();
}
if (flow.options.type === 'filter') {
const handler: FilterHandler = (payload, meta, context) =>

View File

@@ -94,6 +94,7 @@ export function getTriggers() {
{
field: 'collections',
name: t('collections'),
type: 'csv',
meta: {
interface: 'system-collections',
width: 'full' as Width,