1
0
Fork 0
mirror of synced 2024-10-06 04:54:52 +13:00
budibase/packages/builder/src/components/deploy/RevertModal.svelte
2022-01-21 09:10:59 +00:00

46 lines
1.1 KiB
Svelte

<script>
import {
Icon,
Input,
Modal,
notifications,
ModalContent,
} from "@budibase/bbui"
import { store } from "builderStore"
import { API } from "api"
let revertModal
let appName
$: appId = $store.appId
const revert = async () => {
try {
await API.revertAppChanges(appId)
// Reset frontend state after revert
const applicationPkg = await API.fetchAppPackage(appId)
await store.actions.initialise(applicationPkg)
notifications.info("Changes reverted successfully")
} catch (error) {
notifications.error(`Error reverting changes: ${error}`)
}
}
</script>
<Icon name="Revert" hoverable on:click={revertModal.show} />
<Modal bind:this={revertModal}>
<ModalContent
title="Revert Changes"
confirmText="Revert"
onConfirm={revert}
disabled={appName !== $store.name}
>
<span
>The changes you have made will be deleted and the application reverted
back to its production state.</span
>
<span>Please enter your app name to continue.</span>
<Input bind:value={appName} />
</ModalContent>
</Modal>