From 52cd19a04679c91050db0395698c57c988eba74f Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Mon, 30 Mar 2020 21:14:41 +0100 Subject: [PATCH] error recovery notification banner --- packages/builder/src/App.svelte | 16 +++- packages/builder/src/PackageRoot.svelte | 1 + .../builder/src/builderStore/store/index.js | 2 +- .../builder/src/common/AppNotification.svelte | 76 +++++++++++++++++++ 4 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 packages/builder/src/common/AppNotification.svelte diff --git a/packages/builder/src/App.svelte b/packages/builder/src/App.svelte index 69bddc225c..870d057ace 100644 --- a/packages/builder/src/App.svelte +++ b/packages/builder/src/App.svelte @@ -6,12 +6,26 @@ import { onMount } from "svelte" import IconButton from "./common/IconButton.svelte" import Spinner from "./common/Spinner.svelte" + import AppNotification, { showAppNotification } from "./common/AppNotification.svelte" let init = initialise() + + function showErrorBanner() { + showAppNotification({ + status: "danger", + message: + "Whoops! Looks like we're having trouble. Please refresh the page.", + }) + } + + onMount(() => { + window.addEventListener("error", showErrorBanner) + window.addEventListener("unhandledrejection", showErrorBanner) + })
- + {#await init}
diff --git a/packages/builder/src/PackageRoot.svelte b/packages/builder/src/PackageRoot.svelte index f7a134ed9a..1a58aae6df 100644 --- a/packages/builder/src/PackageRoot.svelte +++ b/packages/builder/src/PackageRoot.svelte @@ -5,6 +5,7 @@ import BackendRoot from "./BackendRoot.svelte" import { fade } from "svelte/transition" import { SettingsIcon, PreviewIcon } from "./common/Icons/" + import { showAppNotification } from "./common/AppNotification.svelte" const TABS = { BACKEND: "backend", diff --git a/packages/builder/src/builderStore/store/index.js b/packages/builder/src/builderStore/store/index.js index d7be2fe92a..41230bcaf4 100644 --- a/packages/builder/src/builderStore/store/index.js +++ b/packages/builder/src/builderStore/store/index.js @@ -44,7 +44,7 @@ export const getStore = () => { currentNode: null, libraries: null, showSettings: false, - useAnalytics: true, + useAnalytics: true } const store = writable(initial) diff --git a/packages/builder/src/common/AppNotification.svelte b/packages/builder/src/common/AppNotification.svelte new file mode 100644 index 0000000000..59e6730857 --- /dev/null +++ b/packages/builder/src/common/AppNotification.svelte @@ -0,0 +1,76 @@ + + +