1
0
Fork 0
mirror of synced 2024-06-27 02:20:35 +12:00

Add role IDs as bindings

This commit is contained in:
Andrew Kingston 2022-04-05 16:05:29 +01:00
parent 250bdd2d87
commit 2cafc7d032

View file

@ -7,7 +7,11 @@ import {
getComponentSettings,
} from "./componentUtils"
import { store } from "builderStore"
import { queries as queriesStores, tables as tablesStore } from "stores/backend"
import {
queries as queriesStores,
tables as tablesStore,
roles as rolesStore,
} from "stores/backend"
import {
makePropSafe,
isJSBinding,
@ -33,6 +37,7 @@ export const getBindableProperties = (asset, componentId) => {
const deviceBindings = getDeviceBindings()
const stateBindings = getStateBindings()
const selectedRowsBindings = getSelectedRowsBindings(asset)
const roleBindings = getRoleBindings()
return [
...contextBindings,
...urlBindings,
@ -40,6 +45,7 @@ export const getBindableProperties = (asset, componentId) => {
...userBindings,
...deviceBindings,
...selectedRowsBindings,
...roleBindings,
]
}
@ -391,6 +397,16 @@ const getUrlBindings = asset => {
}))
}
const getRoleBindings = () => {
return (get(rolesStore) || []).map(role => {
return {
type: "context",
runtimeBinding: `trim "${role._id}"`,
readableBinding: `Roles.${role.name}`,
}
})
}
/**
* Gets all bindable properties exposed in a button actions flow up until
* the specified action ID, as well as context provided for the action