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..86ad625c2c 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 @@ -408,9 +409,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..0c0f8efe4f 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,15 +38,19 @@ 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) } } @@ -67,7 +73,9 @@ Edit - Delete + {#if allowDeletion} + Delete + {/if} @@ -91,10 +99,13 @@ okText="Delete Table" onOk={deleteTable} 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 +113,15 @@ {/each}
- This action cannot be undone. +

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

+