Errors from builder store
This commit is contained in:
parent
7e02938619
commit
3c4ac9ad5a
|
@ -7206,8 +7206,7 @@
|
|||
{
|
||||
"type": "table",
|
||||
"label": "Data",
|
||||
"key": "dataSource",
|
||||
"validator": "checkValidDatasource"
|
||||
"key": "dataSource"
|
||||
},
|
||||
{
|
||||
"type": "radio",
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
appStore,
|
||||
dndComponentPath,
|
||||
dndIsDragging,
|
||||
componentErrors,
|
||||
} from "stores"
|
||||
import { Helpers } from "@budibase/bbui"
|
||||
import { getActiveConditions, reduceConditionActions } from "utils/conditions"
|
||||
|
@ -40,7 +41,6 @@
|
|||
getActionDependentContextKeys,
|
||||
} from "../utils/buttonActions.js"
|
||||
import { gridLayout } from "utils/grid"
|
||||
import { validateComponentSetting } from "utils/componentsValidator"
|
||||
|
||||
export let instance = {}
|
||||
export let parent = null
|
||||
|
@ -344,21 +344,6 @@
|
|||
return missing
|
||||
})
|
||||
|
||||
// Check for invalid settings
|
||||
invalidSettings = settingsDefinition.reduce((invalidSettings, setting) => {
|
||||
if (setting.validator) {
|
||||
const error = validateComponentSetting(
|
||||
setting.validator,
|
||||
instance[setting.key]
|
||||
)
|
||||
if (error) {
|
||||
invalidSettings.push(error)
|
||||
}
|
||||
}
|
||||
|
||||
return invalidSettings
|
||||
}, [])
|
||||
|
||||
// When considering bindings we can ignore children, so we remove that
|
||||
// before storing the reference stringified version
|
||||
const noChildren = JSON.stringify({ ...instance, _children: null })
|
||||
|
@ -389,6 +374,9 @@
|
|||
}
|
||||
}
|
||||
|
||||
// Check for invalid settings
|
||||
$: invalidSettings = $componentErrors[id]
|
||||
|
||||
// Extracts a map of all context keys which are required by action settings
|
||||
// to provide the functions to evaluate at runtime. This needs done manually
|
||||
// as the action definitions themselves do not specify bindings for action
|
||||
|
|
|
@ -19,6 +19,9 @@ const createBuilderStore = () => {
|
|||
eventResolvers: {},
|
||||
metadata: null,
|
||||
snippets: null,
|
||||
componentErrors: {
|
||||
c5ea93132725c48b2a365fcc1facaee86: ["Ups...!"],
|
||||
}, // TODO
|
||||
|
||||
// Legacy - allow the builder to specify a layout
|
||||
layout: null,
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
import { derived } from "svelte/store"
|
||||
import { builderStore } from "../builder.js"
|
||||
|
||||
export const componentErrors = derived([builderStore], ([$builderStore]) => {
|
||||
return $builderStore.componentErrors as Record<string, string[]>
|
||||
})
|
|
@ -5,3 +5,4 @@ export { currentRole } from "./currentRole.js"
|
|||
export { dndComponentPath } from "./dndComponentPath.js"
|
||||
export { devToolsEnabled } from "./devToolsEnabled.js"
|
||||
export { snippets } from "./snippets.js"
|
||||
export { componentErrors } from "./componentErrors"
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
const validators = {
|
||||
checkValidDatasource: (a: any) => {
|
||||
return `Ups... "${a.label}" not found`
|
||||
},
|
||||
}
|
||||
|
||||
export function validateComponentSetting(
|
||||
key: keyof typeof validators,
|
||||
value: any
|
||||
) {
|
||||
const validator = validators[key]
|
||||
return validator(value)
|
||||
}
|
Loading…
Reference in New Issue