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 @@ + +