1
0
Fork 0
mirror of synced 2024-06-02 02:25:17 +12:00

Merge branch 'develop' of github.com:Budibase/budibase into plugins-dev-experience

This commit is contained in:
mike12345567 2022-08-31 16:24:10 +01:00
commit f2c79c1f3b
21 changed files with 211 additions and 117 deletions

View file

@ -1,5 +1,5 @@
{
"version": "1.2.58-alpha.3",
"version": "1.2.58-alpha.4",
"npmClient": "yarn",
"packages": [
"packages/*"

View file

@ -1,6 +1,6 @@
{
"name": "@budibase/backend-core",
"version": "1.2.58-alpha.3",
"version": "1.2.58-alpha.4",
"description": "Budibase backend core libraries used in server and worker",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
@ -20,7 +20,7 @@
"test:watch": "jest --watchAll"
},
"dependencies": {
"@budibase/types": "1.2.58-alpha.3",
"@budibase/types": "1.2.58-alpha.4",
"@techpass/passport-openidconnect": "0.3.2",
"aws-sdk": "2.1030.0",
"bcrypt": "5.0.1",

View file

@ -1,7 +1,7 @@
{
"name": "@budibase/bbui",
"description": "A UI solution used in the different Budibase projects.",
"version": "1.2.58-alpha.3",
"version": "1.2.58-alpha.4",
"license": "MPL-2.0",
"svelte": "src/index.js",
"module": "dist/bbui.es.js",
@ -38,7 +38,7 @@
],
"dependencies": {
"@adobe/spectrum-css-workflow-icons": "^1.2.1",
"@budibase/string-templates": "1.2.58-alpha.3",
"@budibase/string-templates": "1.2.58-alpha.4",
"@spectrum-css/actionbutton": "^1.0.1",
"@spectrum-css/actiongroup": "^1.0.1",
"@spectrum-css/avatar": "^3.0.2",

View file

@ -1,6 +1,6 @@
{
"name": "@budibase/builder",
"version": "1.2.58-alpha.3",
"version": "1.2.58-alpha.4",
"license": "GPL-3.0",
"private": true,
"scripts": {
@ -69,10 +69,10 @@
}
},
"dependencies": {
"@budibase/bbui": "1.2.58-alpha.3",
"@budibase/client": "1.2.58-alpha.3",
"@budibase/frontend-core": "1.2.58-alpha.3",
"@budibase/string-templates": "1.2.58-alpha.3",
"@budibase/bbui": "1.2.58-alpha.4",
"@budibase/client": "1.2.58-alpha.4",
"@budibase/frontend-core": "1.2.58-alpha.4",
"@budibase/string-templates": "1.2.58-alpha.4",
"@sentry/browser": "5.19.1",
"@spectrum-css/page": "^3.0.1",
"@spectrum-css/vars": "^3.0.1",

View file

@ -19,7 +19,6 @@ import {
makeComponentUnique,
} from "../componentUtils"
import { Helpers } from "@budibase/bbui"
import { DefaultAppTheme, LAYOUT_NAMES } from "../../constants"
import { Utils } from "@budibase/frontend-core"
const INITIAL_FRONTEND_STATE = {
@ -134,35 +133,6 @@ export const getFrontendStore = () => {
await integrations.init()
await queries.init()
await tables.init()
// Add navigation settings to old apps
if (!application.navigation) {
const layout = layouts.find(x => x._id === LAYOUT_NAMES.MASTER.PRIVATE)
const customTheme = application.customTheme
let navigationSettings = {
navigation: "Top",
title: application.name,
navWidth: "Large",
navBackground:
customTheme?.navBackground || DefaultAppTheme.navBackground,
navTextColor:
customTheme?.navTextColor || DefaultAppTheme.navTextColor,
}
if (layout) {
navigationSettings.hideLogo = layout.props.hideLogo
navigationSettings.hideTitle = layout.props.hideTitle
navigationSettings.title = layout.props.title || application.name
navigationSettings.logoUrl = layout.props.logoUrl
navigationSettings.links = layout.props.links
navigationSettings.navigation = layout.props.navigation || "Top"
navigationSettings.sticky = layout.props.sticky
navigationSettings.navWidth = layout.props.width || "Large"
if (navigationSettings.navigation === "None") {
navigationSettings.navigation = "Top"
}
}
await store.actions.navigation.save(navigationSettings)
}
},
theme: {
save: async theme => {

View file

@ -1,6 +1,6 @@
{
"name": "@budibase/cli",
"version": "1.2.58-alpha.3",
"version": "1.2.58-alpha.4",
"description": "Budibase CLI, for developers, self hosting and migrations.",
"main": "src/index.js",
"bin": {
@ -26,9 +26,9 @@
"outputPath": "build"
},
"dependencies": {
"@budibase/backend-core": "1.2.58-alpha.3",
"@budibase/string-templates": "1.2.58-alpha.3",
"@budibase/types": "1.2.58-alpha.3",
"@budibase/backend-core": "1.2.58-alpha.4",
"@budibase/string-templates": "1.2.58-alpha.4",
"@budibase/types": "1.2.58-alpha.4",
"axios": "0.21.2",
"chalk": "4.1.0",
"cli-progress": "3.11.2",

View file

@ -1,6 +1,6 @@
{
"name": "@budibase/client",
"version": "1.2.58-alpha.3",
"version": "1.2.58-alpha.4",
"license": "MPL-2.0",
"module": "dist/budibase-client.js",
"main": "dist/budibase-client.js",
@ -19,9 +19,9 @@
"dev:builder": "rollup -cw"
},
"dependencies": {
"@budibase/bbui": "1.2.58-alpha.3",
"@budibase/frontend-core": "1.2.58-alpha.3",
"@budibase/string-templates": "1.2.58-alpha.3",
"@budibase/bbui": "1.2.58-alpha.4",
"@budibase/frontend-core": "1.2.58-alpha.4",
"@budibase/string-templates": "1.2.58-alpha.4",
"@spectrum-css/button": "^3.0.3",
"@spectrum-css/card": "^3.0.3",
"@spectrum-css/divider": "^1.0.3",

View file

@ -1,12 +1,12 @@
{
"name": "@budibase/frontend-core",
"version": "1.2.58-alpha.3",
"version": "1.2.58-alpha.4",
"description": "Budibase frontend core libraries used in builder and client",
"author": "Budibase",
"license": "MPL-2.0",
"svelte": "src/index.js",
"dependencies": {
"@budibase/bbui": "1.2.58-alpha.3",
"@budibase/bbui": "1.2.58-alpha.4",
"lodash": "^4.17.21",
"svelte": "^3.46.2"
}

View file

@ -1,7 +1,7 @@
{
"name": "@budibase/server",
"email": "hi@budibase.com",
"version": "1.2.58-alpha.3",
"version": "1.2.58-alpha.4",
"description": "Budibase Web Server",
"main": "src/index.ts",
"repository": {
@ -77,11 +77,11 @@
"license": "GPL-3.0",
"dependencies": {
"@apidevtools/swagger-parser": "10.0.3",
"@budibase/backend-core": "1.2.58-alpha.3",
"@budibase/client": "1.2.58-alpha.3",
"@budibase/pro": "1.2.58-alpha.3",
"@budibase/string-templates": "1.2.58-alpha.3",
"@budibase/types": "1.2.58-alpha.3",
"@budibase/backend-core": "1.2.58-alpha.4",
"@budibase/client": "1.2.58-alpha.4",
"@budibase/pro": "1.2.58-alpha.4",
"@budibase/string-templates": "1.2.58-alpha.4",
"@budibase/types": "1.2.58-alpha.4",
"@bull-board/api": "3.7.0",
"@bull-board/koa": "3.9.4",
"@elastic/elasticsearch": "7.10.0",

View file

@ -47,7 +47,14 @@ import { checkAppMetadata } from "../../automations/logging"
import { getUniqueRows } from "../../utilities/usageQuota/rows"
import { quotas } from "@budibase/pro"
import { errors, events, migrations } from "@budibase/backend-core"
import { App, MigrationType } from "@budibase/types"
import {
App,
Layout,
Screen,
MigrationType,
AppNavigation,
} from "@budibase/types"
import { BASE_LAYOUT_PROP_IDS } from "../../constants/layouts"
const URL_REGEX_SLASH = /\/|\\/g
@ -243,27 +250,19 @@ const performAppCreate = async (ctx: any) => {
}
const instance = await createInstance(instanceConfig)
const appId = instance._id
const db = context.getAppDB()
let _rev
try {
// if template there will be an existing doc
const existing = await db.get(DocumentType.APP_METADATA)
_rev = existing._rev
} catch (err) {
// nothing to do
}
const newApplication: App = {
let newApplication: App = {
_id: DocumentType.APP_METADATA,
_rev,
appId: instance._id,
_rev: undefined,
appId,
type: "app",
version: packageJson.version,
componentLibraries: ["@budibase/standard-components"],
name: name,
url: url,
template: ctx.request.body.template,
instance: instance,
template: templateKey,
instance,
tenantId: getTenantId(),
updatedAt: new Date().toISOString(),
createdAt: new Date().toISOString(),
@ -285,6 +284,36 @@ const performAppCreate = async (ctx: any) => {
buttonBorderRadius: "16px",
},
}
// If we used a template or imported an app there will be an existing doc.
// Fetch and migrate some metadata from the existing app.
try {
const existing: App = await db.get(DocumentType.APP_METADATA)
const keys: (keyof App)[] = [
"_rev",
"navigation",
"theme",
"customTheme",
"icon",
]
keys.forEach(key => {
if (existing[key]) {
// @ts-ignore
newApplication[key] = existing[key]
}
})
// Migrate navigation settings and screens if required
if (existing && !existing.navigation) {
const navigation = await migrateAppNavigation()
if (navigation) {
newApplication.navigation = navigation
}
}
} catch (err) {
// Nothing to do
}
const response = await db.put(newApplication, { force: true })
newApplication._rev = response.rev
@ -567,3 +596,55 @@ export const updateAppPackage = async (appPackage: any, appId: any) => {
return newAppPackage
})
}
const migrateAppNavigation = async () => {
const db = context.getAppDB()
const existing: App = await db.get(DocumentType.APP_METADATA)
const layouts: Layout[] = await getLayouts()
const screens: Screen[] = await getScreens()
// Migrate all screens, removing custom layouts
for (let screen of screens) {
if (!screen.layoutId) {
return
}
const layout = layouts.find(layout => layout._id === screen.layoutId)
screen.layoutId = undefined
screen.showNavigation = layout?.props.navigation !== "None"
screen.width = layout?.props.width || "Large"
await db.put(screen)
}
// Migrate layout navigation settings
const { name, customTheme } = existing
const layout = layouts?.find(
(layout: Layout) => layout._id === BASE_LAYOUT_PROP_IDS.PRIVATE
)
if (layout) {
let navigationSettings: any = {
navigation: "Top",
title: name,
navWidth: "Large",
navBackground:
customTheme?.navBackground || "var(--spectrum-global-color-gray-50)",
navTextColor:
customTheme?.navTextColor || "var(--spectrum-global-color-gray-800)",
}
if (layout) {
navigationSettings.hideLogo = layout.props.hideLogo
navigationSettings.hideTitle = layout.props.hideTitle
navigationSettings.title = layout.props.title || name
navigationSettings.logoUrl = layout.props.logoUrl
navigationSettings.links = layout.props.links
navigationSettings.navigation = layout.props.navigation || "Top"
navigationSettings.sticky = layout.props.sticky
navigationSettings.navWidth = layout.props.width || "Large"
if (navigationSettings.navigation === "None") {
navigationSettings.navigation = "Top"
}
}
return navigationSettings
} else {
return null
}
}

View file

@ -17,6 +17,7 @@ const {
checkBuilderEndpoint,
} = require("./utilities/TestFunctions")
const setup = require("./utilities")
const { basicScreen, basicLayout } = setup.structures
const { AppStatus } = require("../../../db/utils")
const { events } = require("@budibase/backend-core")
@ -81,6 +82,31 @@ describe("/applications", () => {
body: { name: "My App" },
})
})
it("migrates navigation settings from old apps", async () => {
const res = await request
.post("/api/applications")
.field("name", "Old App")
.field("useTemplate", "true")
.set(config.defaultHeaders())
.attach("templateFile", "src/api/routes/tests/data/old-app.txt")
.expect("Content-Type", /json/)
.expect(200)
expect(res.body._id).toBeDefined()
expect(res.body.navigation).toBeDefined()
expect(res.body.navigation.hideLogo).toBe(true)
expect(res.body.navigation.title).toBe("Custom Title")
expect(res.body.navigation.hideLogo).toBe(true)
expect(res.body.navigation.navigation).toBe("Left")
expect(res.body.navigation.navBackground).toBe(
"var(--spectrum-global-color-blue-600)"
)
expect(res.body.navigation.navTextColor).toBe(
"var(--spectrum-global-color-gray-50)"
)
expect(events.app.created).toBeCalledTimes(1)
expect(events.app.fileImported).toBeCalledTimes(1)
})
})
describe("fetch", () => {

File diff suppressed because one or more lines are too long

View file

@ -1094,12 +1094,12 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/backend-core@1.2.58-alpha.3":
version "1.2.58-alpha.3"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.2.58-alpha.3.tgz#705986aaf2d97d15fab64ded044d30530773b541"
integrity sha512-yliV7eLHgjprjYdLhB2Tk/0ibEk5O17Mez5Nn5AqySAwsz+LwfHquaJZ8gT6uoRmgdMVLiEipBmO7cd+XQpR5A==
"@budibase/backend-core@1.2.58-alpha.4":
version "1.2.58-alpha.4"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.2.58-alpha.4.tgz#3c45ab2161b8da445edcbee009b4a80ee4da9dad"
integrity sha512-gLNxqy44PoSZWxsuJeOYxkwsDPKO0Xz5Iuz0ZNiKRDgIw0A5AavqregwmuVUHIRiWes08RY4lFjOSdozQtI15A==
dependencies:
"@budibase/types" "1.2.58-alpha.3"
"@budibase/types" "1.2.58-alpha.4"
"@techpass/passport-openidconnect" "0.3.2"
aws-sdk "2.1030.0"
bcrypt "5.0.1"
@ -1178,13 +1178,13 @@
svelte-flatpickr "^3.2.3"
svelte-portal "^1.0.0"
"@budibase/pro@1.2.58-alpha.3":
version "1.2.58-alpha.3"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.2.58-alpha.3.tgz#ae905b19db0284265a6089c4a420f89e8e5e352e"
integrity sha512-jyhv5LdP28nnuKkjoHCAfowo/gYM2Bs9gRHXVpaH2+dfZP0+0jsSHekUoE/gBDpsslCcDoh/XuqriCyvIfG7Dw==
"@budibase/pro@1.2.58-alpha.4":
version "1.2.58-alpha.4"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.2.58-alpha.4.tgz#08c1d7c08522986c7a94f8e532374d7c39a83297"
integrity sha512-Byvg/sXW9ZwAxd31Ps1ObG/D3vwtttPWr4e55O5ci7XBHDF0soenjwQlNT5FeW8T3RqMORCDUA4jqX6OMpzF0w==
dependencies:
"@budibase/backend-core" "1.2.58-alpha.3"
"@budibase/types" "1.2.58-alpha.3"
"@budibase/backend-core" "1.2.58-alpha.4"
"@budibase/types" "1.2.58-alpha.4"
"@koa/router" "8.0.8"
joi "17.6.0"
node-fetch "^2.6.1"
@ -1207,10 +1207,10 @@
svelte-apexcharts "^1.0.2"
svelte-flatpickr "^3.1.0"
"@budibase/types@1.2.58-alpha.3":
version "1.2.58-alpha.3"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.2.58-alpha.3.tgz#0a96a949b8b989723abf768e3494fe2040d3b543"
integrity sha512-jRC1zTxLi4ozEIlzRMyo1+L+WkKyU2r8m1W7FRhvUQn4+Alk4ynB6TUaSfWavDOvtg4hWg5TVzJfpVOfVjeg5w==
"@budibase/types@1.2.58-alpha.4":
version "1.2.58-alpha.4"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.2.58-alpha.4.tgz#21695d674f23f032311fb441d6a4e156b5008e0f"
integrity sha512-OsJ6neUWhjok5480M2usOoYX1s3VyAnB+5N0E0Enb4N4XG/oVRbQQbxSlPFwrmTRpIXxgW/DufL52rVGCw8wcg==
"@bull-board/api@3.7.0":
version "3.7.0"

View file

@ -1,6 +1,6 @@
{
"name": "@budibase/string-templates",
"version": "1.2.58-alpha.3",
"version": "1.2.58-alpha.4",
"description": "Handlebars wrapper for Budibase templating.",
"main": "src/index.cjs",
"module": "dist/bundle.mjs",

View file

@ -1,6 +1,6 @@
{
"name": "@budibase/types",
"version": "1.2.58-alpha.3",
"version": "1.2.58-alpha.4",
"description": "Budibase types",
"main": "dist/index.js",
"types": "dist/index.d.ts",

View file

@ -14,14 +14,11 @@ export interface App extends Document {
tenantId: string
status: string
theme?: string
customTheme?: {
buttonBorderRadius?: string
primaryColor?: string
primaryColorHover?: string
}
customTheme?: AppCustomTheme
revertableVersion?: string
navigation?: AppNavigation
automationErrors?: AppMetadataErrors
icon?: AppIcon
}
export interface AppInstance {
@ -47,3 +44,18 @@ export interface AppNavigationLink {
id?: string
roleId?: string
}
export interface AppCustomTheme {
buttonBorderRadius?: string
primaryColor?: string
primaryColorHover?: string
// Used to exist before new design UI
navTextColor?: string
navBackground?: string
}
export interface AppIcon {
name: string
color: string
}

View file

@ -1,3 +1,5 @@
import { Document } from "../document"
export interface Layout extends Document {}
export interface Layout extends Document {
props: any
}

View file

@ -1,7 +1,7 @@
import { Document } from "../document"
export interface Screen extends Document {
layoutId: string
layoutId?: string
showNavigation?: boolean
width?: string
routing: {

View file

@ -2,12 +2,12 @@ import { BaseEvent } from "./event"
export interface ScreenCreatedEvent extends BaseEvent {
screenId: string
layoutId: string
layoutId?: string
roleId: string
}
export interface ScreenDeletedEvent extends BaseEvent {
screenId: string
layoutId: string
layoutId?: string
roleId: string
}

View file

@ -1,7 +1,7 @@
{
"name": "@budibase/worker",
"email": "hi@budibase.com",
"version": "1.2.58-alpha.3",
"version": "1.2.58-alpha.4",
"description": "Budibase background service",
"main": "src/index.ts",
"repository": {
@ -35,10 +35,10 @@
"author": "Budibase",
"license": "GPL-3.0",
"dependencies": {
"@budibase/backend-core": "1.2.58-alpha.3",
"@budibase/pro": "1.2.58-alpha.3",
"@budibase/string-templates": "1.2.58-alpha.3",
"@budibase/types": "1.2.58-alpha.3",
"@budibase/backend-core": "1.2.58-alpha.4",
"@budibase/pro": "1.2.58-alpha.4",
"@budibase/string-templates": "1.2.58-alpha.4",
"@budibase/types": "1.2.58-alpha.4",
"@koa/router": "8.0.8",
"@sentry/node": "6.17.7",
"@techpass/passport-openidconnect": "0.3.2",

View file

@ -291,12 +291,12 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/backend-core@1.2.58-alpha.3":
version "1.2.58-alpha.3"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.2.58-alpha.3.tgz#705986aaf2d97d15fab64ded044d30530773b541"
integrity sha512-yliV7eLHgjprjYdLhB2Tk/0ibEk5O17Mez5Nn5AqySAwsz+LwfHquaJZ8gT6uoRmgdMVLiEipBmO7cd+XQpR5A==
"@budibase/backend-core@1.2.58-alpha.4":
version "1.2.58-alpha.4"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.2.58-alpha.4.tgz#3c45ab2161b8da445edcbee009b4a80ee4da9dad"
integrity sha512-gLNxqy44PoSZWxsuJeOYxkwsDPKO0Xz5Iuz0ZNiKRDgIw0A5AavqregwmuVUHIRiWes08RY4lFjOSdozQtI15A==
dependencies:
"@budibase/types" "1.2.58-alpha.3"
"@budibase/types" "1.2.58-alpha.4"
"@techpass/passport-openidconnect" "0.3.2"
aws-sdk "2.1030.0"
bcrypt "5.0.1"
@ -325,21 +325,21 @@
uuid "8.3.2"
zlib "1.0.5"
"@budibase/pro@1.2.58-alpha.3":
version "1.2.58-alpha.3"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.2.58-alpha.3.tgz#ae905b19db0284265a6089c4a420f89e8e5e352e"
integrity sha512-jyhv5LdP28nnuKkjoHCAfowo/gYM2Bs9gRHXVpaH2+dfZP0+0jsSHekUoE/gBDpsslCcDoh/XuqriCyvIfG7Dw==
"@budibase/pro@1.2.58-alpha.4":
version "1.2.58-alpha.4"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.2.58-alpha.4.tgz#08c1d7c08522986c7a94f8e532374d7c39a83297"
integrity sha512-Byvg/sXW9ZwAxd31Ps1ObG/D3vwtttPWr4e55O5ci7XBHDF0soenjwQlNT5FeW8T3RqMORCDUA4jqX6OMpzF0w==
dependencies:
"@budibase/backend-core" "1.2.58-alpha.3"
"@budibase/types" "1.2.58-alpha.3"
"@budibase/backend-core" "1.2.58-alpha.4"
"@budibase/types" "1.2.58-alpha.4"
"@koa/router" "8.0.8"
joi "17.6.0"
node-fetch "^2.6.1"
"@budibase/types@1.2.58-alpha.3":
version "1.2.58-alpha.3"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.2.58-alpha.3.tgz#0a96a949b8b989723abf768e3494fe2040d3b543"
integrity sha512-jRC1zTxLi4ozEIlzRMyo1+L+WkKyU2r8m1W7FRhvUQn4+Alk4ynB6TUaSfWavDOvtg4hWg5TVzJfpVOfVjeg5w==
"@budibase/types@1.2.58-alpha.4":
version "1.2.58-alpha.4"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.2.58-alpha.4.tgz#21695d674f23f032311fb441d6a4e156b5008e0f"
integrity sha512-OsJ6neUWhjok5480M2usOoYX1s3VyAnB+5N0E0Enb4N4XG/oVRbQQbxSlPFwrmTRpIXxgW/DufL52rVGCw8wcg==
"@cspotcode/source-map-consumer@0.8.0":
version "0.8.0"