Remove last usage of legacy context util and update data providers to be able to use any data providers on the screen

This commit is contained in:
Andrew Kingston 2023-09-15 08:46:35 +01:00
parent b36b061bb2
commit 0d0d96f5da
3 changed files with 10 additions and 22 deletions

View File

@ -97,7 +97,7 @@ export const findAllComponents = rootComponent => {
}
/**
* Finds the closes parent component which matches certain criteria
* Finds the closest parent component which matches certain criteria
*/
export const findClosestMatchingComponent = (
rootComponent,

View File

@ -258,20 +258,6 @@ export const getComponentContexts = (
return Object.values(map)
}
/**
* Gets all data provider components above a component.
*/
export const getContextProviderComponents = (
asset,
componentId,
type,
options = { includeSelf: false }
) => {
return getComponentContexts(asset, componentId, type, options).map(
entry => entry.component
)
}
/**
* Gets all data provider components above a component.
*/

View File

@ -1,5 +1,5 @@
<script>
import { getContextProviderComponents } from "builderStore/dataBinding"
import { getComponentContexts } from "builderStore/dataBinding"
import {
Button,
Popover,
@ -22,6 +22,7 @@
import BindingBuilder from "components/integration/QueryBindingBuilder.svelte"
import IntegrationQueryEditor from "components/integration/index.svelte"
import { makePropSafe as safe } from "@budibase/string-templates"
import { findAllComponents } from "builderStore/componentUtils"
export let value = {}
export let otherSources
@ -60,12 +61,13 @@
...query,
type: "query",
}))
$: contextProviders = getContextProviderComponents(
$currentAsset,
$store.selectedComponentId
$: dataProviders = findAllComponents($currentAsset.props)
.filter(component => {
return (
component._component?.endsWith("/dataprovider") &&
component._id !== $store.selectedComponentId
)
$: dataProviders = contextProviders
.filter(component => component._component?.endsWith("/dataprovider"))
})
.map(provider => ({
label: provider._instanceName,
name: provider._instanceName,