Prevent data providers from using arbitrary context-providing components as sources

This commit is contained in:
Andrew Kingston 2021-11-30 14:32:18 +00:00
parent 4e607feda0
commit 52b7e41e5f
3 changed files with 16 additions and 13 deletions

View File

@ -61,7 +61,7 @@ export const getComponentBindableProperties = (asset, componentId) => {
/**
* Gets all data provider components above a component.
*/
export const getDataProviderComponents = (asset, componentId) => {
export const getContextProviderComponents = (asset, componentId) => {
if (!asset || !componentId) {
return []
}
@ -143,7 +143,7 @@ export const getDatasourceForProvider = (asset, component) => {
*/
const getContextBindings = (asset, componentId) => {
// Extract any components which provide data contexts
const dataProviders = getDataProviderComponents(asset, componentId)
const dataProviders = getContextProviderComponents(asset, componentId)
// Generate bindings for all matching components
return getProviderContextBindings(asset, dataProviders)

View File

@ -1,5 +1,5 @@
<script>
import { getDataProviderComponents } from "builderStore/dataBinding"
import { getContextProviderComponents } from "builderStore/dataBinding"
import {
Button,
Popover,
@ -58,10 +58,13 @@
...query,
type: "query",
}))
$: dataProviders = getDataProviderComponents(
$: contextProviders = getContextProviderComponents(
$currentAsset,
$store.selectedComponentId
).map(provider => ({
)
$: dataProviders = contextProviders
.filter(component => component._component?.endsWith("/dataprovider"))
.map(provider => ({
label: provider._instanceName,
name: provider._instanceName,
providerId: provider._id,

View File

@ -3,7 +3,7 @@
import { store, currentAsset } from "builderStore"
import { tables } from "stores/backend"
import {
getDataProviderComponents,
getContextProviderComponents,
getSchemaForDatasource,
} from "builderStore/dataBinding"
import SaveFields from "./SaveFields.svelte"
@ -11,7 +11,7 @@
export let parameters
export let bindings = []
$: dataProviderComponents = getDataProviderComponents(
$: dataProviderComponents = getContextProviderComponents(
$currentAsset,
$store.selectedComponentId
)