From 8e557696c95ed6299491fa31a110bb5c91d0961e Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Wed, 19 Jul 2023 17:11:15 +0100 Subject: [PATCH] backmerge master --- .github/workflows/release-master.yml | 2 +- .github/workflows/release-selfhost.yml | 6 +-- .github/workflows/release-singleimage.yml | 4 +- charts/budibase/values.yaml | 2 +- lerna.json | 2 +- .../SetupPanel/AutomationBlockSetup.svelte | 46 ++++++++++++++----- .../common/CodeEditor/CodeEditor.svelte | 29 +++++++----- packages/client/src/components/Block.svelte | 19 ++++---- .../src/components/BlockComponent.svelte | 10 ++-- .../components/app/blocks/CardsBlock.svelte | 2 +- .../components/app/blocks/TableBlock.svelte | 2 +- packages/client/src/utils/buttonActions.js | 2 +- scripts/versionCommit.sh | 2 +- 13 files changed, 81 insertions(+), 47 deletions(-) diff --git a/.github/workflows/release-master.yml b/.github/workflows/release-master.yml index 9a86f50c044..c0e012bb27e 100644 --- a/.github/workflows/release-master.yml +++ b/.github/workflows/release-master.yml @@ -98,7 +98,7 @@ jobs: git fetch mkdir sync echo "Packaging chart to sync dir" - helm package charts/budibase --version 0.0.0-master --app-version v"$RELEASE_VERSION" --destination sync + helm package charts/budibase --version 0.0.0-master --app-version "$RELEASE_VERSION" --destination sync echo "Packaging successful" git checkout gh-pages echo "Indexing helm repo" diff --git a/.github/workflows/release-selfhost.yml b/.github/workflows/release-selfhost.yml index f4524e99dc7..39ee8127266 100644 --- a/.github/workflows/release-selfhost.yml +++ b/.github/workflows/release-selfhost.yml @@ -43,7 +43,7 @@ jobs: run: | docker login -u $DOCKER_USER -p $DOCKER_PASSWORD - release_tag=v${{ env.RELEASE_VERSION }} + release_tag=${{ env.RELEASE_VERSION }} # Pull apps and worker images docker pull budibase/apps:$release_tag @@ -108,8 +108,8 @@ jobs: - name: Perform Github Release uses: softprops/action-gh-release@v1 with: - name: v${{ env.RELEASE_VERSION }} - tag_name: v${{ env.RELEASE_VERSION }} + name: ${{ env.RELEASE_VERSION }} + tag_name: ${{ env.RELEASE_VERSION }} generate_release_notes: true files: | packages/cli/build/cli-win.exe diff --git a/.github/workflows/release-singleimage.yml b/.github/workflows/release-singleimage.yml index 5408b48ef8b..92f21bd6493 100644 --- a/.github/workflows/release-singleimage.yml +++ b/.github/workflows/release-singleimage.yml @@ -71,7 +71,7 @@ jobs: context: . push: true platforms: linux/amd64,linux/arm64 - tags: budibase/budibase,budibase/budibase:v${{ env.RELEASE_VERSION }} + tags: budibase/budibase,budibase/budibase:${{ env.RELEASE_VERSION }} file: ./hosting/single/Dockerfile - name: Tag and release Budibase Azure App Service docker image uses: docker/build-push-action@v2 @@ -80,5 +80,5 @@ jobs: push: true platforms: linux/amd64 build-args: TARGETBUILD=aas - tags: budibase/budibase-aas,budibase/budibase-aas:v${{ env.RELEASE_VERSION }} + tags: budibase/budibase-aas,budibase/budibase-aas:${{ env.RELEASE_VERSION }} file: ./hosting/single/Dockerfile diff --git a/charts/budibase/values.yaml b/charts/budibase/values.yaml index 2d89e81b7f3..74e4c52654e 100644 --- a/charts/budibase/values.yaml +++ b/charts/budibase/values.yaml @@ -209,7 +209,7 @@ services: # Override values in couchDB subchart couchdb: ## clusterSize is the initial size of the CouchDB cluster. - clusterSize: 3 + clusterSize: 1 allowAdminParty: false # Secret Management diff --git a/lerna.json b/lerna.json index a2456706d10..551b1f60f24 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.8.12-alpha.5", + "version": "2.8.15", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte index 823dcc432b3..cece075860b 100644 --- a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte +++ b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte @@ -15,6 +15,7 @@ Icon, Checkbox, DatePicker, + Detail, } from "@budibase/bbui" import CreateWebhookModal from "components/automation/Shared/CreateWebhookModal.svelte" import { automationStore, selectedAutomation } from "builderStore" @@ -32,7 +33,7 @@ import CodeEditor from "components/common/CodeEditor/CodeEditor.svelte" import { bindingsToCompletions, - jsAutocomplete, + hbAutocomplete, EditorModes, } from "components/common/CodeEditor" import FilterDrawer from "components/design/settings/controls/FilterEditor/FilterDrawer.svelte" @@ -55,6 +56,7 @@ let drawer let fillWidth = true let inputData + let codeBindingOpen = false $: filters = lookForFilters(schemaProperties) || [] $: tempFilters = filters @@ -70,6 +72,13 @@ $: queryLimit = tableId?.includes("datasource") ? "∞" : "1000" $: isTrigger = block?.type === "TRIGGER" $: isUpdateRow = stepId === ActionStepID.UPDATE_ROW + $: codeMode = + stepId === "EXECUTE_BASH" ? EditorModes.Handlebars : EditorModes.JS + + $: stepCompletions = + codeMode === EditorModes.Handlebars + ? [hbAutocomplete([...bindingsToCompletions(bindings, codeMode)])] + : [] /** * TODO - Remove after November 2023 @@ -489,6 +498,18 @@ /> {:else if value.customType === "code"} + {#if codeMode == EditorModes.JS} + (codeBindingOpen = !codeBindingOpen)} + quiet + icon={codeBindingOpen ? "ChevronDown" : "ChevronRight"} + > + Bindings + + {#if codeBindingOpen} +
{JSON.stringify(bindings, null, 2)}
+ {/if} + {/if} { @@ -496,19 +517,22 @@ onChange({ detail: e.detail }, key) inputData[key] = e.detail }} - completions={[ - jsAutocomplete([ - ...bindingsToCompletions(bindings, EditorModes.JS), - ]), - ]} - mode={EditorModes.JS} + completions={stepCompletions} + mode={codeMode} + autocompleteEnabled={codeMode != EditorModes.JS} height={500} />
- -
-
Add available bindings by typing $
-
+ {#if codeMode == EditorModes.Handlebars} + +
+
+ Add available bindings by typing + }} + +
+
+ {/if}
{:else if value.customType === "loopOption"} diff --git a/packages/builder/src/components/common/CodeEditor/CodeEditor.svelte b/packages/builder/src/components/common/CodeEditor/CodeEditor.svelte index e68d3fd8424..74f160710f7 100644 --- a/packages/builder/src/components/common/CodeEditor/CodeEditor.svelte +++ b/packages/builder/src/components/common/CodeEditor/CodeEditor.svelte @@ -51,6 +51,7 @@ export let mode = EditorModes.Handlebars export let value = "" export let placeholder = null + export let autocompleteEnabled = true // Export a function to expose caret position export const getCaretPosition = () => { @@ -150,12 +151,6 @@ syntaxHighlighting(oneDarkHighlightStyle, { fallback: true }), highlightActiveLineGutter(), highlightSpecialChars(), - autocompletion({ - override: [...completions], - closeOnBlur: true, - icons: false, - optionClass: () => "autocomplete-option", - }), EditorView.lineWrapping, EditorView.updateListener.of(v => { const docStr = v.state.doc?.toString() @@ -178,11 +173,16 @@ const buildExtensions = base => { const complete = [...base] - if (mode.name == "javascript") { - complete.push(javascript()) - complete.push(highlightWhitespace()) - complete.push(lineNumbers()) - complete.push(foldGutter()) + + if (autocompleteEnabled) { + complete.push( + autocompletion({ + override: [...completions], + closeOnBlur: true, + icons: false, + optionClass: () => "autocomplete-option", + }) + ) complete.push( EditorView.inputHandler.of((view, from, to, insert) => { if (insert === "$") { @@ -212,6 +212,13 @@ ) } + if (mode.name == "javascript") { + complete.push(javascript()) + complete.push(highlightWhitespace()) + complete.push(lineNumbers()) + complete.push(foldGutter()) + } + if (placeholder) { complete.push(placeholderFn(placeholder)) } diff --git a/packages/client/src/components/Block.svelte b/packages/client/src/components/Block.svelte index b72ff81b496..a7390650151 100644 --- a/packages/client/src/components/Block.svelte +++ b/packages/client/src/components/Block.svelte @@ -8,27 +8,31 @@ let structureLookupMap = {} - const registerBlockComponent = (id, order, parentId, instance) => { + const registerBlockComponent = (id, parentId, order, instance) => { // Ensure child map exists if (!structureLookupMap[parentId]) { structureLookupMap[parentId] = {} } // Add this instance in this order, overwriting any existing instance in // this order in case of repeaters - structureLookupMap[parentId][order] = instance + structureLookupMap[parentId][id] = { order, instance } } - const unregisterBlockComponent = (order, parentId) => { + const unregisterBlockComponent = (id, parentId) => { // Ensure child map exists if (!structureLookupMap[parentId]) { return } - delete structureLookupMap[parentId][order] + delete structureLookupMap[parentId][id] } const eject = () => { // Start the new structure with the root component - let definition = structureLookupMap[$component.id][0] + const rootMap = structureLookupMap[$component.id] || {} + let definition = Object.values(rootMap)[0]?.instance + if (!definition) { + return + } // Copy styles from block to root component definition._styles = { @@ -49,10 +53,7 @@ const attachChildren = (rootComponent, map) => { // Transform map into children array let id = rootComponent._id - const children = Object.entries(map[id] || {}).map(([order, instance]) => ({ - order, - instance, - })) + const children = Object.values(map[id] || {}) if (!children.length) { return } diff --git a/packages/client/src/components/BlockComponent.svelte b/packages/client/src/components/BlockComponent.svelte index 4f720e29312..24d9b4dee41 100644 --- a/packages/client/src/components/BlockComponent.svelte +++ b/packages/client/src/components/BlockComponent.svelte @@ -23,6 +23,8 @@ // Create a fake component instance so that we can use the core Component // to render this part of the block, taking advantage of binding enrichment $: id = `${block.id}-${context ?? rand}` + $: parentId = $component?.id + $: inBuilder = $builderStore.inBuilder $: instance = { _component: `@budibase/standard-components/${type}`, _id: id, @@ -38,14 +40,14 @@ // Register this block component if we're inside the builder so it can be // ejected later $: { - if ($builderStore.inBuilder) { - block.registerComponent(id, order ?? 0, $component?.id, instance) + if (inBuilder) { + block.registerComponent(id, parentId, order ?? 0, instance) } } onDestroy(() => { - if ($builderStore.inBuilder) { - block.unregisterComponent(order ?? 0, $component?.id) + if (inBuilder) { + block.unregisterComponent(id, parentId) } }) diff --git a/packages/client/src/components/app/blocks/CardsBlock.svelte b/packages/client/src/components/app/blocks/CardsBlock.svelte index bbe54867eed..3e48247f927 100644 --- a/packages/client/src/components/app/blocks/CardsBlock.svelte +++ b/packages/client/src/components/app/blocks/CardsBlock.svelte @@ -126,7 +126,7 @@ order={1} > {#if enrichedSearchColumns?.length} - {#each enrichedSearchColumns as column, idx} + {#each enrichedSearchColumns as column, idx (column.name)} {#if enrichedSearchColumns?.length} - {#each enrichedSearchColumns as column, idx} + {#each enrichedSearchColumns as column, idx (column.name)} { actions.slice(i + 1), newContext ) - resolve(await next()) + resolve(typeof next === "function" ? await next() : true) } else { resolve(false) } diff --git a/scripts/versionCommit.sh b/scripts/versionCommit.sh index 71c931d7364..86db0136e75 100755 --- a/scripts/versionCommit.sh +++ b/scripts/versionCommit.sh @@ -13,6 +13,6 @@ node ./bumpVersion.js $1 NEW_VERSION=$(node -p "require('../lerna.json').version") git add ../lerna.json git commit -m "Bump version to $NEW_VERSION" -git tag v$NEW_VERSION +git tag $NEW_VERSION git push git push --tags \ No newline at end of file