diff --git a/packages/builder/src/components/backend/DataTable/buttons/grid/GridRowActionsButton.svelte b/packages/builder/src/components/backend/DataTable/buttons/grid/GridRowActionsButton.svelte index 3f0d6f11c5..f61e19c19d 100644 --- a/packages/builder/src/components/backend/DataTable/buttons/grid/GridRowActionsButton.svelte +++ b/packages/builder/src/components/backend/DataTable/buttons/grid/GridRowActionsButton.svelte @@ -95,7 +95,7 @@ {#if isView} toggleAction(action, e.detail)} /> 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 a8532b0c72..b1f4e7067f 100644 --- a/packages/builder/src/stores/builder/rowActions.js +++ b/packages/builder/src/stores/builder/rowActions.js @@ -129,13 +129,15 @@ const derivedStore = derived(store, $store => { // Generate an entry for every view as well Object.keys($store || {}).forEach(tableId => { + // We need to have all the actions for the table in order to be displayed in the crud section map[tableId] = $store[tableId] for (let action of $store[tableId]) { - for (let viewId of action.allowedViews || []) { - 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) } } })