diff --git a/packages/bbui/src/Form/Core/TextField.svelte b/packages/bbui/src/Form/Core/TextField.svelte index 37989a291e..85c71338f7 100644 --- a/packages/bbui/src/Form/Core/TextField.svelte +++ b/packages/bbui/src/Form/Core/TextField.svelte @@ -11,6 +11,7 @@ export let readonly = false export let updateOnChange = true export let quiet = false + export let dataCy const dispatch = createEventDispatcher() let focus = false @@ -78,6 +79,7 @@ {disabled} {readonly} {id} + data-cy={dataCy} value={value || ""} placeholder={placeholder || ""} on:click diff --git a/packages/bbui/src/Form/Input.svelte b/packages/bbui/src/Form/Input.svelte index d1dbaff50b..1660b67799 100644 --- a/packages/bbui/src/Form/Input.svelte +++ b/packages/bbui/src/Form/Input.svelte @@ -13,6 +13,7 @@ export let error = null export let updateOnChange = true export let quiet = false + export let dataCy const dispatch = createEventDispatcher() const onChange = e => { @@ -23,6 +24,7 @@ { cy.get(".spectrum-Table-editIcon > use").click() cy.contains("Delete").click() cy.wait(50) + cy.get(`[data-cy="delete-column-confirm"]`).type("nameupdated") cy.contains("Delete Column").click() cy.contains("nameupdated").should("not.exist") }) @@ -66,6 +67,7 @@ context("Create a Table", () => { cy.get(".actions .spectrum-Icon").click({ force: true }) }) cy.get(".spectrum-Menu > :nth-child(2)").click() + cy.get(`[data-cy="delete-table-confirm"]`).type("dog") cy.contains("Delete Table").click() cy.contains("dog").should("not.exist") }) diff --git a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte index 83ed741b75..841e781cf2 100644 --- a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte @@ -62,6 +62,7 @@ let indexes = [...($tables.selected.indexes || [])] let confirmDeleteDialog let deletion + let deleteColName $: checkConstraints(field) $: required = !!field?.constraints?.presence || primaryDisplay @@ -179,6 +180,7 @@ function hideDeleteDialog() { confirmDeleteDialog.hide() + deleteColName = "" deletion = false } @@ -408,9 +410,20 @@ + disabled={deleteColName !== field.name} +> +

+ Are you sure you wish to delete the column {field.name}? + Your data will be deleted and this action cannot be undone - enter the column + name to confirm. +

+ +
diff --git a/packages/builder/src/components/backend/TableNavigator/popovers/EditTablePopover.svelte b/packages/builder/src/components/backend/TableNavigator/popovers/EditTablePopover.svelte index 04094b881a..6d8c5811ec 100644 --- a/packages/builder/src/components/backend/TableNavigator/popovers/EditTablePopover.svelte +++ b/packages/builder/src/components/backend/TableNavigator/popovers/EditTablePopover.svelte @@ -21,8 +21,10 @@ let originalName = table.name let templateScreens let willBeDeleted + let deleteTableName $: external = table?.type === "external" + $: allowDeletion = !external || table?.created function showDeleteModal() { templateScreens = $allScreens.filter( @@ -36,18 +38,26 @@ async function deleteTable() { const wasSelectedTable = $tables.selected - await tables.delete(table) - store.actions.screens.delete(templateScreens) - await tables.fetch() - notifications.success("Table deleted") - if (table.type === "external") { - await datasources.fetch() - } - if (wasSelectedTable && wasSelectedTable._id === table._id) { - $goto("./table") + try { + await tables.delete(table) + await store.actions.screens.delete(templateScreens) + await tables.fetch() + if (table.type === "external") { + await datasources.fetch() + } + notifications.success("Table deleted") + if (wasSelectedTable && wasSelectedTable._id === table._id) { + $goto("./table") + } + } catch (err) { + notifications.error(err) } } + function hideDeleteDialog() { + deleteTableName = "" + } + async function save() { await tables.save(table) notifications.success("Table renamed successfully") @@ -67,7 +77,9 @@ Edit - Delete + {#if allowDeletion} + Delete + {/if} @@ -90,11 +102,15 @@ bind:this={confirmDeleteDialog} okText="Delete Table" onOk={deleteTable} + onCancel={hideDeleteDialog} title="Confirm Deletion" + disabled={deleteTableName !== table.name} > - Are you sure you wish to delete the table - {table.name}? - The following will also be deleted: +

+ Are you sure you wish to delete the table + {table.name}? + The following will also be deleted: +

{#each willBeDeleted as item} @@ -102,7 +118,15 @@ {/each}
- This action cannot be undone. +

+ This action cannot be undone - to continue please enter the table name below + to confirm. +

+