fixing tests
This commit is contained in:
parent
db69673a9d
commit
2ebe5580d5
|
@ -1,5 +1,5 @@
|
||||||
import { filter, cloneDeep, values } from "lodash/fp"
|
import { cloneDeep, values } from "lodash/fp"
|
||||||
import { pipe } from "components/common/core"
|
import { backendUiStore } from "builderStore";
|
||||||
import * as backendStoreActions from "./backend"
|
import * as backendStoreActions from "./backend"
|
||||||
import { writable, get } from "svelte/store"
|
import { writable, get } from "svelte/store"
|
||||||
import api from "../api"
|
import api from "../api"
|
||||||
|
@ -197,9 +197,8 @@ const setCurrentScreen = store => screenName => {
|
||||||
|
|
||||||
const deleteScreen = store => name => {
|
const deleteScreen = store => name => {
|
||||||
store.update(s => {
|
store.update(s => {
|
||||||
const components = pipe(s.components, [filter(c => c.name !== name)])
|
const components = s.components.filter(c => c.name !== name)
|
||||||
|
const screens = s.screens.filter(c => c.name !== name);
|
||||||
const screens = pipe(s.screens, [filter(c => c.name !== name)])
|
|
||||||
|
|
||||||
s.components = components
|
s.components = components
|
||||||
s.screens = screens
|
s.screens = screens
|
||||||
|
@ -255,14 +254,14 @@ const renameScreen = store => (oldname, newname) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const savePage = store => async page => {
|
const savePage = store => async page => {
|
||||||
store.update(s => {
|
store.update(state => {
|
||||||
if (s.currentFrontEndType !== "page" || !s.currentPageName) {
|
if (s.currentFrontEndType !== "page" || !s.currentPageName) {
|
||||||
return s
|
return state
|
||||||
}
|
}
|
||||||
|
|
||||||
s.pages[s.currentPageName] = page
|
s.pages[s.currentPageName] = page
|
||||||
_savePage(s)
|
_savePage(s)
|
||||||
return s
|
return state
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,7 +329,6 @@ const setCurrentPage = store => pageName => {
|
||||||
* @param {string} presetName - name of the component preset if defined
|
* @param {string} presetName - name of the component preset if defined
|
||||||
*/
|
*/
|
||||||
const addChildComponent = store => (componentToAdd, presetName) => {
|
const addChildComponent = store => (componentToAdd, presetName) => {
|
||||||
// componentToAdd looks like: @budibase/standard-components/container
|
|
||||||
store.update(state => {
|
store.update(state => {
|
||||||
function findSlot(component_array) {
|
function findSlot(component_array) {
|
||||||
for (let i = 0; i < component_array.length; i += 1) {
|
for (let i = 0; i < component_array.length; i += 1) {
|
||||||
|
@ -356,7 +354,13 @@ const addChildComponent = store => (componentToAdd, presetName) => {
|
||||||
: state.components[componentToAdd]
|
: state.components[componentToAdd]
|
||||||
|
|
||||||
const presetProps = presetName ? component.presets[presetName] : {}
|
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(
|
state.currentComponentInfo._children = state.currentComponentInfo._children.concat(
|
||||||
newComponent.props
|
newComponent.props
|
||||||
|
|
|
@ -25,8 +25,7 @@ export const createProps = (componentDefinition, derivedFromProps) => {
|
||||||
_id: uuid(),
|
_id: uuid(),
|
||||||
_component: componentDefinition._component,
|
_component: componentDefinition._component,
|
||||||
_styles: { position: {}, layout: {} },
|
_styles: { position: {}, layout: {} },
|
||||||
_code: "",
|
_code: ""
|
||||||
_instanceId: "dev-1" // TODO fix
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const errors = []
|
const errors = []
|
||||||
|
|
|
@ -12,29 +12,12 @@ export const loadBudibase = async opts => {
|
||||||
const frontendDefinition = _window["##BUDIBASE_FRONTEND_DEFINITION##"]
|
const frontendDefinition = _window["##BUDIBASE_FRONTEND_DEFINITION##"]
|
||||||
const uiFunctions = _window["##BUDIBASE_FRONTEND_FUNCTIONS##"]
|
const uiFunctions = _window["##BUDIBASE_FRONTEND_FUNCTIONS##"]
|
||||||
|
|
||||||
// TODO: Update
|
// TODO: update
|
||||||
const user = {}
|
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 componentLibraryModules = opts && opts.componentLibraries || {}
|
||||||
|
|
||||||
const libraries = frontendDefinition.libraries || [
|
const libraries = frontendDefinition.libraries || []
|
||||||
"@budibase/materialdesign-components",
|
|
||||||
"@budibase/standard-components"
|
|
||||||
]
|
|
||||||
|
|
||||||
for (let library of libraries) {
|
for (let library of libraries) {
|
||||||
// fetch the JavaScript for the component libraries from the server
|
// fetch the JavaScript for the component libraries from the server
|
||||||
|
|
|
@ -93,6 +93,10 @@ const buildFrontendAppDefinition = async (config, appname, pageName, pkg) => {
|
||||||
appRootPath: appRootPath,
|
appRootPath: appRootPath,
|
||||||
page: pkg.page,
|
page: pkg.page,
|
||||||
screens: pkg.screens,
|
screens: pkg.screens,
|
||||||
|
libraries: [
|
||||||
|
"@budibase/materialdesign-components",
|
||||||
|
"@budibase/standard-components"
|
||||||
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
await writeFile(
|
await writeFile(
|
||||||
|
|
Loading…
Reference in New Issue