1
0
Fork 0
mirror of synced 2024-09-21 20:01:32 +12:00
budibase/packages/builder/src/components/start/ExportAppModal.svelte

82 lines
2.1 KiB
Svelte
Raw Normal View History

2022-05-25 20:26:10 +12:00
<script>
2023-06-13 22:21:54 +12:00
import {
ModalContent,
Toggle,
Body,
InlineAlert,
Input,
} from "@budibase/bbui"
2022-05-25 20:26:10 +12:00
export let app
export let published
2023-06-13 21:00:01 +12:00
let includeInternalTablesRows = true
let encypt = true
2023-06-13 22:21:54 +12:00
let password
let passwordError
2022-05-25 20:26:10 +12:00
2023-06-13 22:15:32 +12:00
const Step = { CONFIG: "config", SET_PASSWORD: "set_password" }
let currentStep = Step.CONFIG
$: exportButtonText = published ? "Export published" : "Export latest"
$: stepConfig = {
[Step.CONFIG]: {
title: published ? "Export published app" : "Export latest app",
confirmText: encypt ? "Continue" : exportButtonText,
onConfirm: () => {
if (!encypt) {
exportApp()
} else {
currentStep = Step.SET_PASSWORD
return false
}
},
},
[Step.SET_PASSWORD]: {
title: "Add password to encrypt your export",
confirmText: exportButtonText,
onConfirm: () => {
2023-06-13 22:21:54 +12:00
if (!password) {
passwordError = "Password is required"
return false
}
2023-06-13 22:15:32 +12:00
exportApp()
},
},
}
2022-05-25 20:26:10 +12:00
const exportApp = () => {
const id = published ? app.prodId : app.devId
2022-05-25 20:26:10 +12:00
const appName = encodeURIComponent(app.name)
2023-06-13 21:00:01 +12:00
window.location = `/api/backups/export?appId=${id}&appname=${appName}&excludeRows=${!includeInternalTablesRows}`
2022-05-25 20:26:10 +12:00
}
</script>
2023-06-13 22:15:32 +12:00
<ModalContent
title={stepConfig[currentStep].title}
confirmText={stepConfig[currentStep].confirmText}
onConfirm={stepConfig[currentStep].onConfirm}
>
2023-06-13 22:21:54 +12:00
{#if currentStep === Step.CONFIG}
2023-06-13 21:00:01 +12:00
<Body>
<Toggle
text="Export rows from internal tables"
bind:value={includeInternalTablesRows}
/>
<Toggle text="Encrypt my export" bind:value={encypt} />
</Body>
{#if !encypt}
<InlineAlert
header="Do not share your budibase application exports publicly as they may contain sensitive information such as database credentials or secret keys."
2023-06-13 22:21:54 +12:00
/>
{/if}
{/if}
{#if currentStep === Step.SET_PASSWORD}
<Input
label="Password"
placeholder="Type here..."
bind:value={password}
error={passwordError}
2023-06-13 21:00:01 +12:00
/>
{/if}
2022-05-25 20:26:10 +12:00
</ModalContent>