From e2033898b0d7e23ce72b6ca5b84aa544a8b3445e Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Tue, 30 Aug 2022 11:17:11 +0100 Subject: [PATCH 001/208] Add additional params to listObjects --- packages/server/src/integrations/s3.ts | 34 ++++++++++++++++--- .../server/src/integrations/tests/s3.spec.js | 12 +++++-- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/packages/server/src/integrations/s3.ts b/packages/server/src/integrations/s3.ts index e8da696424..fabb6daa3d 100644 --- a/packages/server/src/integrations/s3.ts +++ b/packages/server/src/integrations/s3.ts @@ -1,4 +1,4 @@ -import { Integration, QueryType, IntegrationBase } from "@budibase/types" +import { Integration, QueryType, IntegrationBase, DatasourceFieldType } from "@budibase/types" module S3Module { const AWS = require("aws-sdk") @@ -46,12 +46,25 @@ module S3Module { type: QueryType.FIELDS, fields: { bucket: { - type: "string", + type: DatasourceFieldType.STRING, required: true, }, + delimiter: { + type: DatasourceFieldType.STRING, + }, + marker: { + type: DatasourceFieldType.STRING, + }, + maxKeys: { + type: DatasourceFieldType.NUMBER, + display: "Max Keys", + }, + prefix: { + type: DatasourceFieldType.STRING, + }, }, - }, - }, + } + } } class S3Integration implements IntegrationBase { @@ -69,10 +82,21 @@ module S3Module { this.client = new AWS.S3(this.config) } - async read(query: { bucket: string }) { + async read(query: { + bucket: string, + delimiter: string, + expectedBucketOwner: string, + marker: string, + maxKeys: number, + prefix: string, + }) { const response = await this.client .listObjects({ Bucket: query.bucket, + Delimiter: query.delimiter, + Marker: query.marker, + MaxKeys: query.maxKeys, + Prefix: query.prefix, }) .promise() return response.Contents diff --git a/packages/server/src/integrations/tests/s3.spec.js b/packages/server/src/integrations/tests/s3.spec.js index 7ac403dbd4..a655112973 100644 --- a/packages/server/src/integrations/tests/s3.spec.js +++ b/packages/server/src/integrations/tests/s3.spec.js @@ -17,10 +17,18 @@ describe("S3 Integration", () => { it("calls the read method with the correct params", async () => { const response = await config.integration.read({ - bucket: "test" + bucket: "test", + delimiter: "/", + marker: "file.txt", + maxKeys: 999, + prefix: "directory/", }) expect(config.integration.client.listObjects).toHaveBeenCalledWith({ - Bucket: "test" + Bucket: "test", + Delimiter: "/", + Marker: "file.txt", + MaxKeys: 999, + Prefix: "directory/" }) }) }) \ No newline at end of file From 9e864e07a9ea8cf270611df8e75de88a7dc0dcbf Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Tue, 30 Aug 2022 13:42:49 +0100 Subject: [PATCH 002/208] WIP --- packages/server/package.json | 2 +- packages/server/src/integrations/s3.ts | 66 ++++++++++++++++++++++---- packages/server/yarn.lock | 2 +- 3 files changed, 58 insertions(+), 12 deletions(-) diff --git a/packages/server/package.json b/packages/server/package.json index 4ef6a5bd18..4d4c580709 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -95,7 +95,7 @@ "bcryptjs": "2.4.3", "bull": "4.8.5", "chmodr": "1.2.0", - "csvtojson": "2.0.10", + "csvtojson": "^2.0.10", "curlconverter": "3.21.0", "dotenv": "8.2.0", "download": "8.0.0", diff --git a/packages/server/src/integrations/s3.ts b/packages/server/src/integrations/s3.ts index fabb6daa3d..ddae25eee8 100644 --- a/packages/server/src/integrations/s3.ts +++ b/packages/server/src/integrations/s3.ts @@ -1,7 +1,13 @@ -import { Integration, QueryType, IntegrationBase, DatasourceFieldType } from "@budibase/types" +import { + Integration, + QueryType, + IntegrationBase, + DatasourceFieldType, +} from "@budibase/types" module S3Module { const AWS = require("aws-sdk") + const csv = require("csvtojson") interface S3Config { region: string @@ -63,8 +69,22 @@ module S3Module { type: DatasourceFieldType.STRING, }, }, - } - } + }, + readCsv: { + displayName: "Read CSV", + type: QueryType.FIELDS, + fields: { + bucket: { + type: DatasourceFieldType.STRING, + required: true, + }, + key: { + type: DatasourceFieldType.STRING, + required: true, + }, + }, + }, + }, } class S3Integration implements IntegrationBase { @@ -82,13 +102,13 @@ module S3Module { this.client = new AWS.S3(this.config) } - async read(query: { - bucket: string, - delimiter: string, - expectedBucketOwner: string, - marker: string, - maxKeys: number, - prefix: string, + async read(query: { + bucket: string + delimiter: string + expectedBucketOwner: string + marker: string + maxKeys: number + prefix: string }) { const response = await this.client .listObjects({ @@ -101,6 +121,32 @@ module S3Module { .promise() return response.Contents } + + async readCsv(query: { bucket: string; key: string }) { + let streamErr: string | undefined = undefined + const stream = this.client + .getObject({ + Bucket: query.bucket, + Key: query.key, + }) + .createReadStream() + .on("error", (err: string) => { + //stream.destroy() + // + console.log("err ", err) + streamErr = "ERROR" + }) + + if (streamErr) { + throw new Error("ERROR") + } + + try { + return await csv().fromStream(stream) + } catch (err) { + throw new Error("Failed to read CSV") + } + } } module.exports = { diff --git a/packages/server/yarn.lock b/packages/server/yarn.lock index 0e6b40cc30..64239ce820 100644 --- a/packages/server/yarn.lock +++ b/packages/server/yarn.lock @@ -4924,7 +4924,7 @@ cssstyle@^2.3.0: dependencies: cssom "~0.3.6" -csvtojson@2.0.10: +csvtojson@^2.0.10: version "2.0.10" resolved "https://registry.yarnpkg.com/csvtojson/-/csvtojson-2.0.10.tgz#11e7242cc630da54efce7958a45f443210357574" integrity sha512-lUWFxGKyhraKCW8Qghz6Z0f2l/PqB1W3AO0HKJzGIQ5JRSlR651ekJDiGJbBT4sRNNv5ddnSGVEnsxP9XRCVpQ== From 1e70f6afb4122e74566652a755b658f887f892f6 Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Tue, 30 Aug 2022 13:55:55 +0100 Subject: [PATCH 003/208] Promisify stream --- packages/server/src/integrations/s3.ts | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/packages/server/src/integrations/s3.ts b/packages/server/src/integrations/s3.ts index ddae25eee8..43aa04de6a 100644 --- a/packages/server/src/integrations/s3.ts +++ b/packages/server/src/integrations/s3.ts @@ -123,29 +123,22 @@ module S3Module { } async readCsv(query: { bucket: string; key: string }) { - let streamErr: string | undefined = undefined const stream = this.client .getObject({ Bucket: query.bucket, Key: query.key, }) .createReadStream() - .on("error", (err: string) => { - //stream.destroy() - // - console.log("err ", err) - streamErr = "ERROR" - }) - if (streamErr) { - throw new Error("ERROR") - } - - try { - return await csv().fromStream(stream) - } catch (err) { - throw new Error("Failed to read CSV") - } + return new Promise((resolve, reject) => { + stream + .on("error", (err: Error) => { + reject(err) + }) + .on("finish", async () => { + resolve(csv().fromStream(stream)) + }) + }) } } From 8c40394d3561c18bbaf4ac655fb33149c70f3e1e Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Tue, 30 Aug 2022 15:18:44 +0100 Subject: [PATCH 004/208] Handle non-csv file error --- packages/server/src/integrations/s3.ts | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/packages/server/src/integrations/s3.ts b/packages/server/src/integrations/s3.ts index 43aa04de6a..eb3605af8f 100644 --- a/packages/server/src/integrations/s3.ts +++ b/packages/server/src/integrations/s3.ts @@ -130,14 +130,25 @@ module S3Module { }) .createReadStream() - return new Promise((resolve, reject) => { - stream - .on("error", (err: Error) => { - reject(err) - }) - .on("finish", async () => { - resolve(csv().fromStream(stream)) + let csvError = false + return new Promise(async (resolve, reject) => { + stream.on("error", (err: Error) => { + reject(err) + }) + const response = csv() + .fromStream(stream) + .on("error", () => { + csvError = true }) + stream.on("finish", () => { + resolve(response) + }) + }).catch(err => { + if (csvError) { + throw new Error("Could not read CSV") + } else { + throw err + } }) } } From 0e219e15455e9fd8844d598f3fa9cab396ead80c Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Tue, 30 Aug 2022 15:19:18 +0100 Subject: [PATCH 005/208] remove async --- packages/server/src/integrations/s3.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/integrations/s3.ts b/packages/server/src/integrations/s3.ts index eb3605af8f..f24fe92f6b 100644 --- a/packages/server/src/integrations/s3.ts +++ b/packages/server/src/integrations/s3.ts @@ -131,7 +131,7 @@ module S3Module { .createReadStream() let csvError = false - return new Promise(async (resolve, reject) => { + return new Promise((resolve, reject) => { stream.on("error", (err: Error) => { reject(err) }) From 3443e2cd48774e8e739d68f98d7de4397f43af69 Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Tue, 30 Aug 2022 16:56:56 +0100 Subject: [PATCH 006/208] Create WIP --- packages/server/src/integrations/s3.ts | 92 +++++++++++++++++++ .../server/src/integrations/tests/s3.spec.js | 32 ++++++- 2 files changed, 123 insertions(+), 1 deletion(-) diff --git a/packages/server/src/integrations/s3.ts b/packages/server/src/integrations/s3.ts index f24fe92f6b..67568436c3 100644 --- a/packages/server/src/integrations/s3.ts +++ b/packages/server/src/integrations/s3.ts @@ -48,6 +48,41 @@ module S3Module { }, }, query: { + create: { + type: QueryType.FIELDS, + fields: { + bucket: { + display: "New Bucket", + type: DatasourceFieldType.STRING, + required: true, + }, + location: { + required: true, + default: "us-east-1", + type: DatasourceFieldType.STRING, + }, + grantFullControl: { + display: "Grant full control", + type: DatasourceFieldType.STRING, + }, + grantRead: { + display: "Grant read", + type: DatasourceFieldType.STRING, + }, + grantReadAcp: { + display: "Grant read ACP", + type: DatasourceFieldType.STRING, + }, + grantWrite: { + display: "Grant write", + type: DatasourceFieldType.STRING, + }, + grantWriteAcp: { + display: "Grant write ACP", + type: DatasourceFieldType.STRING, + }, + }, + }, read: { type: QueryType.FIELDS, fields: { @@ -85,6 +120,33 @@ module S3Module { }, }, }, + extra: { + acl: { + required: false, + displayName: "ACL", + type: DatasourceFieldType.LIST, + data: { + create: [ + "private", + "public-read", + "public-read-write", + "authenticated-read", + ] + } + }, + objectOwnership: { + required: false, + displayName: "Object ownership", + type: DatasourceFieldType.LIST, + data: { + create: [ + "BucketOwnerPreferred", + "ObjectWriter", + "BucketOwnerEnforced", + ], + }, + }, + } } class S3Integration implements IntegrationBase { @@ -102,6 +164,36 @@ module S3Module { this.client = new AWS.S3(this.config) } + async create(query: { + bucket: string, + location: string, + grantFullControl: string, + grantRead: string, + grantReadAcp: string, + grantWrite: string, + grantWriteAcp: string, + extra: { + acl: string, + objectOwnership: string, + }}) { + const response = await this.client.createBucket({ + Bucket: query.bucket, + // ACL: query.extra?.acl, + CreateBucketConfiguration: { + LocationConstraint: query.location + }, + GrantFullControl: query.grantFullControl, + GrantRead: query.grantRead, + GrantReadACP: query.grantReadAcp, + GrantWrite: query.grantWrite, + GrantWriteACP: query.grantWriteAcp, + }, (err: any) => { + console.log("ERR ", err) + }) + .promise() + return response.Contents + } + async read(query: { bucket: string delimiter: string diff --git a/packages/server/src/integrations/tests/s3.spec.js b/packages/server/src/integrations/tests/s3.spec.js index a655112973..48e7221ef8 100644 --- a/packages/server/src/integrations/tests/s3.spec.js +++ b/packages/server/src/integrations/tests/s3.spec.js @@ -16,7 +16,7 @@ describe("S3 Integration", () => { }) it("calls the read method with the correct params", async () => { - const response = await config.integration.read({ + await config.integration.read({ bucket: "test", delimiter: "/", marker: "file.txt", @@ -31,4 +31,34 @@ describe("S3 Integration", () => { Prefix: "directory/" }) }) + + it("calls the create method with the correct params", async () => { + await config.integration.create({ + bucket: "test", + location: "af-south-1", + grantFullControl: "me", + grantRead: "him", + grantReadAcp: "her", + grantWrite: "she", + grantWriteAcp: "he", + objectLockEnabledForBucket: true + }, { + acl: "private", + objectOwnership: "BucketOwnerPreferred" + }) + expect(config.integration.client.createBucket).toHaveBeenCalledWith({ + Bucket: "test", + CreateBucketConfiguration: { + LocationConstraint: "af-south-1" + }, + GrantFullControl: "me", + GrantRead: "him", + GrantReadAcp: "her", + GrantWrite: "she", + GrantWriteAcp: "he", + ObjectLockEnabledForBucket: true, + ACL: "private", + ObjectOwnership: "BucketOwnerPreferred" + }) + }) }) \ No newline at end of file From 088cf26b468f876f6b61a25b2d136ec2d78323c0 Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Tue, 30 Aug 2022 19:17:10 +0100 Subject: [PATCH 007/208] Create Bucket --- packages/server/__mocks__/aws-sdk.ts | 7 +++ packages/server/src/integrations/s3.ts | 54 ++++++++----------- .../server/src/integrations/tests/s3.spec.js | 29 +++++++--- 3 files changed, 49 insertions(+), 41 deletions(-) diff --git a/packages/server/__mocks__/aws-sdk.ts b/packages/server/__mocks__/aws-sdk.ts index 75353db7e6..24873ac174 100644 --- a/packages/server/__mocks__/aws-sdk.ts +++ b/packages/server/__mocks__/aws-sdk.ts @@ -37,6 +37,13 @@ module AwsMock { Contents: {}, }) ) + + // @ts-ignore + this.createBucket = jest.fn( + response({ + Contents: {}, + }) + ) } aws.DynamoDB = { DocumentClient } diff --git a/packages/server/src/integrations/s3.ts b/packages/server/src/integrations/s3.ts index 67568436c3..b717ece222 100644 --- a/packages/server/src/integrations/s3.ts +++ b/packages/server/src/integrations/s3.ts @@ -131,22 +131,10 @@ module S3Module { "public-read", "public-read-write", "authenticated-read", - ] - } - }, - objectOwnership: { - required: false, - displayName: "Object ownership", - type: DatasourceFieldType.LIST, - data: { - create: [ - "BucketOwnerPreferred", - "ObjectWriter", - "BucketOwnerEnforced", ], }, }, - } + }, } class S3Integration implements IntegrationBase { @@ -165,33 +153,33 @@ module S3Module { } async create(query: { - bucket: string, - location: string, - grantFullControl: string, - grantRead: string, - grantReadAcp: string, - grantWrite: string, - grantWriteAcp: string, + bucket: string + location: string + grantFullControl: string + grantRead: string + grantReadAcp: string + grantWrite: string + grantWriteAcp: string extra: { - acl: string, - objectOwnership: string, - }}) { - const response = await this.client.createBucket({ + acl: string + } + }) { + let params: any = { Bucket: query.bucket, - // ACL: query.extra?.acl, - CreateBucketConfiguration: { - LocationConstraint: query.location - }, + ACL: query.extra?.acl, GrantFullControl: query.grantFullControl, GrantRead: query.grantRead, GrantReadACP: query.grantReadAcp, GrantWrite: query.grantWrite, GrantWriteACP: query.grantWriteAcp, - }, (err: any) => { - console.log("ERR ", err) - }) - .promise() - return response.Contents + } + if (query.location) { + params["CreateBucketConfiguration"] = { + LocationConstraint: query.location, + } + } + const response = await this.client.createBucket(params).promise() + return response } async read(query: { diff --git a/packages/server/src/integrations/tests/s3.spec.js b/packages/server/src/integrations/tests/s3.spec.js index 48e7221ef8..26a87fa99f 100644 --- a/packages/server/src/integrations/tests/s3.spec.js +++ b/packages/server/src/integrations/tests/s3.spec.js @@ -41,10 +41,10 @@ describe("S3 Integration", () => { grantReadAcp: "her", grantWrite: "she", grantWriteAcp: "he", - objectLockEnabledForBucket: true - }, { - acl: "private", - objectOwnership: "BucketOwnerPreferred" + objectLockEnabledForBucket: true, + extra: { + acl: "private" + } }) expect(config.integration.client.createBucket).toHaveBeenCalledWith({ Bucket: "test", @@ -53,12 +53,25 @@ describe("S3 Integration", () => { }, GrantFullControl: "me", GrantRead: "him", - GrantReadAcp: "her", + GrantReadACP: "her", GrantWrite: "she", - GrantWriteAcp: "he", - ObjectLockEnabledForBucket: true, + GrantWriteACP: "he", ACL: "private", - ObjectOwnership: "BucketOwnerPreferred" + }) + }) + + it("does not add undefined location constraint when calling the create method", async () => { + await config.integration.create({ + bucket: "test" + }) + expect(config.integration.client.createBucket).toHaveBeenCalledWith({ + Bucket: "test", + GrantFullControl: undefined, + GrantRead: undefined, + GrantReadACP: undefined, + GrantWrite: undefined, + GrantWriteACP: undefined, + ACL: undefined, }) }) }) \ No newline at end of file From 0e44703e95ec1f1e5547e9e2b72afe999474eff2 Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Tue, 30 Aug 2022 19:56:08 +0100 Subject: [PATCH 008/208] Delete method S3 Bucket --- packages/server/__mocks__/aws-sdk.ts | 7 ++++ packages/server/src/integrations/s3.ts | 25 ++++++++++++-- .../server/src/integrations/tests/s3.spec.js | 33 +++++++++++++++++++ 3 files changed, 63 insertions(+), 2 deletions(-) diff --git a/packages/server/__mocks__/aws-sdk.ts b/packages/server/__mocks__/aws-sdk.ts index 24873ac174..b0da0e97b6 100644 --- a/packages/server/__mocks__/aws-sdk.ts +++ b/packages/server/__mocks__/aws-sdk.ts @@ -44,6 +44,13 @@ module AwsMock { Contents: {}, }) ) + + // @ts-ignore + this.deleteObjects = jest.fn( + response({ + Contents: {}, + }) + ) } aws.DynamoDB = { DocumentClient } diff --git a/packages/server/src/integrations/s3.ts b/packages/server/src/integrations/s3.ts index b717ece222..72e664fe16 100644 --- a/packages/server/src/integrations/s3.ts +++ b/packages/server/src/integrations/s3.ts @@ -119,6 +119,19 @@ module S3Module { }, }, }, + delete: { + type: QueryType.FIELDS, + fields: { + bucket: { + type: DatasourceFieldType.STRING, + required: true, + }, + delete: { + type: DatasourceFieldType.JSON, + required: true, + }, + }, + } }, extra: { acl: { @@ -178,8 +191,7 @@ module S3Module { LocationConstraint: query.location, } } - const response = await this.client.createBucket(params).promise() - return response + return await this.client.createBucket(params).promise() } async read(query: { @@ -231,6 +243,15 @@ module S3Module { } }) } + + async delete(query: { bucket: string, delete: string }) { + return await this.client + .deleteObjects({ + Bucket: query.bucket, + Delete: JSON.parse(query.delete), + }) + .promise() + } } module.exports = { diff --git a/packages/server/src/integrations/tests/s3.spec.js b/packages/server/src/integrations/tests/s3.spec.js index 26a87fa99f..fc2477a225 100644 --- a/packages/server/src/integrations/tests/s3.spec.js +++ b/packages/server/src/integrations/tests/s3.spec.js @@ -74,4 +74,37 @@ describe("S3 Integration", () => { ACL: undefined, }) }) + + it("calls the delete method with the correct params ", async () => { + await config.integration.delete({ + bucket: "test", + delete: `{ + "Objects": [ + { + "Key": "HappyFace.jpg", + "VersionId": "2LWg7lQLnY41.maGB5Z6SWW.dcq0vx7b" + }, + { + "Key": "HappyFace.jpg", + "VersionId": "yoz3HB.ZhCS_tKVEmIOr7qYyyAaZSKVd" + } + ] + }` + }) + expect(config.integration.client.deleteObjects).toHaveBeenCalledWith({ + Bucket: "test", + Delete: { + Objects: [ + { + Key: "HappyFace.jpg", + VersionId: "2LWg7lQLnY41.maGB5Z6SWW.dcq0vx7b" + }, + { + Key: "HappyFace.jpg", + VersionId: "yoz3HB.ZhCS_tKVEmIOr7qYyyAaZSKVd" + } + ] + } + }) + }) }) \ No newline at end of file From b11b3c11fbd37262be2b70706d5b3fb34dc60b4e Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Tue, 30 Aug 2022 19:56:38 +0100 Subject: [PATCH 009/208] lint --- packages/server/src/integrations/s3.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/server/src/integrations/s3.ts b/packages/server/src/integrations/s3.ts index 72e664fe16..2ff594495d 100644 --- a/packages/server/src/integrations/s3.ts +++ b/packages/server/src/integrations/s3.ts @@ -131,7 +131,7 @@ module S3Module { required: true, }, }, - } + }, }, extra: { acl: { @@ -244,13 +244,13 @@ module S3Module { }) } - async delete(query: { bucket: string, delete: string }) { + async delete(query: { bucket: string; delete: string }) { return await this.client - .deleteObjects({ - Bucket: query.bucket, - Delete: JSON.parse(query.delete), - }) - .promise() + .deleteObjects({ + Bucket: query.bucket, + Delete: JSON.parse(query.delete), + }) + .promise() } } From bb4ee20bd624f3f0f806589912ecf8da0c618c02 Mon Sep 17 00:00:00 2001 From: Dean Date: Mon, 17 Oct 2022 12:03:13 +0100 Subject: [PATCH 010/208] Values or defaults passed to the picker are parsed to ensure only valid options are marked/added to the component. --- .../bbui/src/Form/Core/Multiselect.svelte | 22 ++++++++++++++++--- .../common/bindings/BindingPanel.svelte | 2 +- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/packages/bbui/src/Form/Core/Multiselect.svelte b/packages/bbui/src/Form/Core/Multiselect.svelte index eb39e39042..3fbbaf5d4a 100644 --- a/packages/bbui/src/Form/Core/Multiselect.svelte +++ b/packages/bbui/src/Form/Core/Multiselect.svelte @@ -15,12 +15,28 @@ export let sort = false export let autoWidth = false + $: streamed = Array.isArray(value) + ? value.reduce((acc, ele) => { + if (typeof ele === "string") { + let temp = ele.trim() + if (!temp) { + return acc + } + } + let processedOpt = ele.toString() + if (options.indexOf(processedOpt) > -1) { + acc.push(ele.toString()) + } + return acc + }, []) + : [] + const dispatch = createEventDispatcher() - $: selectedLookupMap = getSelectedLookupMap(value) + $: selectedLookupMap = getSelectedLookupMap(streamed) $: optionLookupMap = getOptionLookupMap(options) - $: fieldText = getFieldText(value, optionLookupMap, placeholder) + $: fieldText = getFieldText(streamed, optionLookupMap, placeholder) $: isOptionSelected = optionValue => selectedLookupMap[optionValue] === true - $: toggleOption = makeToggleOption(selectedLookupMap, value) + $: toggleOption = makeToggleOption(selectedLookupMap, streamed) const getFieldText = (value, map, placeholder) => { if (Array.isArray(value) && value.length > 0) { diff --git a/packages/builder/src/components/common/bindings/BindingPanel.svelte b/packages/builder/src/components/common/bindings/BindingPanel.svelte index 1a1714967d..d105253e14 100644 --- a/packages/builder/src/components/common/bindings/BindingPanel.svelte +++ b/packages/builder/src/components/common/bindings/BindingPanel.svelte @@ -247,7 +247,7 @@ return } hoverTarget = { - title: binding.display?.name || binding.fieldSchema.name, + title: binding.display?.name || binding.fieldSchema?.name, description: binding.description, } popover.show() From 50eee8d938199807cbfdb3024e897ac85f32a6dc Mon Sep 17 00:00:00 2001 From: Dean Date: Mon, 17 Oct 2022 12:08:37 +0100 Subject: [PATCH 011/208] Added the json field type to the Automation field block. Also added in the automation icon to identify the automation bindings --- .../automation/SetupPanel/RowSelector.svelte | 13 ++++++++++-- .../SetupPanel/RowSelectorTypes.svelte | 21 ++++++++++++++++++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/packages/builder/src/components/automation/SetupPanel/RowSelector.svelte b/packages/builder/src/components/automation/SetupPanel/RowSelector.svelte index c72acc252a..b3d50c1658 100644 --- a/packages/builder/src/components/automation/SetupPanel/RowSelector.svelte +++ b/packages/builder/src/components/automation/SetupPanel/RowSelector.svelte @@ -14,6 +14,11 @@ export let block export let isTestModal + $: parsedBindings = bindings.map(binding => { + binding.icon = "ShareAndroid" + return binding + }) + let table let schemaFields @@ -79,6 +84,10 @@ return [value] } + if (type === "json") { + return value.value + } + return value } @@ -109,7 +118,7 @@ {isTestModal} {field} {schema} - {bindings} + bindings={parsedBindings} {value} {onChange} /> @@ -124,7 +133,7 @@ on:change={e => onChange(e, field, schema.type)} label={field} type="string" - {bindings} + bindings={parsedBindings} fillWidth={true} allowJS={true} updateOnChange={false} diff --git a/packages/builder/src/components/automation/SetupPanel/RowSelectorTypes.svelte b/packages/builder/src/components/automation/SetupPanel/RowSelectorTypes.svelte index f3abad6e25..30b888b5fb 100644 --- a/packages/builder/src/components/automation/SetupPanel/RowSelectorTypes.svelte +++ b/packages/builder/src/components/automation/SetupPanel/RowSelectorTypes.svelte @@ -5,11 +5,13 @@ DatePicker, Multiselect, TextArea, + Label, } from "@budibase/bbui" import LinkedRowSelector from "components/common/LinkedRowSelector.svelte" import DrawerBindableInput from "../../common/bindings/DrawerBindableInput.svelte" import ModalBindableInput from "../../common/bindings/ModalBindableInput.svelte" import AutomationBindingPanel from "../../common/bindings/ServerBindingPanel.svelte" + import Editor from "components/integration/QueryEditor.svelte" export let onChange export let field @@ -18,6 +20,11 @@ export let bindings export let isTestModal + $: parsedBindings = bindings.map(binding => { + binding.icon = "ShareAndroid" + return binding + }) + function schemaHasOptions(schema) { return !!schema.constraints?.inclusion?.length } @@ -50,6 +57,18 @@ /> {:else if schema.type === "longform"}