Remove static definition from store and properly handle custom components from API

This commit is contained in:
Andrew Kingston 2022-08-11 15:25:43 +01:00
parent a38373a939
commit 019b2181e8
1 changed files with 7 additions and 28 deletions

View File

@ -90,36 +90,14 @@ export const getFrontendStore = () => {
// Fetch component definitions. // Fetch component definitions.
// Allow errors to propagate. // Allow errors to propagate.
let components = await API.fetchComponentLibDefinitions(application.appId) const components = await API.fetchComponentLibDefinitions(
application.appId
// Extend definitions with custom components )
components["test"] = {
component: "test",
name: "Super cool component",
icon: "Text",
description: "A custom component",
showSettingsBar: false,
hasChildren: true,
settings: [
{
type: "text",
key: "text",
label: "Text",
},
],
context: {
type: "static",
values: [
{
label: "Text prop",
key: "text",
},
],
},
}
// Filter out custom component keys so we can flag them // Filter out custom component keys so we can flag them
let customComponents = ["test"] const customComponents = Object.keys(components).filter(name =>
name.startsWith("plugin/")
)
// Reset store state // Reset store state
store.update(state => ({ store.update(state => ({
@ -146,6 +124,7 @@ export const getFrontendStore = () => {
version: application.version, version: application.version,
revertableVersion: application.revertableVersion, revertableVersion: application.revertableVersion,
navigation: application.navigation || {}, navigation: application.navigation || {},
usedPlugins: application.usedPlugins || [],
})) }))
// Initialise backend stores // Initialise backend stores