diff --git a/.github/workflows/release-charts.yml b/.github/workflows/release-charts.yml index 933edd36b9..1ad5a54edd 100644 --- a/.github/workflows/release-charts.yml +++ b/.github/workflows/release-charts.yml @@ -12,6 +12,12 @@ jobs: with: fetch-depth: 0 + - uses: actions/setup-node@v1 + with: + node-version: 14.x + - run: yarn + - run: yarn bootstrap + - name: 'Get Previous tag' id: previoustag uses: "WyriHaximus/github-action-get-previous-tag@v1" diff --git a/charts/budibase/Chart.yaml b/charts/budibase/Chart.yaml index 602ffbf420..cec5af2914 100644 --- a/charts/budibase/Chart.yaml +++ b/charts/budibase/Chart.yaml @@ -11,8 +11,8 @@ sources: - https://github.com/Budibase/budibase - https://budibase.com type: application -version: 0.2.6 -appVersion: 1.0.10 +version: 1.0.0 +appVersion: 1.0.20 dependencies: - name: couchdb version: 3.3.4 diff --git a/lerna.json b/lerna.json index 66fd740bc5..09d7a43df9 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "1.0.19-alpha.3", + "version": "1.0.22", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/auth/package.json b/packages/auth/package.json index 9f096630c9..74897f1b2b 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/auth", - "version": "1.0.19-alpha.3", + "version": "1.0.22", "description": "Authentication middlewares for budibase builder and apps", "main": "src/index.js", "author": "Budibase", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index b9f779409b..d86371c554 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/bbui", "description": "A UI solution used in the different Budibase projects.", - "version": "1.0.19-alpha.3", + "version": "1.0.22", "license": "MPL-2.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", diff --git a/packages/builder/package.json b/packages/builder/package.json index 1a19246ba0..85e43edaaf 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "1.0.19-alpha.3", + "version": "1.0.22", "license": "GPL-3.0", "private": true, "scripts": { @@ -65,10 +65,10 @@ } }, "dependencies": { - "@budibase/bbui": "^1.0.19-alpha.3", - "@budibase/client": "^1.0.19-alpha.3", + "@budibase/bbui": "^1.0.22", + "@budibase/client": "^1.0.22", "@budibase/colorpicker": "1.1.2", - "@budibase/string-templates": "^1.0.19-alpha.3", + "@budibase/string-templates": "^1.0.22", "@sentry/browser": "5.19.1", "@spectrum-css/page": "^3.0.1", "@spectrum-css/vars": "^3.0.1", diff --git a/packages/cli/package.json b/packages/cli/package.json index 931123b962..de319745a1 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "1.0.19-alpha.3", + "version": "1.0.22", "description": "Budibase CLI, for developers, self hosting and migrations.", "main": "src/index.js", "bin": { diff --git a/packages/client/package.json b/packages/client/package.json index 8a5fdfdff0..2f40808ae0 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "1.0.19-alpha.3", + "version": "1.0.22", "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.0.19-alpha.3", + "@budibase/bbui": "^1.0.22", "@budibase/standard-components": "^0.9.139", - "@budibase/string-templates": "^1.0.19-alpha.3", + "@budibase/string-templates": "^1.0.22", "regexparam": "^1.3.0", "shortid": "^2.2.15", "svelte-spa-router": "^3.0.5" diff --git a/packages/client/src/components/Router.svelte b/packages/client/src/components/Router.svelte index 95f52236a4..49cbc3f821 100644 --- a/packages/client/src/components/Router.svelte +++ b/packages/client/src/components/Router.svelte @@ -1,8 +1,9 @@ {#key config.id} diff --git a/packages/client/src/components/overlay/PeekScreenDisplay.svelte b/packages/client/src/components/overlay/PeekScreenDisplay.svelte index 51ff4412dc..7d3531d236 100644 --- a/packages/client/src/components/overlay/PeekScreenDisplay.svelte +++ b/packages/client/src/components/overlay/PeekScreenDisplay.svelte @@ -4,6 +4,7 @@ dataSourceStore, notificationStore, routeStore, + stateStore, } from "stores" import { Modal, ModalContent, ActionButton } from "@budibase/bbui" import { onDestroy } from "svelte" @@ -12,12 +13,13 @@ NOTIFICATION: "notification", CLOSE_SCREEN_MODAL: "close-screen-modal", INVALIDATE_DATASOURCE: "invalidate-datasource", + UPDATE_STATE: "update-state", } let iframe let listenersAttached = false - const invalidateDataSource = event => { + const proxyInvalidation = event => { const { dataSourceId } = event.detail dataSourceStore.actions.invalidateDataSource(dataSourceId) } @@ -27,14 +29,28 @@ notificationStore.actions.send(message, type, icon) } + const proxyStateUpdate = event => { + const { type, key, value, persist } = event.detail + if (type === "set") { + stateStore.actions.setValue(key, value, persist) + } else if (type === "delete") { + stateStore.actions.deleteValue(key) + } + } + function receiveMessage(message) { const handlers = { [MessageTypes.NOTIFICATION]: () => { proxyNotification(message.data) }, - [MessageTypes.CLOSE_SCREEN_MODAL]: peekStore.actions.hidePeek, + [MessageTypes.CLOSE_SCREEN_MODAL]: () => { + peekStore.actions.hidePeek() + }, [MessageTypes.INVALIDATE_DATASOURCE]: () => { - invalidateDataSource(message.data) + proxyInvalidation(message.data) + }, + [MessageTypes.UPDATE_STATE]: () => { + proxyStateUpdate(message.data) }, } diff --git a/packages/client/src/stores/dataSource.js b/packages/client/src/stores/dataSource.js index ee615b8bfb..efec755b99 100644 --- a/packages/client/src/stores/dataSource.js +++ b/packages/client/src/stores/dataSource.js @@ -1,6 +1,7 @@ import { writable, get } from "svelte/store" import { fetchTableDefinition } from "../api" import { FieldTypes } from "../constants" +import { routeStore } from "./routes" export const createDataSourceStore = () => { const store = writable([]) @@ -60,10 +61,12 @@ export const createDataSourceStore = () => { // Emit this as a window event, so parent screens which are iframing us in // can also invalidate the same datasource - window.parent.postMessage({ - type: "close-screen-modal", - detail: { dataSourceId }, - }) + if (get(routeStore).queryParams?.peek) { + window.parent.postMessage({ + type: "invalidate-datasource", + detail: { dataSourceId }, + }) + } let invalidations = [dataSourceId] diff --git a/packages/client/src/stores/peek.js b/packages/client/src/stores/peek.js index df41f5daff..83974b09f3 100644 --- a/packages/client/src/stores/peek.js +++ b/packages/client/src/stores/peek.js @@ -1,4 +1,5 @@ -import { writable } from "svelte/store" +import { writable, get } from "svelte/store" +import { stateStore } from "./state.js" const initialState = { showPeek: false, @@ -14,7 +15,10 @@ const createPeekStore = () => { let href = url let external = !url.startsWith("/") if (!external) { - href = `${window.location.href.split("#")[0]}#${url}?peek=true` + const state = get(stateStore) + const serialised = encodeURIComponent(btoa(JSON.stringify(state))) + const query = `peek=true&state=${serialised}` + href = `${window.location.href.split("#")[0]}#${url}?${query}` } store.set({ showPeek: true, diff --git a/packages/client/src/stores/state.js b/packages/client/src/stores/state.js index ce977c4333..0297b4c532 100644 --- a/packages/client/src/stores/state.js +++ b/packages/client/src/stores/state.js @@ -1,9 +1,9 @@ import { writable, get, derived } from "svelte/store" import { localStorageStore } from "builder/src/builderStore/store/localStorage" -import { appStore } from "./app" const createStateStore = () => { - const localStorageKey = `${get(appStore).appId}.state` + const appId = window["##BUDIBASE_APP_ID##"] || "app" + const localStorageKey = `${appId}.state` const persistentStore = localStorageStore(localStorageKey, {}) // Initialise the temp store to mirror the persistent store @@ -34,6 +34,9 @@ const createStateStore = () => { }) } + // Initialises the temporary state store with a certain value + const initialise = tempStore.set + // Derive the combination of both persisted and non persisted stores const store = derived( [tempStore, persistentStore], @@ -47,7 +50,7 @@ const createStateStore = () => { return { subscribe: store.subscribe, - actions: { setValue, deleteValue }, + actions: { setValue, deleteValue, initialise }, } } diff --git a/packages/client/src/utils/buttonActions.js b/packages/client/src/utils/buttonActions.js index 5ee571ae5d..9c6ae73c1f 100644 --- a/packages/client/src/utils/buttonActions.js +++ b/packages/client/src/utils/buttonActions.js @@ -116,6 +116,15 @@ const updateStateHandler = action => { } else if (type === "delete") { stateStore.actions.deleteValue(key) } + + // Emit this as an event so that parent windows which are iframing us in + // can also update their state + if (get(routeStore).queryParams?.peek) { + window.parent.postMessage({ + type: "update-state", + detail: { type, key, value, persist }, + }) + } } const handlerMap = { diff --git a/packages/server/package.json b/packages/server/package.json index 7205c1173e..97ab577241 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "1.0.19-alpha.3", + "version": "1.0.22", "description": "Budibase Web Server", "main": "src/index.ts", "repository": { @@ -70,9 +70,9 @@ "license": "GPL-3.0", "dependencies": { "@apidevtools/swagger-parser": "^10.0.3", - "@budibase/auth": "^1.0.19-alpha.3", - "@budibase/client": "^1.0.19-alpha.3", - "@budibase/string-templates": "^1.0.19-alpha.3", + "@budibase/auth": "^1.0.22", + "@budibase/client": "^1.0.22", + "@budibase/string-templates": "^1.0.22", "@bull-board/api": "^3.7.0", "@bull-board/koa": "^3.7.0", "@elastic/elasticsearch": "7.10.0", diff --git a/packages/server/src/threads/automation.js b/packages/server/src/threads/automation.js index 11ee28dbe8..fc9e2a21fc 100644 --- a/packages/server/src/threads/automation.js +++ b/packages/server/src/threads/automation.js @@ -1,6 +1,5 @@ -// when thread starts, make sure it is recorded +require("./utils").threadSetup() const env = require("../environment") -env.setInThread() const actions = require("../automations/actions") const automationUtils = require("../automations/automationUtils") const AutomationEmitter = require("../events/AutomationEmitter") diff --git a/packages/server/src/threads/query.js b/packages/server/src/threads/query.js index 9645bfcd47..f8d713e6a2 100644 --- a/packages/server/src/threads/query.js +++ b/packages/server/src/threads/query.js @@ -1,6 +1,4 @@ -// when thread starts, make sure it is recorded -const env = require("../environment") -env.setInThread() +require("./utils").threadSetup() const ScriptRunner = require("../utilities/scriptRunner") const { integrations } = require("../integrations") diff --git a/packages/server/src/threads/utils.js b/packages/server/src/threads/utils.js new file mode 100644 index 0000000000..48b40d7002 --- /dev/null +++ b/packages/server/src/threads/utils.js @@ -0,0 +1,13 @@ +const env = require("../environment") +const CouchDB = require("../db") +const { init } = require("@budibase/auth") + +exports.threadSetup = () => { + // don't run this if not threading + if (env.isTest() || env.DISABLE_THREADING) { + return + } + // when thread starts, make sure it is recorded + env.setInThread() + init(CouchDB) +} diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index 1cc72023df..005d6304fe 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "1.0.19-alpha.3", + "version": "1.0.22", "description": "Handlebars wrapper for Budibase templating.", "main": "src/index.cjs", "module": "dist/bundle.mjs", diff --git a/packages/worker/package.json b/packages/worker/package.json index 3d2c314091..f1e09ebf60 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "1.0.19-alpha.3", + "version": "1.0.22", "description": "Budibase background service", "main": "src/index.js", "repository": { @@ -29,8 +29,8 @@ "author": "Budibase", "license": "GPL-3.0", "dependencies": { - "@budibase/auth": "^1.0.19-alpha.3", - "@budibase/string-templates": "^1.0.19-alpha.3", + "@budibase/auth": "^1.0.22", + "@budibase/string-templates": "^1.0.22", "@koa/router": "^8.0.0", "@sentry/node": "^6.0.0", "@techpass/passport-openidconnect": "^0.3.0",