Make all actions globally aware in component settings

This commit is contained in:
Andrew Kingston 2023-09-15 09:06:40 +01:00
parent 429f2e0c5f
commit 3839e26758
1 changed files with 8 additions and 9 deletions

View File

@ -261,17 +261,16 @@ export const getComponentContexts = (
* Gets all data provider components above a component.
*/
export const getActionProviderComponents = (asset, componentId, actionType) => {
if (!asset || !componentId) {
if (!asset) {
return []
}
// Get the component tree leading up to this component, ignoring the component
// itself
const path = findComponentPath(asset.props, componentId)
path.pop()
// Filter by only data provider components
return path.filter(component => {
const components = findAllComponents(asset.props)
return components.filter(component => {
// Ignore ourselves
if (componentId && component._id === componentId) {
return false
}
// Find components when expose this action
const def = store.actions.components.getDefinition(component._component)
return def?.actions?.includes(actionType)
})