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}
|
||||
<span>
|
||||
<Toggle
|
||||
value={action.allowedViews?.includes(viewId)}
|
||||
value={action.allowedSources?.includes(viewId)}
|
||||
on:change={e => toggleAction(action, e.detail)}
|
||||
/>
|
||||
</span>
|
||||
|
|
|
@ -63,7 +63,9 @@
|
|||
$: rowActions.refreshRowActions(id)
|
||||
|
||||
const makeRowActionButtons = actions => {
|
||||
return (actions || []).map(action => ({
|
||||
return (actions || [])
|
||||
.filter(action => action.allowedSources?.includes(id))
|
||||
.map(action => ({
|
||||
text: action.name,
|
||||
onClick: async row => {
|
||||
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
|
||||
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)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue