From c5dc50e8bf2e047c4baf177e7742e4524cde9495 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 16 Oct 2020 13:48:59 +0100 Subject: [PATCH 1/3] Fixing some issues found with deleting tables and relationships not getting cleaned up fully + builder not updating - also making sure builder store initial state of screens is accurate. --- packages/builder/src/builderStore/store/index.js | 5 ++++- .../TableNavigator/popovers/EditTablePopover.svelte | 1 + packages/server/src/db/linkedRows/LinkController.js | 13 +++++++++---- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/builder/src/builderStore/store/index.js b/packages/builder/src/builderStore/store/index.js index 277f57584e..e6a42ee91c 100644 --- a/packages/builder/src/builderStore/store/index.js +++ b/packages/builder/src/builderStore/store/index.js @@ -129,7 +129,10 @@ const setPackage = (store, initial) => async pkg => { initial.appId = pkg.application._id initial.pages = pkg.pages initial.hasAppPackage = true - initial.screens = values(pkg.screens) + initial.screens = [ + ...Object.values(main_screens), + ...Object.values(unauth_screens), + ] initial.builtins = [getBuiltin("##builtin/screenslot")] initial.appInstances = pkg.application.instances initial.appId = pkg.application._id diff --git a/packages/builder/src/components/backend/TableNavigator/popovers/EditTablePopover.svelte b/packages/builder/src/components/backend/TableNavigator/popovers/EditTablePopover.svelte index 2b74e9c288..25f74671fd 100644 --- a/packages/builder/src/components/backend/TableNavigator/popovers/EditTablePopover.svelte +++ b/packages/builder/src/components/backend/TableNavigator/popovers/EditTablePopover.svelte @@ -42,6 +42,7 @@ async function deleteTable() { await backendUiStore.actions.tables.delete(table) store.deleteScreens(templateScreens) + await backendUiStore.actions.tables.fetch() notifier.success("Table deleted") hideEditor() } diff --git a/packages/server/src/db/linkedRows/LinkController.js b/packages/server/src/db/linkedRows/LinkController.js index 06e4aab1f2..5eed0bb4a8 100644 --- a/packages/server/src/db/linkedRows/LinkController.js +++ b/packages/server/src/db/linkedRows/LinkController.js @@ -1,6 +1,7 @@ const CouchDB = require("../index") const { IncludeDocs, getLinkDocuments } = require("./linkUtils") const { generateLinkID } = require("../utils") +const Sentry = require("@sentry/node") /** * Creates a new link document structure which can be put to the database. It is important to @@ -289,10 +290,14 @@ class LinkController { const schema = table.schema for (let fieldName of Object.keys(schema)) { const field = schema[fieldName] - if (field.type === "link") { - const linkedTable = await this._db.get(field.tableId) - delete linkedTable.schema[table.name] - await this._db.put(linkedTable) + try { + if (field.type === "link") { + const linkedTable = await this._db.get(field.tableId) + delete linkedTable.schema[field.fieldName] + await this._db.put(linkedTable) + } + } catch (err) { + Sentry.captureException(err) } } // need to get the full link docs to delete them From 691ce5420f295aad67543f94c0fddd2f8d0c6f82 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 16 Oct 2020 13:50:18 +0100 Subject: [PATCH 2/3] Linting. --- packages/standard-components/src/DataGrid/Component.svelte | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/standard-components/src/DataGrid/Component.svelte b/packages/standard-components/src/DataGrid/Component.svelte index 21d5d86c97..781ed6ccbf 100644 --- a/packages/standard-components/src/DataGrid/Component.svelte +++ b/packages/standard-components/src/DataGrid/Component.svelte @@ -11,7 +11,12 @@ import { onMount } from "svelte" import AgGrid from "@budibase/svelte-ag-grid" - import { TextButton as DeleteButton, Icon, Modal, ModalContent } from "@budibase/bbui" + import { + TextButton as DeleteButton, + Icon, + Modal, + ModalContent, + } from "@budibase/bbui" export let _bb export let datasource = {} From 826aa4514df8d969e8156710e8e8e1c75b4e96cf Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 16 Oct 2020 14:00:08 +0100 Subject: [PATCH 3/3] Fixing linting issue. --- packages/builder/src/builderStore/store/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/builder/src/builderStore/store/index.js b/packages/builder/src/builderStore/store/index.js index e6a42ee91c..311d7a63a3 100644 --- a/packages/builder/src/builderStore/store/index.js +++ b/packages/builder/src/builderStore/store/index.js @@ -1,4 +1,4 @@ -import { values, cloneDeep } from "lodash/fp" +import { cloneDeep } from "lodash/fp" import getNewComponentName from "../getNewComponentName" import { backendUiStore } from "builderStore" import { writable, get } from "svelte/store"