budibase/packages/builder/src/components/deploy/DeployModal.svelte

49 lines
1.3 KiB
Svelte
Raw Normal View History

2021-05-16 22:25:37 +02:00
<script>
import { Button, Modal, notifications, ModalContent } from "@budibase/bbui"
import api from "builderStore/api"
2021-09-21 12:47:14 +02:00
import analytics, { Events } from "analytics"
import { store } from "builderStore"
2021-05-16 22:25:37 +02:00
let feedbackModal
let publishModal
async function deployApp() {
try {
const response = await api.post("/api/deploy")
if (response.status !== 200) {
throw new Error(`status ${response.status}`)
} else {
2021-09-21 12:47:14 +02:00
analytics.captureEvent(Events.APP.PUBLISHED, {
appId: $store.appId,
2021-09-21 12:47:14 +02:00
})
notifications.success(`Application published successfully`)
2021-05-16 22:25:37 +02:00
}
} catch (err) {
analytics.captureException(err)
notifications.error(`Error publishing app: ${err}`)
2021-05-16 22:25:37 +02:00
}
}
</script>
2021-05-17 22:43:50 +02:00
<Button secondary on:click={publishModal.show}>Publish</Button>
<Modal bind:this={feedbackModal}>
<ModalContent
title="Enjoying Budibase?"
size="L"
showConfirmButton={false}
showCancelButton={false}
2021-07-21 12:28:38 +02:00
/>
</Modal>
2021-05-16 22:25:37 +02:00
<Modal bind:this={publishModal}>
2021-05-17 22:43:50 +02:00
<ModalContent
title="Publish to Production"
confirmText="Publish"
onConfirm={deployApp}
>
<span
>The changes you have made will be published to the production version of
the application.</span
>
</ModalContent>
2021-05-16 22:25:37 +02:00
</Modal>