From ccb32af0786299ee483735f86b524dbc42e766ce Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 7 Mar 2024 08:25:11 +0000 Subject: [PATCH] Add deletion confirmation to snippets --- .../common/bindings/SnippetDrawer.svelte | 23 ++++++++++++++----- .../[screenId]/_components/AppPreview.svelte | 2 ++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/packages/builder/src/components/common/bindings/SnippetDrawer.svelte b/packages/builder/src/components/common/bindings/SnippetDrawer.svelte index 9b91b1a47c..e7dd5c7a22 100644 --- a/packages/builder/src/components/common/bindings/SnippetDrawer.svelte +++ b/packages/builder/src/components/common/bindings/SnippetDrawer.svelte @@ -12,6 +12,7 @@ import { decodeJSBinding, encodeJSBinding } from "@budibase/string-templates" import { snippets } from "stores/builder" import { getSequentialName } from "helpers/duplicate" + import ConfirmDialog from "components/common/ConfirmDialog.svelte" export let snippet @@ -25,6 +26,7 @@ let name = "" let code = "" let loading = false + let deleteConfirmationDialog $: defaultName = getSequentialName($snippets, "MySnippet", x => x.name) $: key = snippet?.name @@ -36,12 +38,10 @@ const saveSnippet = async () => { loading = true try { - await snippets.saveSnippet({ - name, - code: rawJS, - }) + const newSnippet = { name, code: rawJS } + await snippets.saveSnippet(newSnippet) drawer.hide() - notifications.success(`Snippet ${name} saved`) + notifications.success(`Snippet ${newSnippet.name} saved`) } catch (error) { notifications.error("Error saving snippet") } @@ -109,7 +109,11 @@ {#if snippet} - {/if} @@ -136,6 +140,13 @@ + +