bugfix: component libraries loaded incorrectly
This commit is contained in:
parent
dbb151e86e
commit
5d0f9b788c
|
@ -1,6 +1,11 @@
|
||||||
|
import { flatten, values, uniq, map } from "lodash/fp"
|
||||||
|
import { pipe } from "../common/core"
|
||||||
|
|
||||||
export const loadLibs = async (appName, appPackage) => {
|
export const loadLibs = async (appName, appPackage) => {
|
||||||
const allLibraries = {}
|
const allLibraries = {}
|
||||||
for (let lib of appPackage.pages.componentLibraries) {
|
|
||||||
|
for (let lib of libsFromPages(appPackage.pages)) {
|
||||||
|
|
||||||
const libModule = await import(makeLibraryUrl(appName, lib))
|
const libModule = await import(makeLibraryUrl(appName, lib))
|
||||||
allLibraries[lib] = libModule
|
allLibraries[lib] = libModule
|
||||||
}
|
}
|
||||||
|
@ -10,7 +15,7 @@ export const loadLibs = async (appName, appPackage) => {
|
||||||
|
|
||||||
export const loadLibUrls = (appName, appPackage) => {
|
export const loadLibUrls = (appName, appPackage) => {
|
||||||
const allLibraries = []
|
const allLibraries = []
|
||||||
for (let lib of appPackage.pages.componentLibraries) {
|
for (let lib of libsFromPages(appPackage.pages)) {
|
||||||
const libUrl = makeLibraryUrl(appName, lib)
|
const libUrl = makeLibraryUrl(appName, lib)
|
||||||
allLibraries.push({ libName: lib, importPath: libUrl })
|
allLibraries.push({ libName: lib, importPath: libUrl })
|
||||||
}
|
}
|
||||||
|
@ -25,3 +30,11 @@ export const loadLib = async (appName, lib, allLibs) => {
|
||||||
|
|
||||||
export const makeLibraryUrl = (appName, lib) =>
|
export const makeLibraryUrl = (appName, lib) =>
|
||||||
`/_builder/${appName}/componentlibrary?lib=${encodeURI(lib)}`
|
`/_builder/${appName}/componentlibrary?lib=${encodeURI(lib)}`
|
||||||
|
|
||||||
|
export const libsFromPages = pages => pipe(pages, [
|
||||||
|
values,
|
||||||
|
map(p => p.componentLibraries),
|
||||||
|
flatten,
|
||||||
|
uniq
|
||||||
|
])
|
||||||
|
|
||||||
|
|
|
@ -140,8 +140,6 @@ const initialise = (store, initial) => async () => {
|
||||||
])
|
])
|
||||||
|
|
||||||
pkg.pages = {
|
pkg.pages = {
|
||||||
componentLibraries: ["@budibase/standard-components"],
|
|
||||||
stylesheets: [],
|
|
||||||
main: {
|
main: {
|
||||||
...pkg.pages.main,
|
...pkg.pages.main,
|
||||||
_screens: Object.values(main_screens),
|
_screens: Object.values(main_screens),
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
import IconButton from "../common/IconButton.svelte"
|
import IconButton from "../common/IconButton.svelte"
|
||||||
import { libraryDependencies } from "./pagesParsing/findDependencies"
|
import { libraryDependencies } from "./pagesParsing/findDependencies"
|
||||||
import UIkit from "uikit"
|
import UIkit from "uikit"
|
||||||
|
import { libsFromPages } from "../builderStore/loadComponentLibraries"
|
||||||
let addNewLib = ""
|
let addNewLib = ""
|
||||||
let addNewStylesheet = ""
|
let addNewStylesheet = ""
|
||||||
let modalElement
|
let modalElement
|
||||||
|
@ -61,7 +61,7 @@
|
||||||
<Button color="primary-outline" on:click={addLib}>Add</Button>
|
<Button color="primary-outline" on:click={addLib}>Add</Button>
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
{#each $store.pages.componentLibraries as lib}
|
{#each $store.pages[$store.currentPageName].componentLibraries as lib}
|
||||||
<div>
|
<div>
|
||||||
<span class="row-text">{lib}</span>
|
<span class="row-text">{lib}</span>
|
||||||
<IconButton icon="x" on:click={() => removeLibrary(lib)} />
|
<IconButton icon="x" on:click={() => removeLibrary(lib)} />
|
||||||
|
@ -79,7 +79,7 @@
|
||||||
</Button>
|
</Button>
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
{#each $store.pages.stylesheets as stylesheet}
|
{#each $store.pages[$store.currentPageName].stylesheets as stylesheet}
|
||||||
<div>
|
<div>
|
||||||
<span class="row-text">{stylesheet}</span>
|
<span class="row-text">{stylesheet}</span>
|
||||||
<IconButton
|
<IconButton
|
||||||
|
|
Loading…
Reference in New Issue