From 94e76864bf8ee4fb30b2ef6b2a5c19e33dd685b5 Mon Sep 17 00:00:00 2001 From: deanhannigan Date: Tue, 10 Jan 2023 16:25:23 +0000 Subject: [PATCH 01/30] Render view groupBy array options as tags (#8764) * Fix to properly render groupBy options as tags * Fixes for viewBuilder function definition and some typescript updates --- .../server/src/api/controllers/table/utils.ts | 8 ++++++- .../server/src/api/controllers/view/index.ts | 12 +++++++--- .../src/api/controllers/view/viewBuilder.ts | 22 ++++++++++++------- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/packages/server/src/api/controllers/table/utils.ts b/packages/server/src/api/controllers/table/utils.ts index b672561325..4cc2bf8b1c 100644 --- a/packages/server/src/api/controllers/table/utils.ts +++ b/packages/server/src/api/controllers/table/utils.ts @@ -316,7 +316,13 @@ export async function checkForViewUpdates( // Update view if required if (needsUpdated) { - const newViewTemplate = viewTemplate(view.meta) + const groupByField: any = Object.values(table.schema).find( + (field: any) => field.name == view.groupBy + ) + const newViewTemplate = viewTemplate( + view.meta, + groupByField?.type === FieldTypes.ARRAY + ) await saveView(null, view.name, newViewTemplate) if (!newViewTemplate.meta.schema) { newViewTemplate.meta.schema = table.schema diff --git a/packages/server/src/api/controllers/view/index.ts b/packages/server/src/api/controllers/view/index.ts index 17c3ee301d..f5b30ab722 100644 --- a/packages/server/src/api/controllers/view/index.ts +++ b/packages/server/src/api/controllers/view/index.ts @@ -25,7 +25,15 @@ export async function fetch(ctx: BBContext) { export async function save(ctx: BBContext) { const db = context.getAppDB() const { originalName, ...viewToSave } = ctx.request.body - const view = viewTemplate(viewToSave) + + const existingTable = await db.get(ctx.request.body.tableId) + const table = cloneDeep(existingTable) + + const groupByField: any = Object.values(table.schema).find( + (field: any) => field.name == viewToSave.groupBy + ) + + const view = viewTemplate(viewToSave, groupByField?.type === FieldTypes.ARRAY) const viewName = viewToSave.name if (!viewName) { @@ -35,8 +43,6 @@ export async function save(ctx: BBContext) { await saveView(originalName, viewName, view) // add views to table document - const existingTable = await db.get(ctx.request.body.tableId) - const table = cloneDeep(existingTable) if (!table.views) table.views = {} if (!view.meta.schema) { view.meta.schema = table.schema diff --git a/packages/server/src/api/controllers/view/viewBuilder.ts b/packages/server/src/api/controllers/view/viewBuilder.ts index 3076e311b1..e0496cd3cc 100644 --- a/packages/server/src/api/controllers/view/viewBuilder.ts +++ b/packages/server/src/api/controllers/view/viewBuilder.ts @@ -6,6 +6,7 @@ type ViewTemplateOpts = { groupBy: string filters: ViewFilter[] calculation: string + groupByMulti: boolean } const TOKEN_MAP: Record = { @@ -41,6 +42,12 @@ const GROUP_PROPERTY: Record = { }, } +const GROUP_PROPERTY_MULTI: Record = { + group: { + type: "array", + }, +} + const FIELD_PROPERTY: Record = { field: { type: "string", @@ -136,13 +143,10 @@ function parseEmitExpression(field: string, groupBy: string) { * filters: Array of filter objects containing predicates that are parsed into a JS expression * calculation: an optional calculation to be performed over the view data. */ -export = function ({ - field, - tableId, - groupBy, - filters = [], - calculation, -}: ViewTemplateOpts) { +export = function ( + { field, tableId, groupBy, filters = [], calculation }: ViewTemplateOpts, + groupByMulti?: boolean +) { // first filter can't have a conjunction if (filters && filters.length > 0 && filters[0].conjunction) { delete filters[0].conjunction @@ -151,9 +155,11 @@ export = function ({ let schema = null, statFilter = null + let groupBySchema = groupByMulti ? GROUP_PROPERTY_MULTI : GROUP_PROPERTY + if (calculation) { schema = { - ...(groupBy ? GROUP_PROPERTY : FIELD_PROPERTY), + ...(groupBy ? groupBySchema : FIELD_PROPERTY), ...SCHEMA_MAP[calculation], } if ( From 348f93856b046a81803264ffd55cabb8de2a650e Mon Sep 17 00:00:00 2001 From: Budibase Release Bot <> Date: Tue, 10 Jan 2023 16:38:33 +0000 Subject: [PATCH 02/30] v2.2.13 --- lerna.json | 2 +- packages/backend-core/package.json | 4 ++-- packages/bbui/package.json | 4 ++-- packages/builder/package.json | 10 +++++----- packages/cli/package.json | 8 ++++---- packages/client/package.json | 8 ++++---- packages/frontend-core/package.json | 4 ++-- packages/sdk/package.json | 2 +- packages/server/package.json | 10 +++++----- packages/string-templates/package.json | 2 +- packages/types/package.json | 2 +- packages/worker/package.json | 8 ++++---- 12 files changed, 32 insertions(+), 32 deletions(-) diff --git a/lerna.json b/lerna.json index 4caa4afe17..072ae63ac2 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.2.12", + "version": "2.2.13", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index f4c468c047..d9471b28ae 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/backend-core", - "version": "2.2.12", + "version": "2.2.13", "description": "Budibase backend core libraries used in server and worker", "main": "dist/src/index.js", "types": "dist/src/index.d.ts", @@ -21,7 +21,7 @@ }, "dependencies": { "@budibase/nano": "10.1.1", - "@budibase/types": "^2.2.12", + "@budibase/types": "^2.2.13", "@shopify/jest-koa-mocks": "5.0.1", "@techpass/passport-openidconnect": "0.3.2", "aws-sdk": "2.1030.0", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index ee51cfd977..7ad894ab6e 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/bbui", "description": "A UI solution used in the different Budibase projects.", - "version": "2.2.12", + "version": "2.2.13", "license": "MPL-2.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", @@ -38,7 +38,7 @@ ], "dependencies": { "@adobe/spectrum-css-workflow-icons": "1.2.1", - "@budibase/string-templates": "^2.2.12", + "@budibase/string-templates": "^2.2.13", "@spectrum-css/actionbutton": "1.0.1", "@spectrum-css/actiongroup": "1.0.1", "@spectrum-css/avatar": "3.0.2", diff --git a/packages/builder/package.json b/packages/builder/package.json index 1f67de0032..f01110173f 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "2.2.12", + "version": "2.2.13", "license": "GPL-3.0", "private": true, "scripts": { @@ -71,10 +71,10 @@ } }, "dependencies": { - "@budibase/bbui": "^2.2.12", - "@budibase/client": "^2.2.12", - "@budibase/frontend-core": "^2.2.12", - "@budibase/string-templates": "^2.2.12", + "@budibase/bbui": "^2.2.13", + "@budibase/client": "^2.2.13", + "@budibase/frontend-core": "^2.2.13", + "@budibase/string-templates": "^2.2.13", "@sentry/browser": "5.19.1", "@spectrum-css/page": "^3.0.1", "@spectrum-css/vars": "^3.0.1", diff --git a/packages/cli/package.json b/packages/cli/package.json index dee92cbb55..96e7ca854e 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "2.2.12", + "version": "2.2.13", "description": "Budibase CLI, for developers, self hosting and migrations.", "main": "src/index.js", "bin": { @@ -26,9 +26,9 @@ "outputPath": "build" }, "dependencies": { - "@budibase/backend-core": "^2.2.12", - "@budibase/string-templates": "^2.2.12", - "@budibase/types": "^2.2.12", + "@budibase/backend-core": "^2.2.13", + "@budibase/string-templates": "^2.2.13", + "@budibase/types": "^2.2.13", "axios": "0.21.2", "chalk": "4.1.0", "cli-progress": "3.11.2", diff --git a/packages/client/package.json b/packages/client/package.json index 38c5558b57..a34b615127 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "2.2.12", + "version": "2.2.13", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -19,9 +19,9 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/bbui": "^2.2.12", - "@budibase/frontend-core": "^2.2.12", - "@budibase/string-templates": "^2.2.12", + "@budibase/bbui": "^2.2.13", + "@budibase/frontend-core": "^2.2.13", + "@budibase/string-templates": "^2.2.13", "@spectrum-css/button": "^3.0.3", "@spectrum-css/card": "^3.0.3", "@spectrum-css/divider": "^1.0.3", diff --git a/packages/frontend-core/package.json b/packages/frontend-core/package.json index 8ba3e678b6..3ab20539b5 100644 --- a/packages/frontend-core/package.json +++ b/packages/frontend-core/package.json @@ -1,12 +1,12 @@ { "name": "@budibase/frontend-core", - "version": "2.2.12", + "version": "2.2.13", "description": "Budibase frontend core libraries used in builder and client", "author": "Budibase", "license": "MPL-2.0", "svelte": "src/index.js", "dependencies": { - "@budibase/bbui": "^2.2.12", + "@budibase/bbui": "^2.2.13", "lodash": "^4.17.21", "svelte": "^3.46.2" } diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 7ea3deda91..22f6c005e5 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/sdk", - "version": "2.2.12", + "version": "2.2.13", "description": "Budibase Public API SDK", "author": "Budibase", "license": "MPL-2.0", diff --git a/packages/server/package.json b/packages/server/package.json index fa8f5959d1..94fef84ef0 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "2.2.12", + "version": "2.2.13", "description": "Budibase Web Server", "main": "src/index.ts", "repository": { @@ -43,11 +43,11 @@ "license": "GPL-3.0", "dependencies": { "@apidevtools/swagger-parser": "10.0.3", - "@budibase/backend-core": "^2.2.12", - "@budibase/client": "^2.2.12", + "@budibase/backend-core": "^2.2.13", + "@budibase/client": "^2.2.13", "@budibase/pro": "2.2.12", - "@budibase/string-templates": "^2.2.12", - "@budibase/types": "^2.2.12", + "@budibase/string-templates": "^2.2.13", + "@budibase/types": "^2.2.13", "@bull-board/api": "3.7.0", "@bull-board/koa": "3.9.4", "@elastic/elasticsearch": "7.10.0", diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index c89620a158..34f264d5f0 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "2.2.12", + "version": "2.2.13", "description": "Handlebars wrapper for Budibase templating.", "main": "src/index.cjs", "module": "dist/bundle.mjs", diff --git a/packages/types/package.json b/packages/types/package.json index 9c4ee2411e..e93a3fa65b 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/types", - "version": "2.2.12", + "version": "2.2.13", "description": "Budibase types", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/worker/package.json b/packages/worker/package.json index 2ebb4d703f..a3cc6ab77a 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "2.2.12", + "version": "2.2.13", "description": "Budibase background service", "main": "src/index.ts", "repository": { @@ -36,10 +36,10 @@ "author": "Budibase", "license": "GPL-3.0", "dependencies": { - "@budibase/backend-core": "^2.2.12", + "@budibase/backend-core": "^2.2.13", "@budibase/pro": "2.2.12", - "@budibase/string-templates": "^2.2.12", - "@budibase/types": "^2.2.12", + "@budibase/string-templates": "^2.2.13", + "@budibase/types": "^2.2.13", "@koa/router": "8.0.8", "@sentry/node": "6.17.7", "@techpass/passport-openidconnect": "0.3.2", From 942cfe82608acadc2b9930f8c65a7bb6066edb4c Mon Sep 17 00:00:00 2001 From: Budibase Release Bot <> Date: Tue, 10 Jan 2023 16:42:35 +0000 Subject: [PATCH 03/30] Update pro version to 2.2.13 --- packages/server/package.json | 2 +- packages/server/yarn.lock | 30 +++++++++++++++--------------- packages/worker/package.json | 2 +- packages/worker/yarn.lock | 30 +++++++++++++++--------------- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/packages/server/package.json b/packages/server/package.json index 94fef84ef0..4023d1ece3 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -45,7 +45,7 @@ "@apidevtools/swagger-parser": "10.0.3", "@budibase/backend-core": "^2.2.13", "@budibase/client": "^2.2.13", - "@budibase/pro": "2.2.12", + "@budibase/pro": "2.2.13", "@budibase/string-templates": "^2.2.13", "@budibase/types": "^2.2.13", "@bull-board/api": "3.7.0", diff --git a/packages/server/yarn.lock b/packages/server/yarn.lock index fbac123e04..88c2a0217e 100644 --- a/packages/server/yarn.lock +++ b/packages/server/yarn.lock @@ -1273,13 +1273,13 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@budibase/backend-core@2.2.12": - version "2.2.12" - resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.2.12.tgz#d109a4196e2ca29319649b37b5ba9233e5f3b7ea" - integrity sha512-OgHZhHvpG02CRiJqQfAcXATkNgsi/mF6/cZ1gVCwRl7gccSCLIEUf17SkM1MRykdERU6R93Fkv0Z7LOrU6bn4A== +"@budibase/backend-core@2.2.13": + version "2.2.13" + resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.2.13.tgz#06f606dcf864343375df256f312b097f318dbdfb" + integrity sha512-c0RSE+2xZKgv+o4goUi7tTXivanKvOaD6C/osE93EaRkBQOHDOBTVLvH+0WN8+G1m+8HDBOPSh6v3AUacd3V5g== dependencies: "@budibase/nano" "10.1.1" - "@budibase/types" "^2.2.12" + "@budibase/types" "^2.2.13" "@shopify/jest-koa-mocks" "5.0.1" "@techpass/passport-openidconnect" "0.3.2" aws-sdk "2.1030.0" @@ -1372,13 +1372,13 @@ qs "^6.11.0" tough-cookie "^4.1.2" -"@budibase/pro@2.2.12": - version "2.2.12" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.2.12.tgz#71d664718a8c0a11e1350ae2db91bc82b96850bc" - integrity sha512-weEUNepZSierkBi/EMhKiT52VAsdc2d7GxD1jvAU0NcLDm4C1lfVt8sBSZ7+RmQS4V9n5XMqgORcnV5HmLOUIg== +"@budibase/pro@2.2.13": + version "2.2.13" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.2.13.tgz#fe0f871f2692001b5bb5745fbede2b15a89b5a45" + integrity sha512-Xe0ddefX9Ob8ktgKw46fhGPbgKiDPNmhVVPv/f2fqFNHNg0hwGAcBprrHzBr+576h6pzaY3XU8R7rwWiAikGJQ== dependencies: - "@budibase/backend-core" "2.2.12" - "@budibase/types" "2.2.12" + "@budibase/backend-core" "2.2.13" + "@budibase/types" "2.2.13" "@koa/router" "8.0.8" bull "4.10.1" joi "17.6.0" @@ -1402,10 +1402,10 @@ svelte-apexcharts "^1.0.2" svelte-flatpickr "^3.1.0" -"@budibase/types@2.2.12", "@budibase/types@^2.2.12": - version "2.2.12" - resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.2.12.tgz#a7e8e99bfa3e30f3c416b79636a2e5f4297017d3" - integrity sha512-2Tc74etbXi4bPAyGYdyLCbQzY0y3DhrEe6ZPSGLi2GzI2uePH7qlUKSaS8bz4cxbrXccZoq+DwzAbf9rL9pZww== +"@budibase/types@2.2.13", "@budibase/types@^2.2.13": + version "2.2.13" + resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.2.13.tgz#f91c5e8ccf0e148c4895c411324adc8c3c5257fb" + integrity sha512-erMZP9KAZiYInNLuYoqMaISfBWKDBw0aS5I35xCjZIzaoukE7l6AbBgDbi4foRYe23wdZB7rc/KCOrNnBpLLng== "@bull-board/api@3.7.0": version "3.7.0" diff --git a/packages/worker/package.json b/packages/worker/package.json index a3cc6ab77a..2c6f7d7a69 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -37,7 +37,7 @@ "license": "GPL-3.0", "dependencies": { "@budibase/backend-core": "^2.2.13", - "@budibase/pro": "2.2.12", + "@budibase/pro": "2.2.13", "@budibase/string-templates": "^2.2.13", "@budibase/types": "^2.2.13", "@koa/router": "8.0.8", diff --git a/packages/worker/yarn.lock b/packages/worker/yarn.lock index c452742934..6576de0247 100644 --- a/packages/worker/yarn.lock +++ b/packages/worker/yarn.lock @@ -470,13 +470,13 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@budibase/backend-core@2.2.12": - version "2.2.12" - resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.2.12.tgz#d109a4196e2ca29319649b37b5ba9233e5f3b7ea" - integrity sha512-OgHZhHvpG02CRiJqQfAcXATkNgsi/mF6/cZ1gVCwRl7gccSCLIEUf17SkM1MRykdERU6R93Fkv0Z7LOrU6bn4A== +"@budibase/backend-core@2.2.13": + version "2.2.13" + resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.2.13.tgz#06f606dcf864343375df256f312b097f318dbdfb" + integrity sha512-c0RSE+2xZKgv+o4goUi7tTXivanKvOaD6C/osE93EaRkBQOHDOBTVLvH+0WN8+G1m+8HDBOPSh6v3AUacd3V5g== dependencies: "@budibase/nano" "10.1.1" - "@budibase/types" "^2.2.12" + "@budibase/types" "^2.2.13" "@shopify/jest-koa-mocks" "5.0.1" "@techpass/passport-openidconnect" "0.3.2" aws-sdk "2.1030.0" @@ -519,22 +519,22 @@ qs "^6.11.0" tough-cookie "^4.1.2" -"@budibase/pro@2.2.12": - version "2.2.12" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.2.12.tgz#71d664718a8c0a11e1350ae2db91bc82b96850bc" - integrity sha512-weEUNepZSierkBi/EMhKiT52VAsdc2d7GxD1jvAU0NcLDm4C1lfVt8sBSZ7+RmQS4V9n5XMqgORcnV5HmLOUIg== +"@budibase/pro@2.2.13": + version "2.2.13" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.2.13.tgz#fe0f871f2692001b5bb5745fbede2b15a89b5a45" + integrity sha512-Xe0ddefX9Ob8ktgKw46fhGPbgKiDPNmhVVPv/f2fqFNHNg0hwGAcBprrHzBr+576h6pzaY3XU8R7rwWiAikGJQ== dependencies: - "@budibase/backend-core" "2.2.12" - "@budibase/types" "2.2.12" + "@budibase/backend-core" "2.2.13" + "@budibase/types" "2.2.13" "@koa/router" "8.0.8" bull "4.10.1" joi "17.6.0" node-fetch "^2.6.1" -"@budibase/types@2.2.12", "@budibase/types@^2.2.12": - version "2.2.12" - resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.2.12.tgz#a7e8e99bfa3e30f3c416b79636a2e5f4297017d3" - integrity sha512-2Tc74etbXi4bPAyGYdyLCbQzY0y3DhrEe6ZPSGLi2GzI2uePH7qlUKSaS8bz4cxbrXccZoq+DwzAbf9rL9pZww== +"@budibase/types@2.2.13", "@budibase/types@^2.2.13": + version "2.2.13" + resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.2.13.tgz#f91c5e8ccf0e148c4895c411324adc8c3c5257fb" + integrity sha512-erMZP9KAZiYInNLuYoqMaISfBWKDBw0aS5I35xCjZIzaoukE7l6AbBgDbi4foRYe23wdZB7rc/KCOrNnBpLLng== "@cspotcode/source-map-support@^0.8.0": version "0.8.1" From b06c6852a310234bb81496204291fb742c075718 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 11 Jan 2023 08:01:41 +0000 Subject: [PATCH 04/30] Optimise client library performance with skeleton loaders (#9256) * Treat empty string default values as nullish when considering whether field default values should be applied to the real field value * Add flag to allow not loading data immediately upon creation of a data fetch object * Use loading context inside forms to avoid wasted renders while form schema are loading * Wait for parent data providers to finish loading before loading their own data * Optimise data provider to reduce updates as much as possible * Allow forms to render content immediately again, but use the loading context to inform data providers to wait for them * Remove fetchOnCreation flag for data fetches as now redundant * Fix issue with deleting the selected button action when the next action has no parameters * Lint --- .../ButtonActionDrawer.svelte | 10 ++++ .../client/src/components/Component.svelte | 17 ++++--- .../src/components/app/DataProvider.svelte | 41 +++++++++++---- .../src/components/app/forms/Form.svelte | 15 +++++- .../src/components/app/forms/InnerForm.svelte | 51 +++++++------------ 5 files changed, 82 insertions(+), 52 deletions(-) diff --git a/packages/builder/src/components/design/settings/controls/ButtonActionEditor/ButtonActionDrawer.svelte b/packages/builder/src/components/design/settings/controls/ButtonActionEditor/ButtonActionDrawer.svelte index 1d18fa3a92..b2daf0a2d7 100644 --- a/packages/builder/src/components/design/settings/controls/ButtonActionEditor/ButtonActionDrawer.svelte +++ b/packages/builder/src/components/design/settings/controls/ButtonActionEditor/ButtonActionDrawer.svelte @@ -74,8 +74,18 @@ } const deleteAction = index => { + // Check if we're deleting the selected action + const selectedIndex = actions.indexOf(selectedAction) + const isSelected = index === selectedIndex + + // Delete the action actions.splice(index, 1) actions = actions + + // Select a new action if we deleted the selected one + if (isSelected) { + selectedAction = actions?.length ? actions[0] : null + } } const toggleActionList = () => { diff --git a/packages/client/src/components/Component.svelte b/packages/client/src/components/Component.svelte index aa03b3ce8a..f109449f38 100644 --- a/packages/client/src/components/Component.svelte +++ b/packages/client/src/components/Component.svelte @@ -171,6 +171,15 @@ $: pad = pad || (interactive && hasChildren && inDndPath) $: $dndIsDragging, (pad = false) + // Determine whether we should render a skeleton loader for this component + $: showSkeleton = + $loading && + definition.name !== "Screenslot" && + children.length === 0 && + !instance._blockElementHasChildren && + !definition.block && + definition.skeleton !== false + // Update component context $: store.set({ id, @@ -473,14 +482,6 @@ componentStore.actions.unregisterInstance(id) } }) - - $: showSkeleton = - $loading && - definition.name !== "Screenslot" && - children.length === 0 && - !instance._blockElementHasChildren && - !definition.block && - definition.skeleton !== false {#if showSkeleton} diff --git a/packages/client/src/components/app/DataProvider.svelte b/packages/client/src/components/app/DataProvider.svelte index c28cdef24c..1b4504e689 100644 --- a/packages/client/src/components/app/DataProvider.svelte +++ b/packages/client/src/components/app/DataProvider.svelte @@ -11,20 +11,23 @@ export let limit export let paginate - const loading = writable(false) - const { styleable, Provider, ActionTypes, API } = getContext("sdk") const component = getContext("component") + // Update loading state + const parentLoading = getContext("loading") + const loading = writable(true) + setContext("loading", loading) + // We need to manage our lucene query manually as we want to allow components // to extend it let queryExtensions = {} $: defaultQuery = LuceneUtils.buildLuceneQuery(filter) $: query = extendQuery(defaultQuery, queryExtensions) - // Keep our data fetch instance up to date - $: fetch = createFetch(dataSource) - $: fetch.update({ + // Fetch data and refresh when needed + $: fetch = createFetch(dataSource, $parentLoading) + $: updateFetch({ query, sortColumn, sortOrder, @@ -32,6 +35,9 @@ paginate, }) + // Keep loading context updated + $: loading.set($parentLoading || !$fetch.loaded) + // Build our action context $: actions = [ { @@ -80,14 +86,21 @@ sortColumn: $fetch.sortColumn, sortOrder: $fetch.sortOrder, }, - limit: limit, + limit, } - const parentLoading = getContext("loading") - setContext("loading", loading) - $: loading.set($parentLoading || !$fetch.loaded) + const createFetch = (datasource, parentLoading) => { + // Return a dummy fetch if parent is still loading. We do this so that we + // can still properly subscribe to a valid fetch object and check all + // properties, but we want to avoid fetching the real data until all parents + // have finished loading. + // This logic is only needed due to skeleton loaders, as previously we + // simply blocked component rendering until data was ready. + if (parentLoading) { + return fetchData({ API }) + } - const createFetch = datasource => { + // Otherwise return the real thing return fetchData({ API, datasource, @@ -101,6 +114,14 @@ }) } + const updateFetch = opts => { + // Only update fetch if parents have stopped loading. Otherwise we will + // trigger a fetch of the real data before parents are ready. + if (!$parentLoading) { + fetch.update(opts) + } + } + const addQueryExtension = (key, extension) => { if (!key || !extension) { return diff --git a/packages/client/src/components/app/forms/Form.svelte b/packages/client/src/components/app/forms/Form.svelte index 977b940d1f..f155474d9f 100644 --- a/packages/client/src/components/app/forms/Form.svelte +++ b/packages/client/src/components/app/forms/Form.svelte @@ -1,7 +1,8 @@