Prevent data providers from using arbitrary context-providing components as sources
This commit is contained in:
parent
40aa9656e1
commit
2c91b89f02
|
@ -61,7 +61,7 @@ export const getComponentBindableProperties = (asset, componentId) => {
|
||||||
/**
|
/**
|
||||||
* Gets all data provider components above a component.
|
* Gets all data provider components above a component.
|
||||||
*/
|
*/
|
||||||
export const getDataProviderComponents = (asset, componentId) => {
|
export const getContextProviderComponents = (asset, componentId) => {
|
||||||
if (!asset || !componentId) {
|
if (!asset || !componentId) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ export const getDatasourceForProvider = (asset, component) => {
|
||||||
*/
|
*/
|
||||||
const getContextBindings = (asset, componentId) => {
|
const getContextBindings = (asset, componentId) => {
|
||||||
// Extract any components which provide data contexts
|
// Extract any components which provide data contexts
|
||||||
const dataProviders = getDataProviderComponents(asset, componentId)
|
const dataProviders = getContextProviderComponents(asset, componentId)
|
||||||
|
|
||||||
// Generate bindings for all matching components
|
// Generate bindings for all matching components
|
||||||
return getProviderContextBindings(asset, dataProviders)
|
return getProviderContextBindings(asset, dataProviders)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
import { getDataProviderComponents } from "builderStore/dataBinding"
|
import { getContextProviderComponents } from "builderStore/dataBinding"
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Popover,
|
Popover,
|
||||||
|
@ -58,16 +58,19 @@
|
||||||
...query,
|
...query,
|
||||||
type: "query",
|
type: "query",
|
||||||
}))
|
}))
|
||||||
$: dataProviders = getDataProviderComponents(
|
$: contextProviders = getContextProviderComponents(
|
||||||
$currentAsset,
|
$currentAsset,
|
||||||
$store.selectedComponentId
|
$store.selectedComponentId
|
||||||
).map(provider => ({
|
)
|
||||||
label: provider._instanceName,
|
$: dataProviders = contextProviders
|
||||||
name: provider._instanceName,
|
.filter(component => component._component?.endsWith("/dataprovider"))
|
||||||
providerId: provider._id,
|
.map(provider => ({
|
||||||
value: `{{ literal ${safe(provider._id)} }}`,
|
label: provider._instanceName,
|
||||||
type: "provider",
|
name: provider._instanceName,
|
||||||
}))
|
providerId: provider._id,
|
||||||
|
value: `{{ literal ${safe(provider._id)} }}`,
|
||||||
|
type: "provider",
|
||||||
|
}))
|
||||||
$: links = bindings
|
$: links = bindings
|
||||||
.filter(x => x.fieldSchema?.type === "link")
|
.filter(x => x.fieldSchema?.type === "link")
|
||||||
.map(binding => {
|
.map(binding => {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
import { store, currentAsset } from "builderStore"
|
import { store, currentAsset } from "builderStore"
|
||||||
import { tables } from "stores/backend"
|
import { tables } from "stores/backend"
|
||||||
import {
|
import {
|
||||||
getDataProviderComponents,
|
getContextProviderComponents,
|
||||||
getSchemaForDatasource,
|
getSchemaForDatasource,
|
||||||
} from "builderStore/dataBinding"
|
} from "builderStore/dataBinding"
|
||||||
import SaveFields from "./SaveFields.svelte"
|
import SaveFields from "./SaveFields.svelte"
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
export let parameters
|
export let parameters
|
||||||
export let bindings = []
|
export let bindings = []
|
||||||
|
|
||||||
$: dataProviderComponents = getDataProviderComponents(
|
$: dataProviderComponents = getContextProviderComponents(
|
||||||
$currentAsset,
|
$currentAsset,
|
||||||
$store.selectedComponentId
|
$store.selectedComponentId
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue