mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Show error message when turbo:frame-missing
Instead of replacing frame contents with unhelpful text 'Content missing'.
This commit is contained in:
14
app/webpacker/js/turbo.js
Normal file
14
app/webpacker/js/turbo.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import "@hotwired/turbo";
|
||||
|
||||
document.addEventListener("turbo:frame-missing", (event) => {
|
||||
// don't replace frame contents
|
||||
event.preventDefault();
|
||||
|
||||
// show error message instead
|
||||
status = event.detail.response.status;
|
||||
if(status == 401) {
|
||||
alert(I18n.t("errors.unauthorized.message"));
|
||||
} else {
|
||||
alert(I18n.t("errors.general_error.message"));
|
||||
}
|
||||
});
|
||||
@@ -1,6 +1,6 @@
|
||||
import "controllers";
|
||||
import "channels";
|
||||
import "@hotwired/turbo";
|
||||
import "../js/turbo";
|
||||
import "../js/hotkeys";
|
||||
import "../js/mrujs";
|
||||
import "../js/matomo";
|
||||
@@ -17,3 +17,4 @@ import Trix from "trix";
|
||||
document.addEventListener("trix-file-accept", (event) => {
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import "controllers";
|
||||
import "@hotwired/turbo";
|
||||
import "../js/turbo";
|
||||
import "../js/hotkeys";
|
||||
import "../js/mrujs";
|
||||
import "../js/matomo";
|
||||
|
||||
Reference in New Issue
Block a user