diff --git a/packages/shell/esm-app-shell/src/index.ejs b/packages/shell/esm-app-shell/src/index.ejs index f990b8173..a314f45fa 100644 --- a/packages/shell/esm-app-shell/src/index.ejs +++ b/packages/shell/esm-app-shell/src/index.ejs @@ -52,7 +52,9 @@

Application Error

Something went wrong. Please try reloading.

If the problem persists contact your system administrator.

- +
+ +
diff --git a/packages/shell/esm-app-shell/src/run.ts b/packages/shell/esm-app-shell/src/run.ts index 9c064223f..ef4359123 100644 --- a/packages/shell/esm-app-shell/src/run.ts +++ b/packages/shell/esm-app-shell/src/run.ts @@ -117,7 +117,6 @@ function connectivityChanged() { function runShell() { window.addEventListener("offline", connectivityChanged); window.addEventListener("online", connectivityChanged); - return setupI18n() .catch((err) => console.error(`Failed to initialize translations`, err)) .then(() => start()); @@ -125,15 +124,10 @@ function runShell() { function handleInitFailure(e: Error) { console.error(e); - - if (localStorage.getItem("openmrs:devtools")) { - clearDevOverrides(); - } - - renderApology(e.message); + renderFatalErrorPage(e.message); } -function renderApology(message: string) { +function renderFatalErrorPage(message: string) { const template = document.querySelector("#app-error"); if (template) { @@ -145,6 +139,22 @@ function renderApology(message: string) { message || "No additional information available."; } + if ( + localStorage.getItem("openmrs:devtools") && + Object.keys(localStorage).some((k) => + k.startsWith("import-map-override:") + ) + ) { + const appErrorActionButtons = fragment?.querySelector("#buttons"); + if (appErrorActionButtons) { + const clearDevOverridesButton = document.createElement("button"); + clearDevOverridesButton.className = "bx--btn"; + clearDevOverridesButton.innerHTML = "Clear dev overrides"; + clearDevOverridesButton.onclick = clearDevOverrides; + appErrorActionButtons.appendChild(clearDevOverridesButton); + } + } + document.body.appendChild(fragment); } }