diff --git a/packages/builder/src/components/start/ExportAppModal.svelte b/packages/builder/src/components/start/ExportAppModal.svelte index 6a761f9043..8b65f5ea2f 100644 --- a/packages/builder/src/components/start/ExportAppModal.svelte +++ b/packages/builder/src/components/start/ExportAppModal.svelte @@ -6,16 +6,28 @@ InlineAlert, Input, } from "@budibase/bbui" + import { createValidationStore } from "helpers/validation/yup" export let app export let published let includeInternalTablesRows = true let encypt = true + let password - let passwordError + const validation = createValidationStore() + validation.addValidatorType("password", "password", "true") + + function validate() { + return validation.check({ password }) + } + $: { + if ($validation.errors.length) { + validate() + } + } const Step = { CONFIG: "config", SET_PASSWORD: "set_password" } - let currentStep = Step.CONFIG + let currentStep = Step.SET_PASSWORD $: exportButtonText = published ? "Export published" : "Export latest" $: stepConfig = { @@ -34,9 +46,9 @@ [Step.SET_PASSWORD]: { title: "Add password to encrypt your export", confirmText: exportButtonText, - onConfirm: () => { - if (!password) { - passwordError = "Password is required" + onConfirm: async () => { + await validate() + if (!$validation.valid) { return false } exportApp() @@ -57,25 +69,26 @@ onConfirm={stepConfig[currentStep].onConfirm} > {#if currentStep === Step.CONFIG} - - - - - {#if !encypt} - + + + + {#if !encypt} + {/if} {/if} {#if currentStep === Step.SET_PASSWORD} {/if}