From ceecd85d7652e6a0d19a1fb43da4795b6a48b30c Mon Sep 17 00:00:00 2001 From: Dean Date: Fri, 23 Jun 2023 14:47:58 +0100 Subject: [PATCH 01/28] OIDC icon fix recreated on a new branch --- packages/backend-core/src/configs/configs.ts | 5 +++ packages/bbui/src/Form/Core/Picker.svelte | 16 ++++++-- .../auth/_components/OIDCButton.svelte | 5 ++- packages/types/src/documents/global/config.ts | 6 +++ .../src/api/controllers/global/configs.ts | 38 ++++++++++++++++++- 5 files changed, 63 insertions(+), 7 deletions(-) diff --git a/packages/backend-core/src/configs/configs.ts b/packages/backend-core/src/configs/configs.ts index 701b5bb329..49ace84d52 100644 --- a/packages/backend-core/src/configs/configs.ts +++ b/packages/backend-core/src/configs/configs.ts @@ -5,6 +5,7 @@ import { GoogleInnerConfig, OIDCConfig, OIDCInnerConfig, + OIDCLogosConfig, SCIMConfig, SCIMInnerConfig, SettingsConfig, @@ -191,6 +192,10 @@ export function getDefaultGoogleConfig(): GoogleInnerConfig | undefined { // OIDC +export async function getOIDCLogosDoc(): Promise { + return getConfig(ConfigType.OIDC_LOGOS) +} + async function getOIDCConfigDoc(): Promise { return getConfig(ConfigType.OIDC) } diff --git a/packages/bbui/src/Form/Core/Picker.svelte b/packages/bbui/src/Form/Core/Picker.svelte index bd575600b1..aada17b318 100644 --- a/packages/bbui/src/Form/Core/Picker.svelte +++ b/packages/bbui/src/Form/Core/Picker.svelte @@ -99,9 +99,15 @@ bind:this={button} > {#if fieldIcon} - - - + {#if !useOptionIconImage} + + + + {:else} + + icon + + {/if} {/if} {#if fieldColour} @@ -311,4 +317,8 @@ max-width: 170px; font-size: 12px; } + + .option-extra.icon.field-icon { + display: flex; + } diff --git a/packages/builder/src/pages/builder/auth/_components/OIDCButton.svelte b/packages/builder/src/pages/builder/auth/_components/OIDCButton.svelte index 1fa392610b..9d0ab515fb 100644 --- a/packages/builder/src/pages/builder/auth/_components/OIDCButton.svelte +++ b/packages/builder/src/pages/builder/auth/_components/OIDCButton.svelte @@ -12,6 +12,7 @@ export let samePage $: show = $organisation.oidc + $: oidcLogoCheck = $oidc.logo let preDefinedIcons = { Oidc: OidcLogo, @@ -29,9 +30,9 @@ } }) - $: src = !$oidc.logo + $: src = !oidcLogoCheck ? OidcLogo - : preDefinedIcons[$oidc.logo] || `/global/logos_oidc/${$oidc.logo}` + : preDefinedIcons[$oidc.logo] || oidcLogoCheck {#if show} diff --git a/packages/types/src/documents/global/config.ts b/packages/types/src/documents/global/config.ts index bebb4ae14f..3fd352aada 100644 --- a/packages/types/src/documents/global/config.ts +++ b/packages/types/src/documents/global/config.ts @@ -79,6 +79,12 @@ export interface OIDCConfigs { configs: OIDCInnerConfig[] } +export interface OIDCLogosInnerConfig { + [key: string]: string +} + +export interface OIDCLogosConfig extends Config {} + export interface OIDCInnerConfig { configUrl: string clientID: string diff --git a/packages/worker/src/api/controllers/global/configs.ts b/packages/worker/src/api/controllers/global/configs.ts index 0f22d4aae0..a7d5bac989 100644 --- a/packages/worker/src/api/controllers/global/configs.ts +++ b/packages/worker/src/api/controllers/global/configs.ts @@ -28,6 +28,7 @@ import { SSOConfig, SSOConfigType, UserCtx, + OIDCLogosConfig, } from "@budibase/types" import * as pro from "@budibase/pro" @@ -280,13 +281,39 @@ export async function save(ctx: UserCtx) { } } +function enrichOIDCLogos(oidcLogos: OIDCLogosConfig) { + if (!oidcLogos) { + return + } + oidcLogos.config = Object.keys(oidcLogos.config).reduce( + (acc: any, key: string) => { + if (!key.endsWith("Etag")) { + const etag = oidcLogos.config[`${key}Etag`] + const objectStoreUrl = objectStore.getGlobalFileUrl( + oidcLogos.type, + key, + etag + ) + acc[key] = objectStoreUrl + } else { + acc[key] = oidcLogos.config[key] + } + return acc + }, + {} + ) +} + export async function find(ctx: UserCtx) { try { // Find the config with the most granular scope based on context const type = ctx.params.type - const scopedConfig = await configs.getConfig(type) + let scopedConfig = await configs.getConfig(type) if (scopedConfig) { + if (type === ConfigType.OIDC_LOGOS) { + enrichOIDCLogos(scopedConfig) + } ctx.body = scopedConfig } else { // don't throw an error, there simply is nothing to return @@ -301,13 +328,20 @@ export async function publicOidc(ctx: Ctx) { try { // Find the config with the most granular scope based on context const config = await configs.getOIDCConfig() + const oidcLogoConfig = await configs.getOIDCLogosDoc() + + if (oidcLogoConfig) { + enrichOIDCLogos(oidcLogoConfig) + } if (!config) { ctx.body = [] } else { ctx.body = [ { - logo: config.logo, + logo: oidcLogoConfig + ? oidcLogoConfig.config[config.logo] + : config.logo, name: config.name, uuid: config.uuid, }, From 6f24772f49fc373678f6e62e9e6eacabb02bf226 Mon Sep 17 00:00:00 2001 From: Dean Date: Fri, 23 Jun 2023 16:40:40 +0100 Subject: [PATCH 02/28] PR Feedback --- .../builder/auth/_components/OIDCButton.svelte | 8 +++----- .../src/api/controllers/global/configs.ts | 18 ++++++++---------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/packages/builder/src/pages/builder/auth/_components/OIDCButton.svelte b/packages/builder/src/pages/builder/auth/_components/OIDCButton.svelte index 9d0ab515fb..f5dcbe7466 100644 --- a/packages/builder/src/pages/builder/auth/_components/OIDCButton.svelte +++ b/packages/builder/src/pages/builder/auth/_components/OIDCButton.svelte @@ -12,7 +12,6 @@ export let samePage $: show = $organisation.oidc - $: oidcLogoCheck = $oidc.logo let preDefinedIcons = { Oidc: OidcLogo, @@ -30,14 +29,13 @@ } }) - $: src = !oidcLogoCheck - ? OidcLogo - : preDefinedIcons[$oidc.logo] || oidcLogoCheck + $: oidcLogoImageURL = preDefinedIcons[$oidc.logo] ?? $oidc.logo + $: logoSrc = oidcLogoImageURL ?? OidcLogo {#if show} { const url = `/api/global/auth/${$auth.tenantId}/oidc/configs/${$oidc.uuid}` if (samePage) { diff --git a/packages/worker/src/api/controllers/global/configs.ts b/packages/worker/src/api/controllers/global/configs.ts index a7d5bac989..042fcb9393 100644 --- a/packages/worker/src/api/controllers/global/configs.ts +++ b/packages/worker/src/api/controllers/global/configs.ts @@ -327,23 +327,21 @@ export async function find(ctx: UserCtx) { export async function publicOidc(ctx: Ctx) { try { // Find the config with the most granular scope based on context - const config = await configs.getOIDCConfig() - const oidcLogoConfig = await configs.getOIDCLogosDoc() + const oidcConfig = await configs.getOIDCConfig() + const oidcCustomLogos = await configs.getOIDCLogosDoc() - if (oidcLogoConfig) { - enrichOIDCLogos(oidcLogoConfig) + if (oidcCustomLogos) { + enrichOIDCLogos(oidcCustomLogos) } - if (!config) { + if (!oidcConfig) { ctx.body = [] } else { ctx.body = [ { - logo: oidcLogoConfig - ? oidcLogoConfig.config[config.logo] - : config.logo, - name: config.name, - uuid: config.uuid, + logo: oidcCustomLogos?.config[oidcConfig.logo] ?? oidcConfig.logo, + name: oidcConfig.name, + uuid: oidcConfig.uuid, }, ] } From b130de71dcc04764653465818b6492000d2884ea Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 23 Jun 2023 16:45:22 +0100 Subject: [PATCH 03/28] Persist the current step when remounting a form --- packages/client/src/components/app/forms/Form.svelte | 3 +++ packages/client/src/components/app/forms/InnerForm.svelte | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/client/src/components/app/forms/Form.svelte b/packages/client/src/components/app/forms/Form.svelte index b15ab55c5b..39c9bf4b59 100644 --- a/packages/client/src/components/app/forms/Form.svelte +++ b/packages/client/src/components/app/forms/Form.svelte @@ -2,6 +2,7 @@ import { getContext } from "svelte" import InnerForm from "./InnerForm.svelte" import { Helpers } from "@budibase/bbui" + import { writable } from "svelte/store" export let dataSource export let theme @@ -23,6 +24,7 @@ let loaded = false let schema let table + let currentStep = writable(1) $: fetchSchema(dataSource) $: schemaKey = generateSchemaKey(schema) @@ -92,6 +94,7 @@ {initialValues} {disableValidation} {editAutoColumns} + {currentStep} > diff --git a/packages/client/src/components/app/forms/InnerForm.svelte b/packages/client/src/components/app/forms/InnerForm.svelte index 9eb21b0bae..51f25c4971 100644 --- a/packages/client/src/components/app/forms/InnerForm.svelte +++ b/packages/client/src/components/app/forms/InnerForm.svelte @@ -13,11 +13,14 @@ export let disableValidation = false export let editAutoColumns = false + // We export this store so that when we remount the inner form we can still + // persist what step we're on + export let currentStep + const component = getContext("component") const { styleable, Provider, ActionTypes } = getContext("sdk") let fields = [] - const currentStep = writable(1) const formState = writable({ values: {}, errors: {}, From a4ea6a3d342153922fa21d3e12139c2cbacc3681 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 23 Jun 2023 16:50:10 +0100 Subject: [PATCH 04/28] Ensure initial value of current form step inside form state store is correct --- packages/client/src/components/app/forms/InnerForm.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/client/src/components/app/forms/InnerForm.svelte b/packages/client/src/components/app/forms/InnerForm.svelte index 51f25c4971..88ad35f4b9 100644 --- a/packages/client/src/components/app/forms/InnerForm.svelte +++ b/packages/client/src/components/app/forms/InnerForm.svelte @@ -25,7 +25,7 @@ values: {}, errors: {}, valid: true, - currentStep: 1, + currentStep: get(currentStep), }) // Reactive derived stores to derive form state from field array From 10108fb543f1d62911920ddbb4e75e97c0a78272 Mon Sep 17 00:00:00 2001 From: Dean Date: Mon, 26 Jun 2023 10:22:03 +0100 Subject: [PATCH 05/28] Null checking logo configs --- packages/worker/src/api/controllers/global/configs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/worker/src/api/controllers/global/configs.ts b/packages/worker/src/api/controllers/global/configs.ts index 042fcb9393..411beff554 100644 --- a/packages/worker/src/api/controllers/global/configs.ts +++ b/packages/worker/src/api/controllers/global/configs.ts @@ -282,7 +282,7 @@ export async function save(ctx: UserCtx) { } function enrichOIDCLogos(oidcLogos: OIDCLogosConfig) { - if (!oidcLogos) { + if (!oidcLogos?.config) { return } oidcLogos.config = Object.keys(oidcLogos.config).reduce( From 8f9a1d4bbaf232eb83b0e7bae54299140ac62f1c Mon Sep 17 00:00:00 2001 From: Dean Date: Mon, 26 Jun 2023 10:23:57 +0100 Subject: [PATCH 06/28] PR feedback --- packages/worker/src/api/controllers/global/configs.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/worker/src/api/controllers/global/configs.ts b/packages/worker/src/api/controllers/global/configs.ts index 411beff554..b061d110f5 100644 --- a/packages/worker/src/api/controllers/global/configs.ts +++ b/packages/worker/src/api/controllers/global/configs.ts @@ -282,10 +282,10 @@ export async function save(ctx: UserCtx) { } function enrichOIDCLogos(oidcLogos: OIDCLogosConfig) { - if (!oidcLogos?.config) { + if (!oidcLogos) { return } - oidcLogos.config = Object.keys(oidcLogos.config).reduce( + oidcLogos.config = Object.keys(oidcLogos.config || {}).reduce( (acc: any, key: string) => { if (!key.endsWith("Etag")) { const etag = oidcLogos.config[`${key}Etag`] From d499200de41a56017488d7e75caf151965ae97e5 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 26 Jun 2023 11:53:29 +0100 Subject: [PATCH 07/28] Change path refs --- scripts/bumpVersion.js | 2 +- scripts/versionCommit.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/bumpVersion.js b/scripts/bumpVersion.js index 19deb684da..dd54074ae8 100644 --- a/scripts/bumpVersion.js +++ b/scripts/bumpVersion.js @@ -1,7 +1,7 @@ const fs = require("fs") const semver = require("semver") -const filePath = "lerna.json" +const filePath = "../lerna.json" const versionBump = process.argv[2] || "patch" // Read and parse lerna.json file diff --git a/scripts/versionCommit.sh b/scripts/versionCommit.sh index d70f6900e2..69137a988f 100755 --- a/scripts/versionCommit.sh +++ b/scripts/versionCommit.sh @@ -7,10 +7,10 @@ then fi # Bump the version in lerna.json -node scripts/bumpVersion.js $1 +node ./bumpVersion.js $1 -NEW_VERSION=$(node -p "require('./lerna.json').version") +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 From 24d5d36cffd39dad044430ef50eab73adf6b5c35 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 26 Jun 2023 11:54:24 +0100 Subject: [PATCH 08/28] Add dependencies on scripts --- package.json | 1 - scripts/.gitignore | 1 + scripts/package.json | 10 ++++++++++ scripts/yarn.lock | 22 ++++++++++++++++++++++ yarn.lock | 7 ------- 5 files changed, 33 insertions(+), 8 deletions(-) create mode 100644 scripts/.gitignore create mode 100644 scripts/package.json create mode 100644 scripts/yarn.lock diff --git a/package.json b/package.json index b521030caf..8b715d8747 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,6 @@ "prettier-plugin-svelte": "^2.3.0", "rimraf": "^3.0.2", "rollup-plugin-replace": "^2.2.0", - "semver": "^7.5.0", "svelte": "^3.38.2", "typescript": "4.7.3" }, diff --git a/scripts/.gitignore b/scripts/.gitignore new file mode 100644 index 0000000000..40b878db5b --- /dev/null +++ b/scripts/.gitignore @@ -0,0 +1 @@ +node_modules/ \ No newline at end of file diff --git a/scripts/package.json b/scripts/package.json new file mode 100644 index 0000000000..c08bc5b7c2 --- /dev/null +++ b/scripts/package.json @@ -0,0 +1,10 @@ +{ + "name": "scripts", + "private": true, + "version": "1.0.0", + "main": "index.js", + "license": "MIT", + "devDependencies": { + "semver": "^7.5.3" + } +} diff --git a/scripts/yarn.lock b/scripts/yarn.lock new file mode 100644 index 0000000000..fe88e5d4ba --- /dev/null +++ b/scripts/yarn.lock @@ -0,0 +1,22 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +lru-cache@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" + integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== + dependencies: + yallist "^4.0.0" + +semver@^7.5.3: + version "7.5.3" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.3.tgz#161ce8c2c6b4b3bdca6caadc9fa3317a4c4fe88e" + integrity sha512-QBlUtyVk/5EeHbi7X0fw6liDZc7BBmEaSYn01fMU1OUYbf6GPsbTtd8WmnqbI20SeycoHSeiybkE/q1Q+qlThQ== + dependencies: + lru-cache "^6.0.0" + +yallist@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" + integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== diff --git a/yarn.lock b/yarn.lock index c572cdc1b8..4c02b28ac2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -22426,13 +22426,6 @@ semver@^7.2.1, semver@^7.3.5: dependencies: lru-cache "^6.0.0" -semver@^7.5.0: - version "7.5.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.0.tgz#ed8c5dc8efb6c629c88b23d41dc9bf40c1d96cd0" - integrity sha512-+XC0AD/R7Q2mPSRuy2Id0+CGTZ98+8f+KvwirxOKIEyid+XSx6HbC63p+O4IndTHuX5Z+JxQ0TghCkO5Cg/2HA== - dependencies: - lru-cache "^6.0.0" - semver@~2.3.1: version "2.3.2" resolved "https://registry.yarnpkg.com/semver/-/semver-2.3.2.tgz#b9848f25d6cf36333073ec9ef8856d42f1233e52" From f31990e17ffaaa7b3455107018622ff640935fa8 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 26 Jun 2023 11:55:44 +0100 Subject: [PATCH 09/28] Update pipelines --- .github/workflows/tag-prerelease.yml | 5 +++-- .github/workflows/tag-release.yml | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tag-prerelease.yml b/.github/workflows/tag-prerelease.yml index 83660e409d..f6446c55f5 100644 --- a/.github/workflows/tag-prerelease.yml +++ b/.github/workflows/tag-prerelease.yml @@ -32,10 +32,11 @@ jobs: submodules: true token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - - run: yarn + - run: cd scripts && yarn - name: Tag prerelease run: | + cd scripts # setup the username and email. git config --global user.name "Budibase Staging Release Bot" git config --global user.email "<>" - ./scripts/versionCommit.sh prerelease + ./versionCommit.sh prerelease diff --git a/.github/workflows/tag-release.yml b/.github/workflows/tag-release.yml index f361c200a0..191c3ad9ef 100644 --- a/.github/workflows/tag-release.yml +++ b/.github/workflows/tag-release.yml @@ -42,12 +42,13 @@ jobs: submodules: true token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - - run: yarn + - run: cd scripts && yarn - name: Tag release run: | + cd scripts # setup the username and email. git config --global user.name "Budibase Staging Release Bot" git config --global user.email "<>" BUMP_TYPE_INPUT=${{ github.event.inputs.versioning }} BUMP_TYPE=${BUMP_TYPE_INPUT:-"patch"} - ./scripts/versionCommit.sh $BUMP_TYPE + ./versionCommit.sh $BUMP_TYPE From 46e889fd7299504b8ca5de8c4f54594da3eec73c Mon Sep 17 00:00:00 2001 From: Dean Date: Mon, 26 Jun 2023 12:38:13 +0100 Subject: [PATCH 10/28] Fix for invite error handling and updated messaging --- .../_components/BuilderSidePanel.svelte | 42 +++++++++++-------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/packages/builder/src/pages/builder/app/[application]/_components/BuilderSidePanel.svelte b/packages/builder/src/pages/builder/app/[application]/_components/BuilderSidePanel.svelte index 65963b828d..3249ca2514 100644 --- a/packages/builder/src/pages/builder/app/[application]/_components/BuilderSidePanel.svelte +++ b/packages/builder/src/pages/builder/app/[application]/_components/BuilderSidePanel.svelte @@ -40,6 +40,8 @@ let userOnboardResponse = null let userLimitReachedModal + let inviteFailureResponse = "" + $: queryIsEmail = emailValidator(query) === true $: prodAppId = apps.getProdAppID($store.appId) $: promptInvite = showInvite( @@ -308,19 +310,6 @@ let userInviteResponse try { userInviteResponse = await users.onboard(payload) - - const newUser = userInviteResponse?.successful.find( - user => user.email === newUserEmail - ) - if (newUser) { - notifications.success( - userInviteResponse.created - ? "User created successfully" - : "User invite successful" - ) - } else { - throw new Error("User invite failed") - } } catch (error) { console.error(error.message) notifications.error("Error inviting user") @@ -331,12 +320,31 @@ const onInviteUser = async () => { userOnboardResponse = await inviteUser() + const originalQuery = query + "" + query = null - const userInviteSuccess = userOnboardResponse?.successful - if (userInviteSuccess && userInviteSuccess[0].email === query) { - query = null - query = userInviteSuccess[0].email + const newUser = userOnboardResponse?.successful.find( + user => user.email === originalQuery + ) + if (newUser) { + query = originalQuery + notifications.success( + userOnboardResponse.created + ? "User created successfully" + : "User invite successful" + ) + } else { + const failedUser = userOnboardResponse?.unsuccessful.find( + user => user.email === originalQuery + ) + inviteFailureResponse = + failedUser?.reason === "Unavailable" + ? "Email already in use. Please use a different email." + : failedUser?.reason + + notifications.error(inviteFailureResponse) } + userOnboardResponse = null } const onUpdateUserInvite = async (invite, role) => { From 22fca335f0647ad7beebdf2b1c45dde504c3af2d Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 26 Jun 2023 15:04:13 +0100 Subject: [PATCH 11/28] Lint pro from monorepo --- .eslintrc.json | 7 ++----- packages/pro | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 79e0c00abd..d94c749042 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -16,8 +16,7 @@ "dist", "public", "*.spec.js", - "bundle.js", - "packages/pro" + "bundle.js" ], "plugins": ["svelte3"], "extends": ["eslint:recommended"], @@ -30,9 +29,7 @@ "files": ["**/*.ts"], "parser": "@typescript-eslint/parser", "plugins": [], - "extends": [ - "eslint:recommended" - ], + "extends": ["eslint:recommended"], "rules": { "no-unused-vars": "off", "no-inner-declarations": "off", diff --git a/packages/pro b/packages/pro index d99e1baee7..374032692e 160000 --- a/packages/pro +++ b/packages/pro @@ -1 +1 @@ -Subproject commit d99e1baee70edf726bcc1a83684bf9bd641d04de +Subproject commit 374032692eae2b0823a60ceaee52cf8c481a3328 From 0ecda93ea9174e6d8cd6825c1701d3e9033c5e18 Mon Sep 17 00:00:00 2001 From: melohagan <101575380+melohagan@users.noreply.github.com> Date: Mon, 26 Jun 2023 15:07:29 +0100 Subject: [PATCH 12/28] Fix for $in on ObjectIds (#11014) --- packages/server/src/integrations/mongodb.ts | 27 ++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/packages/server/src/integrations/mongodb.ts b/packages/server/src/integrations/mongodb.ts index 3f05dca954..e716f3192d 100644 --- a/packages/server/src/integrations/mongodb.ts +++ b/packages/server/src/integrations/mongodb.ts @@ -380,18 +380,26 @@ class MongoIntegration implements IntegrationBase { return this.client.connect() } + matchId(value?: string) { + return value?.match(/(?<=objectid\(['"]).*(?=['"]\))/gi)?.[0] + } + + hasObjectId(value?: any): boolean { + return ( + typeof value === "string" && value.toLowerCase().startsWith("objectid") + ) + } + createObjectIds(json: any): object { const self = this + function interpolateObjectIds(json: any) { for (let field of Object.keys(json || {})) { if (json[field] instanceof Object) { json[field] = self.createObjectIds(json[field]) } - if ( - typeof json[field] === "string" && - json[field].toLowerCase().startsWith("objectid") - ) { - const id = json[field].match(/(?<=objectid\(['"]).*(?=['"]\))/gi)?.[0] + if (self.hasObjectId(json[field])) { + const id = self.matchId(json[field]) if (id) { json[field] = ObjectId.createFromHexString(id) } @@ -402,7 +410,14 @@ class MongoIntegration implements IntegrationBase { if (Array.isArray(json)) { for (let i = 0; i < json.length; i++) { - json[i] = interpolateObjectIds(json[i]) + if (self.hasObjectId(json[i])) { + const id = self.matchId(json[i]) + if (id) { + json[i] = ObjectId.createFromHexString(id) + } + } else { + json[i] = interpolateObjectIds(json[i]) + } } return json } From 747686a8fa068cc94d9cc5a52233673fc9bcf5d0 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 26 Jun 2023 15:08:45 +0100 Subject: [PATCH 13/28] Update pro ref --- packages/pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/pro b/packages/pro index 374032692e..3b736a2e1b 160000 --- a/packages/pro +++ b/packages/pro @@ -1 +1 @@ -Subproject commit 374032692eae2b0823a60ceaee52cf8c481a3328 +Subproject commit 3b736a2e1bdca2b990ccab8f315592f59c3d3775 From d25b86a6b11bf704af855a8b61d820b2936c8653 Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Mon, 26 Jun 2023 14:14:14 +0000 Subject: [PATCH 14/28] Bump version to 2.7.34 --- lerna.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lerna.json b/lerna.json index b43faee706..7b4c79fa60 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.7.33", + "version": "2.7.34", "npmClient": "yarn", "packages": [ "packages/backend-core", From 6d8903d7e50de905b334d435173597bf73e506ea Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 26 Jun 2023 15:22:36 +0100 Subject: [PATCH 15/28] Lint pro command --- .eslintignore | 2 +- package.json | 1 + packages/pro | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.eslintignore b/.eslintignore index 1dac74b117..0d81de0ef9 100644 --- a/.eslintignore +++ b/.eslintignore @@ -10,4 +10,4 @@ packages/builder/.routify packages/builder/cypress/support/queryLevelTransformerFunction.js packages/builder/cypress/support/queryLevelTransformerFunctionWithData.js packages/builder/cypress/reports -packages/sdk/sdk \ No newline at end of file +packages/sdk/sdk diff --git a/package.json b/package.json index b521030caf..aa32e4cc11 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,7 @@ "lint:eslint": "eslint packages && eslint qa-core", "lint:prettier": "prettier --check \"packages/**/*.{js,ts,svelte}\" && prettier --write \"examples/**/*.{js,ts,svelte}\" && prettier --check \"qa-core/**/*.{js,ts,svelte}\"", "lint": "yarn run lint:eslint && yarn run lint:prettier", + "lint:pro": "yarn eslint packages/pro && yarn prettier --check packages/pro", "lint:fix:eslint": "eslint --fix packages qa-core", "lint:fix:prettier": "prettier --write \"packages/**/*.{js,ts,svelte}\" && prettier --write \"examples/**/*.{js,ts,svelte}\" && prettier --write \"qa-core/**/*.{js,ts,svelte}\"", "lint:fix": "yarn run lint:fix:prettier && yarn run lint:fix:eslint", diff --git a/packages/pro b/packages/pro index 3b736a2e1b..8815e6e884 160000 --- a/packages/pro +++ b/packages/pro @@ -1 +1 @@ -Subproject commit 3b736a2e1bdca2b990ccab8f315592f59c3d3775 +Subproject commit 8815e6e8843ae371a77aec3128f0f7739caaf350 From ce92bfd3ef908efba03ac02601bf4580deb909c8 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 26 Jun 2023 15:46:48 +0100 Subject: [PATCH 16/28] Update pro ref --- packages/pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/pro b/packages/pro index 8815e6e884..5030ab60bd 160000 --- a/packages/pro +++ b/packages/pro @@ -1 +1 @@ -Subproject commit 8815e6e8843ae371a77aec3128f0f7739caaf350 +Subproject commit 5030ab60bde3178189a2220d8281becc650ce1bf From d7e1ebe9ec73417ef9bac4b5f7b3b7ecdc81cb70 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 26 Jun 2023 16:09:08 +0100 Subject: [PATCH 17/28] Update pro ref --- packages/pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/pro b/packages/pro index 5030ab60bd..8164d5d4b7 160000 --- a/packages/pro +++ b/packages/pro @@ -1 +1 @@ -Subproject commit 5030ab60bde3178189a2220d8281becc650ce1bf +Subproject commit 8164d5d4b7bb213940761595eaab0289e2737c18 From 0e9c687228c0892386c7fe0a0de0cb7b8fcfed20 Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Mon, 26 Jun 2023 16:23:45 +0000 Subject: [PATCH 18/28] Bump version to 2.7.35 --- lerna.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lerna.json b/lerna.json index 7b4c79fa60..65876a2c4d 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.7.34", + "version": "2.7.35", "npmClient": "yarn", "packages": [ "packages/backend-core", From 7f6dc2a65423e79f5a065adc65be219a873957ad Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Mon, 26 Jun 2023 17:15:59 +0000 Subject: [PATCH 19/28] Bump version to 2.7.34-alpha.10 --- lerna.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lerna.json b/lerna.json index 1045e7274a..b37112f1a7 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.7.34-alpha.9", + "version": "2.7.34-alpha.10", "npmClient": "yarn", "packages": [ "packages/*" From 3eff4d85d03182f5d855eb41bd3cdd5575d0303f Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 26 Jun 2023 18:52:15 +0100 Subject: [PATCH 20/28] Adding a test case for the removal of automation logs from app sync, as well as adding to the publish/sync filter a check to not carry over automation logs. --- packages/backend-core/src/db/Replication.ts | 3 ++ .../src/api/routes/tests/application.spec.ts | 37 ++++++++++++++++++- .../src/tests/utilities/TestConfiguration.ts | 20 ++++++++++ .../server/src/tests/utilities/structures.ts | 17 +++++++++ 4 files changed, 76 insertions(+), 1 deletion(-) diff --git a/packages/backend-core/src/db/Replication.ts b/packages/backend-core/src/db/Replication.ts index eb9d613a58..e813722d98 100644 --- a/packages/backend-core/src/db/Replication.ts +++ b/packages/backend-core/src/db/Replication.ts @@ -57,6 +57,9 @@ class Replication { appReplicateOpts() { return { filter: (doc: any) => { + if (doc._id && doc._id.startsWith(DocumentType.AUTOMATION_LOG)) { + return false + } return doc._id !== DocumentType.APP_METADATA }, } diff --git a/packages/server/src/api/routes/tests/application.spec.ts b/packages/server/src/api/routes/tests/application.spec.ts index 1f4f189724..207d25d508 100644 --- a/packages/server/src/api/routes/tests/application.spec.ts +++ b/packages/server/src/api/routes/tests/application.spec.ts @@ -14,7 +14,7 @@ jest.mock("../../../utilities/redis", () => ({ import { clearAllApps, checkBuilderEndpoint } from "./utilities/TestFunctions" import * as setup from "./utilities" import { AppStatus } from "../../../db/utils" -import { events, utils } from "@budibase/backend-core" +import { events, utils, context } from "@budibase/backend-core" import env from "../../../environment" jest.setTimeout(15000) @@ -324,4 +324,39 @@ describe("/applications", () => { expect(events.app.unpublished).toBeCalledTimes(1) }) }) + + describe("app sync", () => { + it("should not sync automation logs", async () => { + // setup the apps + await config.createApp("testing-auto-logs") + const automation = await config.createAutomation() + await config.publish() + await context.doInAppContext(config.getProdAppId(), () => { + return config.createAutomationLog(automation) + }) + + // do the sync + const appId = config.getAppId() + await request + .post(`/api/applications/${appId}/sync`) + .set(config.defaultHeaders()) + .expect("Content-Type", /json/) + .expect(200) + + // does exist in prod + await context.doInAppContext(config.getProdAppId(), async () => { + const logs = await config.getAutomationLogs() + expect(logs.data.length).toBe(1) + }) + + // delete prod app so we revert to dev log search + await config.unpublish() + + // doesn't exist in dev + await context.doInAppContext(config.getAppId(), async () => { + const logs = await config.getAutomationLogs() + expect(logs.data.length).toBe(0) + }) + }) + }) }) diff --git a/packages/server/src/tests/utilities/TestConfiguration.ts b/packages/server/src/tests/utilities/TestConfiguration.ts index 995035aa97..26f70ec845 100644 --- a/packages/server/src/tests/utilities/TestConfiguration.ts +++ b/packages/server/src/tests/utilities/TestConfiguration.ts @@ -21,6 +21,7 @@ import { basicScreen, basicLayout, basicWebhook, + basicAutomationLog, } from "./structures" import { constants, @@ -48,6 +49,7 @@ import { Table, SearchFilters, UserRoles, + Automation, } from "@budibase/types" import { BUILTIN_ROLE_IDS } from "@budibase/backend-core/src/security/roles" @@ -720,6 +722,24 @@ class TestConfiguration { return { datasource, query: basedOnQuery } } + // AUTOMATION LOG + + async createAutomationLog(automation: Automation) { + return await context.doInAppContext(this.getProdAppId(), async () => { + return await pro.sdk.automations.logs.storeLog( + automation, + basicAutomationLog(automation._id!) + ) + }) + } + + async getAutomationLogs() { + const now = new Date() + return await pro.sdk.automations.logs.logSearch({ + startDate: new Date(now.getTime() - 100000).toISOString(), + }) + } + // QUERY async previewQuery( diff --git a/packages/server/src/tests/utilities/structures.ts b/packages/server/src/tests/utilities/structures.ts index 71f30f0074..02c62b85ba 100644 --- a/packages/server/src/tests/utilities/structures.ts +++ b/packages/server/src/tests/utilities/structures.ts @@ -9,6 +9,8 @@ import { import { Automation, AutomationActionStepId, + AutomationResults, + AutomationStatus, AutomationStep, AutomationStepType, AutomationTrigger, @@ -241,6 +243,21 @@ export function collectAutomation(tableId?: string): Automation { return automation as Automation } +export function basicAutomationLog(automationId: string): AutomationResults { + return { + automationId, + status: AutomationStatus.SUCCESS, + trigger: "trigger", + steps: [ + { + stepId: AutomationActionStepId.SERVER_LOG, + inputs: {}, + outputs: {}, + }, + ], + } +} + export function basicRow(tableId: string) { return { name: "Test Contact", From 65df28460f577c8ffb2787180a712e1679796f4c Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 27 Jun 2023 08:30:25 +0100 Subject: [PATCH 21/28] Remove unused command --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index aa32e4cc11..b521030caf 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,6 @@ "lint:eslint": "eslint packages && eslint qa-core", "lint:prettier": "prettier --check \"packages/**/*.{js,ts,svelte}\" && prettier --write \"examples/**/*.{js,ts,svelte}\" && prettier --check \"qa-core/**/*.{js,ts,svelte}\"", "lint": "yarn run lint:eslint && yarn run lint:prettier", - "lint:pro": "yarn eslint packages/pro && yarn prettier --check packages/pro", "lint:fix:eslint": "eslint --fix packages qa-core", "lint:fix:prettier": "prettier --write \"packages/**/*.{js,ts,svelte}\" && prettier --write \"examples/**/*.{js,ts,svelte}\" && prettier --write \"qa-core/**/*.{js,ts,svelte}\"", "lint:fix": "yarn run lint:fix:prettier && yarn run lint:fix:eslint", From 85ff09bbf3fe1a081753bdb22294a3ab47a3b0f2 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 27 Jun 2023 08:34:25 +0100 Subject: [PATCH 22/28] Update pro ref --- packages/pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/pro b/packages/pro index 8164d5d4b7..544c7e067d 160000 --- a/packages/pro +++ b/packages/pro @@ -1 +1 @@ -Subproject commit 8164d5d4b7bb213940761595eaab0289e2737c18 +Subproject commit 544c7e067de69832469cde673e59501480d6d98a From 6f75c5df532b820c8822390830a9c8f8f127b618 Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Tue, 27 Jun 2023 09:59:02 +0100 Subject: [PATCH 23/28] Use any type to fix TypeScript check --- packages/server/src/integrations/mongodb.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/integrations/mongodb.ts b/packages/server/src/integrations/mongodb.ts index 3286ff4e65..bc23ac7dbc 100644 --- a/packages/server/src/integrations/mongodb.ts +++ b/packages/server/src/integrations/mongodb.ts @@ -392,7 +392,7 @@ class MongoIntegration implements IntegrationBase { ) } - createObjectIds(json: any): object { + createObjectIds(json: any): any { const self = this function interpolateObjectIds(json: any) { From 47260f23bf8c0cf39f1a2ef3ae9440d0b61e2d2c Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 27 Jun 2023 10:01:06 +0100 Subject: [PATCH 24/28] PR comments. --- .../src/api/routes/tests/application.spec.ts | 14 +++++--------- .../src/tests/utilities/TestConfiguration.ts | 12 +++++++----- packages/server/src/tests/utilities/structures.ts | 4 +++- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/server/src/api/routes/tests/application.spec.ts b/packages/server/src/api/routes/tests/application.spec.ts index 207d25d508..fa5cb0a983 100644 --- a/packages/server/src/api/routes/tests/application.spec.ts +++ b/packages/server/src/api/routes/tests/application.spec.ts @@ -325,7 +325,7 @@ describe("/applications", () => { }) }) - describe("app sync", () => { + describe("POST /api/applications/:appId/sync", () => { it("should not sync automation logs", async () => { // setup the apps await config.createApp("testing-auto-logs") @@ -344,19 +344,15 @@ describe("/applications", () => { .expect(200) // does exist in prod - await context.doInAppContext(config.getProdAppId(), async () => { - const logs = await config.getAutomationLogs() - expect(logs.data.length).toBe(1) - }) + const prodLogs = await config.getAutomationLogs() + expect(prodLogs.data.length).toBe(1) // delete prod app so we revert to dev log search await config.unpublish() // doesn't exist in dev - await context.doInAppContext(config.getAppId(), async () => { - const logs = await config.getAutomationLogs() - expect(logs.data.length).toBe(0) - }) + const devLogs = await config.getAutomationLogs() + expect(devLogs.data.length).toBe(0) }) }) }) diff --git a/packages/server/src/tests/utilities/TestConfiguration.ts b/packages/server/src/tests/utilities/TestConfiguration.ts index 26f70ec845..2078bf765a 100644 --- a/packages/server/src/tests/utilities/TestConfiguration.ts +++ b/packages/server/src/tests/utilities/TestConfiguration.ts @@ -21,7 +21,7 @@ import { basicScreen, basicLayout, basicWebhook, - basicAutomationLog, + basicAutomationResults, } from "./structures" import { constants, @@ -728,15 +728,17 @@ class TestConfiguration { return await context.doInAppContext(this.getProdAppId(), async () => { return await pro.sdk.automations.logs.storeLog( automation, - basicAutomationLog(automation._id!) + basicAutomationResults(automation._id!) ) }) } async getAutomationLogs() { - const now = new Date() - return await pro.sdk.automations.logs.logSearch({ - startDate: new Date(now.getTime() - 100000).toISOString(), + return context.doInAppContext(this.appId, async () => { + const now = new Date() + return await pro.sdk.automations.logs.logSearch({ + startDate: new Date(now.getTime() - 100000).toISOString(), + }) }) } diff --git a/packages/server/src/tests/utilities/structures.ts b/packages/server/src/tests/utilities/structures.ts index 02c62b85ba..0a9a9d5a68 100644 --- a/packages/server/src/tests/utilities/structures.ts +++ b/packages/server/src/tests/utilities/structures.ts @@ -243,7 +243,9 @@ export function collectAutomation(tableId?: string): Automation { return automation as Automation } -export function basicAutomationLog(automationId: string): AutomationResults { +export function basicAutomationResults( + automationId: string +): AutomationResults { return { automationId, status: AutomationStatus.SUCCESS, From 4387eb2a674e16f6e0329f7d428ccc7972453d82 Mon Sep 17 00:00:00 2001 From: Gerard Burns Date: Tue, 27 Jun 2023 14:16:55 +0100 Subject: [PATCH 25/28] Update datasource config to use tabs --- .../buttons/ExistingRelationshipButton.svelte | 54 ++-- .../PlusConfigForm.svelte | 249 ------------------ .../TableIntegrationMenu/index.svelte | 86 ------ .../rest/RestExtraConfigForm.svelte | 137 ---------- .../CreateEditRelationshipModal.svelte | 66 +++++ .../index.svelte | 2 +- .../Authentication}/AuthTypeRenderer.svelte | 0 .../RestAuthenticationBuilder.svelte | 27 +- .../RestAuthenticationModal.svelte | 0 .../panels/Authentication}/authTypes.js | 0 .../panels/Authentication/index.svelte | 27 ++ .../_components/panels/Headers.svelte | 53 ++++ .../_components/panels/Panel.svelte | 27 ++ .../panels/Queries/RestImportButton.svelte | 21 ++ .../Queries/RestImportQueriesModal.svelte | 132 ++++++++++ .../_components/panels/Queries/index.svelte | 43 +++ .../_components/panels/Relationships.svelte | 108 ++++++++ .../panels/SaveDatasourceButton.svelte | 29 ++ .../_components/panels/Tables/Controls.svelte | 71 +++++ .../Tables}/CreateExternalTableModal.svelte | 0 .../_components/panels/Tables/index.svelte | 33 +++ .../_components/panels/Tooltip.svelte | 30 +++ .../Variables}/ViewDynamicVariables.svelte | 7 +- .../_components/panels/Variables/index.svelte | 59 +++++ .../datasource/[datasourceId]/index.svelte | 249 ++++++------------ .../builder/src/stores/backend/datasources.js | 5 +- 26 files changed, 829 insertions(+), 686 deletions(-) delete mode 100644 packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/PlusConfigForm.svelte delete mode 100644 packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/index.svelte delete mode 100644 packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/rest/RestExtraConfigForm.svelte create mode 100644 packages/builder/src/components/backend/Datasources/CreateEditRelationshipModal.svelte rename packages/builder/src/{components/backend/DatasourceNavigator/TableIntegrationMenu/rest/auth => pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication}/AuthTypeRenderer.svelte (100%) rename packages/builder/src/{components/backend/DatasourceNavigator/TableIntegrationMenu/rest/auth => pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication}/RestAuthenticationBuilder.svelte (69%) rename packages/builder/src/{components/backend/DatasourceNavigator/TableIntegrationMenu/rest/auth => pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication}/RestAuthenticationModal.svelte (100%) rename packages/builder/src/{components/backend/DatasourceNavigator/TableIntegrationMenu/rest/auth => pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication}/authTypes.js (100%) create mode 100644 packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication/index.svelte create mode 100644 packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Headers.svelte create mode 100644 packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Panel.svelte create mode 100644 packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Queries/RestImportButton.svelte create mode 100644 packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Queries/RestImportQueriesModal.svelte create mode 100644 packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Queries/index.svelte create mode 100644 packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Relationships.svelte create mode 100644 packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/SaveDatasourceButton.svelte create mode 100644 packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Tables/Controls.svelte rename packages/builder/src/{components/backend/DatasourceNavigator/TableIntegrationMenu => pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Tables}/CreateExternalTableModal.svelte (100%) create mode 100644 packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Tables/index.svelte create mode 100644 packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Tooltip.svelte rename packages/builder/src/{components/backend/DatasourceNavigator/TableIntegrationMenu/rest/variables => pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Variables}/ViewDynamicVariables.svelte (87%) create mode 100644 packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Variables/index.svelte diff --git a/packages/builder/src/components/backend/DataTable/buttons/ExistingRelationshipButton.svelte b/packages/builder/src/components/backend/DataTable/buttons/ExistingRelationshipButton.svelte index aa666ea8d6..d0b0d9e68c 100644 --- a/packages/builder/src/components/backend/DataTable/buttons/ExistingRelationshipButton.svelte +++ b/packages/builder/src/components/backend/DataTable/buttons/ExistingRelationshipButton.svelte @@ -1,18 +1,14 @@ {#if datasource}
- + modal.show({ fromTable: table })} + > Define relationship
- - - + {/if} diff --git a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/PlusConfigForm.svelte b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/PlusConfigForm.svelte deleted file mode 100644 index 36fb34143a..0000000000 --- a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/PlusConfigForm.svelte +++ /dev/null @@ -1,249 +0,0 @@ - - - - - - - - - - - confirmDialog.hide()} - warning={false} - title="Confirm table fetch" -> - - If you have fetched tables from this database before, this action may - overwrite any changes you made after your initial fetch. - -
-
- -
-
- - -
- Tables -
- - -
-
- - This datasource can determine tables automatically. Budibase can fetch your - tables directly from the database and you can use them without having to write - any queries at all. - -{#if schemaError} - -{/if} -{#if plusTables && Object.values(plusTables).length > 0} - onClickTable(detail)} - schema={tableSchema} - data={Object.values(plusTables)} - allowEditColumns={false} - allowEditRows={false} - allowSelectRows={false} - customRenderers={[{ column: "primary", component: ArrayRenderer }]} - /> -{:else} - No tables found. -{/if} -{#if integration.relationships !== false} - -
- Relationships - -
- - Tell budibase how your tables are related to get even more smart features. - - {#if relationshipInfo && relationshipInfo.length > 0} -
openRelationshipModal(detail.from, detail.to)} - schema={relationshipSchema} - data={relationshipInfo} - allowEditColumns={false} - allowEditRows={false} - allowSelectRows={false} - /> - {:else} - No relationships configured. - {/if} -{/if} - - diff --git a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/index.svelte b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/index.svelte deleted file mode 100644 index 9277207e37..0000000000 --- a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/index.svelte +++ /dev/null @@ -1,86 +0,0 @@ - - -
-
- {#each Object.entries(integrations) as [integrationType, schema]} -
selectIntegration(integrationType)} - > - - {schema.name || integrationType} -
- {/each} -
-
- - diff --git a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/rest/RestExtraConfigForm.svelte b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/rest/RestExtraConfigForm.svelte deleted file mode 100644 index fc495ec3f2..0000000000 --- a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/rest/RestExtraConfigForm.svelte +++ /dev/null @@ -1,137 +0,0 @@ - - - -
-
- Headers - Optional -
-
- -
-
- - Headers enable you to provide additional information about the request, such - as format. - - onDefaultHeaderUpdate(evt.detail)} - noAddButton - bindings={getRestBindings()} -/> -
- addHeader.addEntry()}> - Add header - -
- - -
-
- Authentication - Optional -
-
- -
-
- - Create an authentication config that can be shared with queries. - - - - -
-
- Variables - Optional -
-
- -
-
-Variables enable you to store and re-use values in queries, with the choice - of a static value such as a token using static variables, or a value from a - query response using dynamic variables. -Static - - - -
-Dynamic - - Dynamic variables are evaluated when a dependant query is executed. The value - is cached for a period of time and will be refreshed if a query fails. - - - - diff --git a/packages/builder/src/components/backend/Datasources/CreateEditRelationshipModal.svelte b/packages/builder/src/components/backend/Datasources/CreateEditRelationshipModal.svelte new file mode 100644 index 0000000000..03683bcfc9 --- /dev/null +++ b/packages/builder/src/components/backend/Datasources/CreateEditRelationshipModal.svelte @@ -0,0 +1,66 @@ + + + + + + + diff --git a/packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/index.svelte b/packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/index.svelte index 9dfe18a407..59ea8ce1d1 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/index.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/index.svelte @@ -33,7 +33,7 @@ // A REST integration is created immediately, we don't need to display a config modal. loading = true datasources - .create({ integration, fields: configFromIntegration(integration) }) + .create({ integration, config: configFromIntegration(integration) }) .then(datasource => { store.setIntegration(integration) store.setDatasource(datasource) diff --git a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/rest/auth/AuthTypeRenderer.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication/AuthTypeRenderer.svelte similarity index 100% rename from packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/rest/auth/AuthTypeRenderer.svelte rename to packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication/AuthTypeRenderer.svelte diff --git a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/rest/auth/RestAuthenticationBuilder.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication/RestAuthenticationBuilder.svelte similarity index 69% rename from packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/rest/auth/RestAuthenticationBuilder.svelte rename to packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication/RestAuthenticationBuilder.svelte index 92f1269a82..c94cbbf81c 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/rest/auth/RestAuthenticationBuilder.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication/RestAuthenticationBuilder.svelte @@ -3,9 +3,11 @@ import AuthTypeRenderer from "./AuthTypeRenderer.svelte" import RestAuthenticationModal from "./RestAuthenticationModal.svelte" import { Helpers } from "@budibase/bbui" + import { createEventDispatcher } from "svelte" - export let configs = [] + export let authConfigs = [] + const dispatch = createEventDispatcher() let currentConfig = null let modal @@ -20,8 +22,10 @@ } const onConfirm = config => { + let newAuthConfigs + if (currentConfig) { - configs = configs.map(c => { + newAuthConfigs = authConfigs.map(c => { // replace the current config with the new one if (c._id === currentConfig._id) { return config @@ -30,27 +34,36 @@ }) } else { config._id = Helpers.uuid() - configs = [...configs, config] + newAuthConfigs = [...authConfigs, config] } + + dispatch("change", newAuthConfigs) } const onRemove = () => { - configs = configs.filter(c => { + const newAuthConfigs = authConfigs.filter(c => { return c._id !== currentConfig._id }) + + dispatch("change", newAuthConfigs) } - + - {#if configs && configs.length > 0} + {#if authConfigs && authConfigs.length > 0}
openConfigModal(detail)} {schema} - data={configs} + data={authConfigs} allowEditColumns={false} allowEditRows={false} allowSelectRows={false} diff --git a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/rest/auth/RestAuthenticationModal.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication/RestAuthenticationModal.svelte similarity index 100% rename from packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/rest/auth/RestAuthenticationModal.svelte rename to packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication/RestAuthenticationModal.svelte diff --git a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/rest/auth/authTypes.js b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication/authTypes.js similarity index 100% rename from packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/rest/auth/authTypes.js rename to packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication/authTypes.js diff --git a/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication/index.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication/index.svelte new file mode 100644 index 0000000000..439ef961ed --- /dev/null +++ b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication/index.svelte @@ -0,0 +1,27 @@ + + + + + + updateAuthConfigs(detail)} + authConfigs={updatedDatasource.config.authConfigs} + /> + diff --git a/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Headers.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Headers.svelte new file mode 100644 index 0000000000..221547309b --- /dev/null +++ b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Headers.svelte @@ -0,0 +1,53 @@ + + + + + + onDefaultHeaderUpdate(evt.detail)} + noAddButton + bindings={restBindings} + /> +
+ addHeader.addEntry()}> + Add header + +
+
diff --git a/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Panel.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Panel.svelte new file mode 100644 index 0000000000..4ef602bffb --- /dev/null +++ b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Panel.svelte @@ -0,0 +1,27 @@ + + +
+
+
+ +
+
+ +
+
+
+ +
+
+ + diff --git a/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Queries/RestImportButton.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Queries/RestImportButton.svelte new file mode 100644 index 0000000000..682284adca --- /dev/null +++ b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Queries/RestImportButton.svelte @@ -0,0 +1,21 @@ + + + + + + +
+ +
+ + diff --git a/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Queries/RestImportQueriesModal.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Queries/RestImportQueriesModal.svelte new file mode 100644 index 0000000000..82a2aa8066 --- /dev/null +++ b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Queries/RestImportQueriesModal.svelte @@ -0,0 +1,132 @@ + + + importQueries()} + {onCancel} + confirmText={"Import"} + cancelText="Back" + size="L" +> + + Import + Import your rest collection using one of the options below + + + + + { + $data.file = e.detail?.[0] + lastTouched = "file" + }} + fileTags={[ + "OpenAPI 3.0", + "OpenAPI 2.0", + "Swagger 2.0", + "cURL", + "YAML", + "JSON", + ]} + maximum={1} + /> + + +