mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Fix using strings for flow trigger collections (#17441)
This commit is contained in:
@@ -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) =>
|
||||
|
||||
@@ -94,6 +94,7 @@ export function getTriggers() {
|
||||
{
|
||||
field: 'collections',
|
||||
name: t('collections'),
|
||||
type: 'csv',
|
||||
meta: {
|
||||
interface: 'system-collections',
|
||||
width: 'full' as Width,
|
||||
|
||||
Reference in New Issue
Block a user