diff --git a/packages/builder/src/components/deploy/DeploymentHistory.svelte b/packages/builder/src/components/deploy/DeploymentHistory.svelte
index ed7439eef9..8068215969 100644
--- a/packages/builder/src/components/deploy/DeploymentHistory.svelte
+++ b/packages/builder/src/components/deploy/DeploymentHistory.svelte
@@ -2,7 +2,7 @@
import { onMount, onDestroy } from "svelte"
import Spinner from "components/common/Spinner.svelte"
import { slide } from "svelte/transition"
- import { Heading, Body, Button, Modal } from "@budibase/bbui"
+ import { Heading, Body, Button, Modal, ModalContent } from "@budibase/bbui"
import api from "builderStore/api"
import { notifier } from "builderStore/store/notifications"
import CreateWebhookDeploymentModal from "./CreateWebhookDeploymentModal.svelte"
@@ -31,6 +31,8 @@
export let appId
let modal
+ let errorReasonModal
+ let errorReason
let poll
let deployments = []
let deploymentUrl = `https://${appId}.app.budi.live/${appId}`
@@ -38,10 +40,35 @@
const formatDate = (date, format) =>
Intl.DateTimeFormat("en-GB", DATE_OPTIONS[format]).format(date)
+ // Required to check any updated deployment statuses between polls
+ function checkIncomingDeploymentStatus(current, incoming) {
+ for (let incomingDeployment of incoming) {
+ if (incomingDeployment.status === DeploymentStatus.FAILURE) {
+ const currentDeployment = current.find(
+ deployment => deployment._id === incomingDeployment._id
+ )
+
+ // We have just been notified of an ongoing deployments failure
+ if (
+ !currentDeployment ||
+ currentDeployment.status === DeploymentStatus.PENDING
+ ) {
+ showErrorReasonModal(incomingDeployment.err)
+ }
+ }
+ }
+ }
+
async function fetchDeployments() {
try {
const response = await api.get(`/api/deployments`)
- deployments = await response.json()
+ const json = await response.json()
+
+ if (deployments.length > 0) {
+ checkIncomingDeploymentStatus(deployments, json)
+ }
+
+ deployments = json
} catch (err) {
console.error(err)
clearInterval(poll)
@@ -49,6 +76,11 @@
}
}
+ function showErrorReasonModal(err) {
+ errorReason = err
+ errorReasonModal.show()
+ }
+
onMount(() => {
fetchDeployments()
poll = setInterval(fetchDeployments, POLL_INTERVAL)
@@ -86,11 +118,15 @@