From 64216f61a91f0efa7c7b8808d36cf8ae3c242f65 Mon Sep 17 00:00:00 2001 From: Dean Date: Mon, 3 Jul 2023 12:48:17 +0100 Subject: [PATCH 1/6] Added custom tab keybinding to support autocomplete and default editor tab behaviour --- .../common/CodeEditor/CodeEditor.svelte | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/packages/builder/src/components/common/CodeEditor/CodeEditor.svelte b/packages/builder/src/components/common/CodeEditor/CodeEditor.svelte index dadca85fac..e68d3fd842 100644 --- a/packages/builder/src/components/common/CodeEditor/CodeEditor.svelte +++ b/packages/builder/src/components/common/CodeEditor/CodeEditor.svelte @@ -7,6 +7,8 @@ closeBrackets, completionKeymap, closeBracketsKeymap, + acceptCompletion, + completionStatus, } from "@codemirror/autocomplete" import { EditorView, @@ -34,7 +36,8 @@ defaultKeymap, historyKeymap, history, - indentWithTab, + indentMore, + indentLess, } from "@codemirror/commands" import { Compartment } from "@codemirror/state" import { javascript } from "@codemirror/lang-javascript" @@ -107,6 +110,22 @@ let isDark = !currentTheme.includes("light") let themeConfig = new Compartment() + const indentWithTabCustom = { + key: "Tab", + run: view => { + if (completionStatus(view.state) == "active") { + acceptCompletion(view) + return true + } + indentMore(view) + return true + }, + shift: view => { + indentLess(view) + return true + }, + } + const buildKeymap = () => { const baseMap = [ ...closeBracketsKeymap, @@ -114,7 +133,7 @@ ...historyKeymap, ...foldKeymap, ...completionKeymap, - indentWithTab, + indentWithTabCustom, ] return baseMap } From db501fb10a21abf1bbbdaa21ba26197e67580286 Mon Sep 17 00:00:00 2001 From: Dean Date: Mon, 10 Jul 2023 09:30:15 +0100 Subject: [PATCH 2/6] Enabled collaboration behaviour in the automation section --- .../builderStore/store/automation/index.js | 36 +++++++++++++++++++ .../builder/src/builderStore/websocket.js | 12 ++++++- .../AutomationPanel/AutomationList.svelte | 9 +++-- .../AutomationPanel/AutomationPanel.svelte | 2 +- .../builder/app/[application]/_layout.svelte | 2 +- .../[application]/automation/_layout.svelte | 4 +++ .../server/src/api/controllers/automation.ts | 4 +++ packages/server/src/websockets/builder.ts | 15 ++++++++ packages/shared-core/src/constants.ts | 1 + 9 files changed, 79 insertions(+), 6 deletions(-) diff --git a/packages/builder/src/builderStore/store/automation/index.js b/packages/builder/src/builderStore/store/automation/index.js index 9e5516c512..9f29f61803 100644 --- a/packages/builder/src/builderStore/store/automation/index.js +++ b/packages/builder/src/builderStore/store/automation/index.js @@ -3,6 +3,7 @@ import { API } from "api" import { cloneDeep } from "lodash/fp" import { generate } from "shortid" import { selectedAutomation } from "builderStore" +import { automationStore } from "builderStore" const initialAutomationState = { automations: [], @@ -248,4 +249,39 @@ const automationActions = store => ({ } await store.actions.save(newAutomation) }, + replace: async (automationId, automation) => { + if (!automationId) { + return + } + if (!automation) { + store.update(state => { + // Remove the automation + state.automations = state.automations.filter( + x => x._id !== automationId + ) + // Select a new automation if required + if (automationId === state.selectedAutomationId) { + store.actions.select(state.automations[0]?._id) + } + return state + }) + } else { + const index = get(store).automations.findIndex( + x => x._id === automation._id + ) + if (index === -1) { + // Automation addition + store.update(state => ({ + ...state, + automations: [...state.automations, automation], + })) + } else { + // Automation update + store.update(state => { + state.automations[index] = automation + return state + }) + } + } + }, }) diff --git a/packages/builder/src/builderStore/websocket.js b/packages/builder/src/builderStore/websocket.js index 87195bed25..6121831c38 100644 --- a/packages/builder/src/builderStore/websocket.js +++ b/packages/builder/src/builderStore/websocket.js @@ -1,5 +1,10 @@ import { createWebsocket } from "@budibase/frontend-core" -import { userStore, store, deploymentStore } from "builderStore" +import { + userStore, + store, + deploymentStore, + automationStore, +} from "builderStore" import { datasources, tables } from "stores/backend" import { get } from "svelte/store" import { auth } from "stores/portal" @@ -67,5 +72,10 @@ export const createBuilderWebsocket = appId => { } ) + // Automations + socket.onOther(BuilderSocketEvent.AutomationChange, ({ id, automation }) => { + automationStore.actions.replace(id, automation) + }) + return socket } diff --git a/packages/builder/src/components/automation/AutomationPanel/AutomationList.svelte b/packages/builder/src/components/automation/AutomationPanel/AutomationList.svelte index 80d65a5cb6..9620dfe86c 100644 --- a/packages/builder/src/components/automation/AutomationPanel/AutomationList.svelte +++ b/packages/builder/src/components/automation/AutomationPanel/AutomationList.svelte @@ -1,6 +1,10 @@
- {#each $automationStore.automations.sort(aut => aut.name) as automation, idx} + {#each $automationStore.automations.sort(aut => aut.name) as automation} Date: Mon, 17 Jul 2023 12:17:42 +0100 Subject: [PATCH 4/6] Removed unnecessary check for automationid --- packages/builder/src/builderStore/store/automation/index.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/builder/src/builderStore/store/automation/index.js b/packages/builder/src/builderStore/store/automation/index.js index 01fc22100e..4ebf0515d6 100644 --- a/packages/builder/src/builderStore/store/automation/index.js +++ b/packages/builder/src/builderStore/store/automation/index.js @@ -249,9 +249,6 @@ const automationActions = store => ({ await store.actions.save(newAutomation) }, replace: async (automationId, automation) => { - if (!automationId) { - return - } if (!automation) { store.update(state => { // Remove the automation From 8526d0e921e487371acaf73ba8bcedad8baf08ea Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Mon, 17 Jul 2023 11:38:15 +0000 Subject: [PATCH 5/6] Bump version to 2.8.10-alpha.3 --- lerna.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lerna.json b/lerna.json index b7a520c00e..f916eba8b8 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.8.10-alpha.2", + "version": "2.8.10-alpha.3", "npmClient": "yarn", "packages": [ "packages/*" From 257ecf6c4be74ecd57f86705151b0acb45e73c9d Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Mon, 17 Jul 2023 13:11:47 +0000 Subject: [PATCH 6/6] Bump version to 2.8.10-alpha.4 --- lerna.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lerna.json b/lerna.json index f916eba8b8..eacb393054 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.8.10-alpha.3", + "version": "2.8.10-alpha.4", "npmClient": "yarn", "packages": [ "packages/*"