Merge pull request #14706 from Budibase/row-action/allow-running-from-tables
Run rowAction from table only if allowed
This commit is contained in:
commit
821176784a
|
@ -95,7 +95,7 @@
|
||||||
{#if isView}
|
{#if isView}
|
||||||
<span>
|
<span>
|
||||||
<Toggle
|
<Toggle
|
||||||
value={action.allowedViews?.includes(viewId)}
|
value={action.allowedSources?.includes(viewId)}
|
||||||
on:change={e => toggleAction(action, e.detail)}
|
on:change={e => toggleAction(action, e.detail)}
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -63,7 +63,9 @@
|
||||||
$: rowActions.refreshRowActions(id)
|
$: rowActions.refreshRowActions(id)
|
||||||
|
|
||||||
const makeRowActionButtons = actions => {
|
const makeRowActionButtons = actions => {
|
||||||
return (actions || []).map(action => ({
|
return (actions || [])
|
||||||
|
.filter(action => action.allowedSources?.includes(id))
|
||||||
|
.map(action => ({
|
||||||
text: action.name,
|
text: action.name,
|
||||||
onClick: async row => {
|
onClick: async row => {
|
||||||
await rowActions.trigger(id, action.id, row._id)
|
await rowActions.trigger(id, action.id, row._id)
|
||||||
|
|
|
@ -129,13 +129,15 @@ const derivedStore = derived(store, $store => {
|
||||||
|
|
||||||
// Generate an entry for every view as well
|
// Generate an entry for every view as well
|
||||||
Object.keys($store || {}).forEach(tableId => {
|
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]
|
map[tableId] = $store[tableId]
|
||||||
for (let action of $store[tableId]) {
|
for (let action of $store[tableId]) {
|
||||||
for (let viewId of action.allowedViews || []) {
|
const otherSources = (action.allowedSources || []).filter(
|
||||||
if (!map[viewId]) {
|
sourceId => sourceId !== tableId
|
||||||
map[viewId] = []
|
)
|
||||||
}
|
for (let source of otherSources) {
|
||||||
map[viewId].push(action)
|
map[source] ??= []
|
||||||
|
map[source].push(action)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue