From 349637733eccacf9d2d4efd5c1fdf43a01d5d67c Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 4 Oct 2024 13:21:21 +0200 Subject: [PATCH] Return allowed run from table --- .../data/table/[tableId]/index.svelte | 16 +++++++++------- .../builder/src/stores/builder/rowActions.js | 11 ++++++----- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/packages/builder/src/pages/builder/app/[application]/data/table/[tableId]/index.svelte b/packages/builder/src/pages/builder/app/[application]/data/table/[tableId]/index.svelte index 24851c723d..1ee96bf624 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/table/[tableId]/index.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/table/[tableId]/index.svelte @@ -63,13 +63,15 @@ $: rowActions.refreshRowActions(id) const makeRowActionButtons = actions => { - return (actions || []).map(action => ({ - text: action.name, - onClick: async row => { - await rowActions.trigger(id, action.id, row._id) - notifications.success("Row action triggered successfully") - }, - })) + return (actions || []) + .filter(action => action.allowedSources?.includes(id)) + .map(action => ({ + text: action.name, + onClick: async row => { + await rowActions.trigger(id, action.id, row._id) + notifications.success("Row action triggered successfully") + }, + })) } const relationshipSupport = datasource => { diff --git a/packages/builder/src/stores/builder/rowActions.js b/packages/builder/src/stores/builder/rowActions.js index 21de2501b3..714f1a47a4 100644 --- a/packages/builder/src/stores/builder/rowActions.js +++ b/packages/builder/src/stores/builder/rowActions.js @@ -131,11 +131,12 @@ const derivedStore = derived(store, $store => { Object.keys($store || {}).forEach(tableId => { map[tableId] = $store[tableId] for (let action of $store[tableId]) { - for (let viewId of action.allowedSources || []) { - if (!map[viewId]) { - map[viewId] = [] - } - map[viewId].push(action) + const otherSources = (action.allowedSources || []).filter( + sourceId => sourceId !== tableId + ) + for (let source of otherSources) { + map[source] ??= [] + map[source].push(action) } } })