From 067d508270021ddf14772ac5444f88be7e1a7f71 Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Tue, 28 Jun 2022 13:44:33 +0100 Subject: [PATCH 1/2] Only call slice if Array or string --- packages/bbui/src/Table/ArrayRenderer.svelte | 6 +++++- packages/server/yarn.lock | 18 +++++++++--------- packages/worker/yarn.lock | 18 +++++++++--------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/packages/bbui/src/Table/ArrayRenderer.svelte b/packages/bbui/src/Table/ArrayRenderer.svelte index 679973a03a..6c1df3b982 100644 --- a/packages/bbui/src/Table/ArrayRenderer.svelte +++ b/packages/bbui/src/Table/ArrayRenderer.svelte @@ -5,8 +5,12 @@ const displayLimit = 5 - $: badges = value?.slice(0, displayLimit) ?? [] + $: badges = isValidType() ? value?.slice(0, displayLimit) : [] $: leftover = (value?.length ?? 0) - badges.length + + function isValidType() { + return Array.isArray(value) || typeof value === "string" + } {#each badges as badge} diff --git a/packages/server/yarn.lock b/packages/server/yarn.lock index 10256b76ae..82d7943354 100644 --- a/packages/server/yarn.lock +++ b/packages/server/yarn.lock @@ -1028,10 +1028,10 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@budibase/backend-core@1.0.209": - version "1.0.209" - resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.209.tgz#23f752d52027baf22995b1eb2ea7ea024f16a027" - integrity sha512-JBXdi/U8kXwulG2cerF8B/ijTo5N3tNItXAODy/rkNPbAef9sSpdPrduvUiGH6DKoVnovq2feSSfT0t/Iztwfw== +"@budibase/backend-core@1.0.212": + version "1.0.212" + resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.212.tgz#7ce8bfa8c968f4aa7558bd2dd13ad3e1e3e40c8f" + integrity sha512-pCrAHr54d2onSbaUoCWP83LMJnm28PNIpBAmAhi2kNdSfaGTFY/Iw1sbGOE3G/9vNaB+RRXeibKEEPFjToOgAg== dependencies: "@techpass/passport-openidconnect" "0.3.2" aws-sdk "2.1030.0" @@ -1109,12 +1109,12 @@ svelte-flatpickr "^3.2.3" svelte-portal "^1.0.0" -"@budibase/pro@1.0.209": - version "1.0.209" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.209.tgz#a27175fc2f4da4d065c13bd5d3552cc5f197693a" - integrity sha512-/mEr8O1UpmF1V17sKTzjUrrG7M5g/ofKw7ROT9wEv0sQGE2D2eZtPrjwSHSC0vYHHsTFf/4aQnu+WY9UAdgQdA== +"@budibase/pro@1.0.212": + version "1.0.212" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.212.tgz#d6d2528b9ec2ec47e79d3360d04feeb5d2900d1e" + integrity sha512-RcbDmz3pkReUHXAJDPzvgTYy0CBksw55XLbW0wNtDu2HVWP0ZXoiMMJjOxNDwMfL3q4eZitWgISa7QUDisDtMA== dependencies: - "@budibase/backend-core" "1.0.209" + "@budibase/backend-core" "1.0.212" node-fetch "^2.6.1" "@budibase/standard-components@^0.9.139": diff --git a/packages/worker/yarn.lock b/packages/worker/yarn.lock index 6bb6b972be..96cc5c5750 100644 --- a/packages/worker/yarn.lock +++ b/packages/worker/yarn.lock @@ -291,10 +291,10 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@budibase/backend-core@1.0.209": - version "1.0.209" - resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.209.tgz#23f752d52027baf22995b1eb2ea7ea024f16a027" - integrity sha512-JBXdi/U8kXwulG2cerF8B/ijTo5N3tNItXAODy/rkNPbAef9sSpdPrduvUiGH6DKoVnovq2feSSfT0t/Iztwfw== +"@budibase/backend-core@1.0.212": + version "1.0.212" + resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.212.tgz#7ce8bfa8c968f4aa7558bd2dd13ad3e1e3e40c8f" + integrity sha512-pCrAHr54d2onSbaUoCWP83LMJnm28PNIpBAmAhi2kNdSfaGTFY/Iw1sbGOE3G/9vNaB+RRXeibKEEPFjToOgAg== dependencies: "@techpass/passport-openidconnect" "0.3.2" aws-sdk "2.1030.0" @@ -322,12 +322,12 @@ uuid "8.3.2" zlib "1.0.5" -"@budibase/pro@1.0.209": - version "1.0.209" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.209.tgz#a27175fc2f4da4d065c13bd5d3552cc5f197693a" - integrity sha512-/mEr8O1UpmF1V17sKTzjUrrG7M5g/ofKw7ROT9wEv0sQGE2D2eZtPrjwSHSC0vYHHsTFf/4aQnu+WY9UAdgQdA== +"@budibase/pro@1.0.212": + version "1.0.212" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.212.tgz#d6d2528b9ec2ec47e79d3360d04feeb5d2900d1e" + integrity sha512-RcbDmz3pkReUHXAJDPzvgTYy0CBksw55XLbW0wNtDu2HVWP0ZXoiMMJjOxNDwMfL3q4eZitWgISa7QUDisDtMA== dependencies: - "@budibase/backend-core" "1.0.209" + "@budibase/backend-core" "1.0.212" node-fetch "^2.6.1" "@cspotcode/source-map-consumer@0.8.0": From 1d40c0684327a96e191735dba712b8482f43fc0f Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Tue, 28 Jun 2022 15:43:34 +0100 Subject: [PATCH 2/2] Refactor --- packages/bbui/src/Table/ArrayRenderer.svelte | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/bbui/src/Table/ArrayRenderer.svelte b/packages/bbui/src/Table/ArrayRenderer.svelte index 6c1df3b982..3755850666 100644 --- a/packages/bbui/src/Table/ArrayRenderer.svelte +++ b/packages/bbui/src/Table/ArrayRenderer.svelte @@ -5,12 +5,8 @@ const displayLimit = 5 - $: badges = isValidType() ? value?.slice(0, displayLimit) : [] + $: badges = Array.isArray(value) ? value.slice(0, displayLimit) : [] $: leftover = (value?.length ?? 0) - badges.length - - function isValidType() { - return Array.isArray(value) || typeof value === "string" - } {#each badges as badge}