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 = ( export const findClosestMatchingComponent = (
rootComponent, rootComponent,

View File

@ -258,20 +258,6 @@ export const getComponentContexts = (
return Object.values(map) 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. * Gets all data provider components above a component.
*/ */

View File

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