From b6aebd67a81c4731f8eb1e8e043ddad0acb78c8c Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 4 Oct 2024 12:55:50 +0200 Subject: [PATCH 1/3] Rename allowedViews to allowedSources --- .../backend/DataTable/buttons/grid/GridRowActionsButton.svelte | 2 +- packages/builder/src/stores/builder/rowActions.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/stores/builder/rowActions.js b/packages/builder/src/stores/builder/rowActions.js index a8532b0c72..21de2501b3 100644 --- a/packages/builder/src/stores/builder/rowActions.js +++ b/packages/builder/src/stores/builder/rowActions.js @@ -131,7 +131,7 @@ 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.allowedViews || []) { + for (let viewId of action.allowedSources || []) { if (!map[viewId]) { map[viewId] = [] } From 349637733eccacf9d2d4efd5c1fdf43a01d5d67c Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 4 Oct 2024 13:21:21 +0200 Subject: [PATCH 2/3] 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) } } }) From 6f62b8671df35a8e7d210ddd46d5fcc27bff6417 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 4 Oct 2024 15:54:07 +0200 Subject: [PATCH 3/3] Add comment --- packages/builder/src/stores/builder/rowActions.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/builder/src/stores/builder/rowActions.js b/packages/builder/src/stores/builder/rowActions.js index 714f1a47a4..b1f4e7067f 100644 --- a/packages/builder/src/stores/builder/rowActions.js +++ b/packages/builder/src/stores/builder/rowActions.js @@ -129,6 +129,7 @@ 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]) { const otherSources = (action.allowedSources || []).filter(