From 2ebe5580d5c71f7a6da2b849a4b0e3ef5e596f81 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Thu, 7 May 2020 22:25:27 +0100 Subject: [PATCH] fixing tests --- .../builder/src/builderStore/store/index.js | 24 +++++++++++-------- .../userInterface/pagesParsing/createProps.js | 3 +-- packages/client/src/index.js | 21 ++-------------- .../server/src/utilities/builder/buildPage.js | 4 ++++ 4 files changed, 21 insertions(+), 31 deletions(-) diff --git a/packages/builder/src/builderStore/store/index.js b/packages/builder/src/builderStore/store/index.js index 3baaa2558f..6a9ff1a863 100644 --- a/packages/builder/src/builderStore/store/index.js +++ b/packages/builder/src/builderStore/store/index.js @@ -1,5 +1,5 @@ -import { filter, cloneDeep, values } from "lodash/fp" -import { pipe } from "components/common/core" +import { cloneDeep, values } from "lodash/fp" +import { backendUiStore } from "builderStore"; import * as backendStoreActions from "./backend" import { writable, get } from "svelte/store" import api from "../api" @@ -197,9 +197,8 @@ const setCurrentScreen = store => screenName => { const deleteScreen = store => name => { store.update(s => { - const components = pipe(s.components, [filter(c => c.name !== name)]) - - const screens = pipe(s.screens, [filter(c => c.name !== name)]) + const components = s.components.filter(c => c.name !== name) + const screens = s.screens.filter(c => c.name !== name); s.components = components s.screens = screens @@ -255,14 +254,14 @@ const renameScreen = store => (oldname, newname) => { } const savePage = store => async page => { - store.update(s => { + store.update(state => { if (s.currentFrontEndType !== "page" || !s.currentPageName) { - return s + return state } s.pages[s.currentPageName] = page _savePage(s) - return s + return state }) } @@ -330,7 +329,6 @@ const setCurrentPage = store => pageName => { * @param {string} presetName - name of the component preset if defined */ const addChildComponent = store => (componentToAdd, presetName) => { - // componentToAdd looks like: @budibase/standard-components/container store.update(state => { function findSlot(component_array) { for (let i = 0; i < component_array.length; i += 1) { @@ -356,7 +354,13 @@ const addChildComponent = store => (componentToAdd, presetName) => { : state.components[componentToAdd] const presetProps = presetName ? component.presets[presetName] : {} - const newComponent = createProps(component, presetProps, state) + + const instanceId = get(backendUiStore).selectedDatabase.id; + + const newComponent = createProps(component, { + ...presetProps, + instanceId + }, state) state.currentComponentInfo._children = state.currentComponentInfo._children.concat( newComponent.props diff --git a/packages/builder/src/components/userInterface/pagesParsing/createProps.js b/packages/builder/src/components/userInterface/pagesParsing/createProps.js index f210958da5..efca014490 100644 --- a/packages/builder/src/components/userInterface/pagesParsing/createProps.js +++ b/packages/builder/src/components/userInterface/pagesParsing/createProps.js @@ -25,8 +25,7 @@ export const createProps = (componentDefinition, derivedFromProps) => { _id: uuid(), _component: componentDefinition._component, _styles: { position: {}, layout: {} }, - _code: "", - _instanceId: "dev-1" // TODO fix + _code: "" } const errors = [] diff --git a/packages/client/src/index.js b/packages/client/src/index.js index 9c1e95df45..b84e9172e4 100644 --- a/packages/client/src/index.js +++ b/packages/client/src/index.js @@ -12,29 +12,12 @@ export const loadBudibase = async opts => { const frontendDefinition = _window["##BUDIBASE_FRONTEND_DEFINITION##"] const uiFunctions = _window["##BUDIBASE_FRONTEND_FUNCTIONS##"] - // TODO: Update + // TODO: update const user = {} - // const userFromStorage = _localStorage.getItem("budibase:user") - - // const user = userFromStorage - // ? JSON.parse(userFromStorage) - // : { - // name: "annonymous", - // permissions: [], - // isUser: false, - // temp: false, - // } - - // let { appRootPath } = frontendDefinition; - // appRootPath = appRootPath === "" ? "" : "/" + trimSlash(appRootPatl) - const componentLibraryModules = opts && opts.componentLibraries || {} - const libraries = frontendDefinition.libraries || [ - "@budibase/materialdesign-components", - "@budibase/standard-components" - ] + const libraries = frontendDefinition.libraries || [] for (let library of libraries) { // fetch the JavaScript for the component libraries from the server diff --git a/packages/server/src/utilities/builder/buildPage.js b/packages/server/src/utilities/builder/buildPage.js index 2c912305ee..4878d40e96 100644 --- a/packages/server/src/utilities/builder/buildPage.js +++ b/packages/server/src/utilities/builder/buildPage.js @@ -93,6 +93,10 @@ const buildFrontendAppDefinition = async (config, appname, pageName, pkg) => { appRootPath: appRootPath, page: pkg.page, screens: pkg.screens, + libraries: [ + "@budibase/materialdesign-components", + "@budibase/standard-components" + ] }) await writeFile(