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,13 +63,15 @@
|
||||||
$: rowActions.refreshRowActions(id)
|
$: rowActions.refreshRowActions(id)
|
||||||
|
|
||||||
const makeRowActionButtons = actions => {
|
const makeRowActionButtons = actions => {
|
||||||
return (actions || []).map(action => ({
|
return (actions || [])
|
||||||
text: action.name,
|
.filter(action => action.allowedSources?.includes(id))
|
||||||
onClick: async row => {
|
.map(action => ({
|
||||||
await rowActions.trigger(id, action.id, row._id)
|
text: action.name,
|
||||||
notifications.success("Row action triggered successfully")
|
onClick: async row => {
|
||||||
},
|
await rowActions.trigger(id, action.id, row._id)
|
||||||
}))
|
notifications.success("Row action triggered successfully")
|
||||||
|
},
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
const relationshipSupport = datasource => {
|
const relationshipSupport = datasource => {
|
||||||
|
|
|
@ -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