From e6303fb4ec8c85ddca942195d3138a814593b3ff Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 11 Aug 2022 15:25:43 +0100 Subject: [PATCH] Remove static definition from store and properly handle custom components from API --- .../src/builderStore/store/frontend.js | 35 ++++--------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/packages/builder/src/builderStore/store/frontend.js b/packages/builder/src/builderStore/store/frontend.js index 7903210f53..16d16de8a2 100644 --- a/packages/builder/src/builderStore/store/frontend.js +++ b/packages/builder/src/builderStore/store/frontend.js @@ -90,36 +90,14 @@ export const getFrontendStore = () => { // Fetch component definitions. // Allow errors to propagate. - let 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", - }, - ], - }, - } + const components = await API.fetchComponentLibDefinitions( + application.appId + ) // 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 store.update(state => ({ @@ -146,6 +124,7 @@ export const getFrontendStore = () => { version: application.version, revertableVersion: application.revertableVersion, navigation: application.navigation || {}, + usedPlugins: application.usedPlugins || [], })) // Initialise backend stores