Add optional chaining to all current asset references to account for nullish values
This commit is contained in:
parent
36da1ea799
commit
eabe1a0057
|
@ -126,7 +126,7 @@ export const getDatasourceForProvider = (asset, component) => {
|
||||||
if (dataProviderSetting) {
|
if (dataProviderSetting) {
|
||||||
const settingValue = component[dataProviderSetting.key]
|
const settingValue = component[dataProviderSetting.key]
|
||||||
const providerId = extractLiteralHandlebarsID(settingValue)
|
const providerId = extractLiteralHandlebarsID(settingValue)
|
||||||
const provider = findComponent(asset.props, providerId)
|
const provider = findComponent(asset?.props, providerId)
|
||||||
return getDatasourceForProvider(asset, provider)
|
return getDatasourceForProvider(asset, provider)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -458,7 +458,7 @@ export const getSchemaForDatasource = (asset, datasource, options) => {
|
||||||
// Determine the entity which backs this datasource.
|
// Determine the entity which backs this datasource.
|
||||||
// "provider" datasources are those targeting another data provider
|
// "provider" datasources are those targeting another data provider
|
||||||
if (type === "provider") {
|
if (type === "provider") {
|
||||||
const component = findComponent(asset.props, datasource.providerId)
|
const component = findComponent(asset?.props, datasource.providerId)
|
||||||
const source = getDatasourceForProvider(asset, component)
|
const source = getDatasourceForProvider(asset, component)
|
||||||
return getSchemaForDatasource(asset, source, options)
|
return getSchemaForDatasource(asset, source, options)
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ export const selectedComponent = derived(
|
||||||
if (!$currentAsset || !$store.selectedComponentId) {
|
if (!$currentAsset || !$store.selectedComponentId) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
return findComponent($currentAsset.props, $store.selectedComponentId)
|
return findComponent($currentAsset?.props, $store.selectedComponentId)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -400,11 +400,11 @@ export const getFrontendStore = () => {
|
||||||
parentComponent = selected
|
parentComponent = selected
|
||||||
} else {
|
} else {
|
||||||
// Otherwise we need to use the parent of this component
|
// Otherwise we need to use the parent of this component
|
||||||
parentComponent = findComponentParent(asset.props, selected._id)
|
parentComponent = findComponentParent(asset?.props, selected._id)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Use screen or layout if no component is selected
|
// Use screen or layout if no component is selected
|
||||||
parentComponent = asset.props
|
parentComponent = asset?.props
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attach component
|
// Attach component
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
const moveUpComponent = () => {
|
const moveUpComponent = () => {
|
||||||
const asset = get(currentAsset)
|
const asset = get(currentAsset)
|
||||||
const parent = findComponentParent(asset.props, component._id)
|
const parent = findComponentParent(asset?.props, component._id)
|
||||||
if (!parent) {
|
if (!parent) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
|
|
||||||
const moveDownComponent = () => {
|
const moveDownComponent = () => {
|
||||||
const asset = get(currentAsset)
|
const asset = get(currentAsset)
|
||||||
const parent = findComponentParent(asset.props, component._id)
|
const parent = findComponentParent(asset?.props, component._id)
|
||||||
if (!parent) {
|
if (!parent) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
export let parameters
|
export let parameters
|
||||||
|
|
||||||
$: components = findAllMatchingComponents($currentAsset.props, component =>
|
$: components = findAllMatchingComponents($currentAsset?.props, component =>
|
||||||
component._component.endsWith("s3upload")
|
component._component.endsWith("s3upload")
|
||||||
)
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const getValue = component => `{{ literal ${makePropSafe(component._id)} }}`
|
const getValue = component => `{{ literal ${makePropSafe(component._id)} }}`
|
||||||
|
|
||||||
$: path = findComponentPath($currentAsset.props, $store.selectedComponentId)
|
$: path = findComponentPath($currentAsset?.props, $store.selectedComponentId)
|
||||||
$: providers = path.filter(c => c._component?.endsWith("/dataprovider"))
|
$: providers = path.filter(c => c._component?.endsWith("/dataprovider"))
|
||||||
|
|
||||||
// Set initial value to closest data provider
|
// Set initial value to closest data provider
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
export let type
|
export let type
|
||||||
|
|
||||||
$: form = findClosestMatchingComponent(
|
$: form = findClosestMatchingComponent(
|
||||||
$currentAsset.props,
|
$currentAsset?.props,
|
||||||
componentInstance._id,
|
componentInstance._id,
|
||||||
component => component._component === "@budibase/standard-components/form"
|
component => component._component === "@budibase/standard-components/form"
|
||||||
)
|
)
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
const resetFormFields = async () => {
|
const resetFormFields = async () => {
|
||||||
const form = findClosestMatchingComponent(
|
const form = findClosestMatchingComponent(
|
||||||
$currentAsset.props,
|
$currentAsset?.props,
|
||||||
componentInstance._id,
|
componentInstance._id,
|
||||||
component => component._component.endsWith("/form")
|
component => component._component.endsWith("/form")
|
||||||
)
|
)
|
||||||
|
|
|
@ -135,7 +135,7 @@
|
||||||
if (asset?._id) {
|
if (asset?._id) {
|
||||||
url += `/${asset._id}`
|
url += `/${asset._id}`
|
||||||
if (componentId) {
|
if (componentId) {
|
||||||
const componentPath = findComponentPath(asset.props, componentId)
|
const componentPath = findComponentPath(asset?.props, componentId)
|
||||||
const componentURL = componentPath
|
const componentURL = componentPath
|
||||||
.slice(1)
|
.slice(1)
|
||||||
.map(comp => comp._id)
|
.map(comp => comp._id)
|
||||||
|
|
Loading…
Reference in New Issue