From 3d2fafc254eda43ff5a286609056ce19c6b303d0 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 3 Feb 2021 18:00:49 +0100 Subject: [PATCH] Add an error component Shows when a rendering error has been triggered, like the one in 5edc402a011a81ae898795222569f270f93f2a77 Signed-off-by: Thomas Citharel --- js/src/App.vue | 12 +- .../components/About/InstanceContactLink.vue | 52 +++++ js/src/components/Error.vue | 219 ++++++++++++++++++ js/src/graphql/config.ts | 9 + js/src/i18n/en_US.json | 16 +- js/src/i18n/fr_FR.json | 16 +- js/src/router/index.ts | 5 + js/src/views/About/AboutInstance.vue | 50 +--- js/src/views/Event/Event.vue | 1 - 9 files changed, 331 insertions(+), 49 deletions(-) create mode 100644 js/src/components/About/InstanceContactLink.vue create mode 100644 js/src/components/Error.vue diff --git a/js/src/App.vue b/js/src/App.vue index a0b85b0f8..b8c29a98a 100644 --- a/js/src/App.vue +++ b/js/src/App.vue @@ -20,7 +20,9 @@

-
+ + +
@@ -57,6 +59,8 @@ import { ICurrentUser } from "./types/current-user.model"; components: { Logo, NavBar, + error: () => + import(/* webpackChunkName: "editor" */ "./components/Error.vue"), "mobilizon-footer": Footer, }, }) @@ -65,12 +69,18 @@ export default class App extends Vue { currentUser!: ICurrentUser; + error: Error | null = null; + async created(): Promise { if (await this.initializeCurrentUser()) { await initializeCurrentActor(this.$apollo.provider.defaultClient); } } + errorCaptured(error: Error): void { + this.error = error; + } + private async initializeCurrentUser() { const userId = localStorage.getItem(AUTH_USER_ID); const userEmail = localStorage.getItem(AUTH_USER_EMAIL); diff --git a/js/src/components/About/InstanceContactLink.vue b/js/src/components/About/InstanceContactLink.vue new file mode 100644 index 000000000..80d17ecea --- /dev/null +++ b/js/src/components/About/InstanceContactLink.vue @@ -0,0 +1,52 @@ + + diff --git a/js/src/components/Error.vue b/js/src/components/Error.vue new file mode 100644 index 000000000..3a0375860 --- /dev/null +++ b/js/src/components/Error.vue @@ -0,0 +1,219 @@ + + + diff --git a/js/src/graphql/config.ts b/js/src/graphql/config.ts index 3dd903581..6e514ef35 100644 --- a/js/src/graphql/config.ts +++ b/js/src/graphql/config.ts @@ -112,6 +112,15 @@ export const ABOUT = gql` } `; +export const CONTACT = gql` + query Contact { + config { + name + contact + } + } +`; + export const RULES = gql` query Rules { config { diff --git a/js/src/i18n/en_US.json b/js/src/i18n/en_US.json index fe0b9e625..669100da6 100644 --- a/js/src/i18n/en_US.json +++ b/js/src/i18n/en_US.json @@ -836,5 +836,19 @@ "No follower matches the filters": "No follower matches the filters", "@{username}'s follow request was rejected": "@{username}'s follow request was rejected", "Followers will receive new public events and posts.": "Followers will receive new public events and posts.", - "Manually approve new followers": "Manually approve new followers" + "Manually approve new followers": "Manually approve new followers", + "An error has occured. Sorry about that. You may try to reload the page.": "An error has occured. Sorry about that. You may try to reload the page.", + "What can I do to help?": "What can I do to help?", + "We improve this software thanks to your feedback. To let us know about this issue, two possibilities (both unfortunately require user account creation):": "We improve this software thanks to your feedback. To let us know about this issue, two possibilities (both unfortunately require user account creation):'", + "Please add as many details as possible to help identify the problem.": "Please add as many details as possible to help identify the problem.", + "Technical details": "Technical details", + "Error message": "Error message", + "Error stacktrace": "Error stacktrace", + "The technical details of the error can help developers solve the problem more easily. Please add them to your feedback.": "The technical details of the error can help developers solve the problem more easily. Please add them to your feedback.", + "Error details copied!": "Error details copied!", + "Copy details to clipboard": "Copy details to clipboard", + "{instanceName} is an instance of {mobilizon_link}, a free software built with the community.": "{instanceName} is an instance of {mobilizon_link}, a free software built with the community.", + "Open a topic on our forum": "Open a topic on our forum", + "Open an issue on our bug tracker (advanced users)": "Open an issue on our bug tracker (advanced users)", + "Unable to copy to clipboard": "Unable to copy to clipboard" } diff --git a/js/src/i18n/fr_FR.json b/js/src/i18n/fr_FR.json index 4433842b5..30038166f 100644 --- a/js/src/i18n/fr_FR.json +++ b/js/src/i18n/fr_FR.json @@ -931,5 +931,19 @@ "No follower matches the filters": "Aucun⋅e abonné⋅e ne correspond aux filtres", "@{username}'s follow request was rejected": "La demande de suivi de @{username} a été rejettée", "Followers will receive new public events and posts.": "Les abonnée⋅s recevront les nouveaux événements et billets publics.", - "Manually approve new followers": "Approuver les nouvelles demandes de suivi manuellement" + "Manually approve new followers": "Approuver les nouvelles demandes de suivi manuellement", + "An error has occured. Sorry about that. You may try to reload the page.": "Une erreur est survenue. Nous en sommes désolé⋅es. Vous pouvez essayer de rafraîchir la page.", + "What can I do to help?": "Que puis-je faire pour aider ?", + "We improve this software thanks to your feedback. To let us know about this issue, two possibilities (both unfortunately require user account creation):": "Nous améliorons ce logiciel grâce à vos retours. Pour nous avertir de ce problème, vous avez deux possibilités (les deux requièrent toutefois la création d'un compte) :", + "Please add as many details as possible to help identify the problem.": "Merci d'ajouter un maximum de détails afin d'aider à identifier le problème.", + "Technical details": "Détails techniques", + "Error message": "Message d'erreur", + "Error stacktrace": "Trace d'appels de l'erreur", + "The technical details of the error can help developers solve the problem more easily. Please add them to your feedback.": "Les détails techniques de l'erreur peuvent aider les développeur⋅ices à résoudre le problème plus facilement. Merci de les inclure dans vos retours.", + "Error details copied!": "Détails de l'erreur copiés !", + "Copy details to clipboard": "Copier les détails dans le presse-papiers", + "{instanceName} is an instance of {mobilizon_link}, a free software built with the community.": "{instanceName} est une instance de {mobilizon_link}, un logiciel libre construit de manière communautaire.", + "Open a topic on our forum": "Ouvrir un sujet sur notre forum", + "Open an issue on our bug tracker (advanced users)": "Ouvrir un ticket sur notre système de suivi des bugs (utilisateur⋅ices avancé⋅es)", + "Unable to copy to clipboard": "Impossible de copier dans le presse-papiers" } diff --git a/js/src/router/index.ts b/js/src/router/index.ts index e6313a39f..0a8b0534d 100644 --- a/js/src/router/index.ts +++ b/js/src/router/index.ts @@ -157,5 +157,10 @@ const router = new Router({ }); router.beforeEach(authGuardIfNeeded); +router.afterEach(() => { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + router.app.$children[0].error = null; +}); export default router; diff --git a/js/src/views/About/AboutInstance.vue b/js/src/views/About/AboutInstance.vue index 86b75262f..9aa1d9d26 100644 --- a/js/src/views/About/AboutInstance.vue +++ b/js/src/views/About/AboutInstance.vue @@ -25,16 +25,7 @@

{{ $t("Contact") }}

-

- {{ generateConfigLink().text }} - {{ config.contact }} - {{ $t("contact uninformed") }} -

+

@@ -85,6 +76,7 @@ diff --git a/js/src/views/Event/Event.vue b/js/src/views/Event/Event.vue index b8d688e78..4ac324b64 100755 --- a/js/src/views/Event/Event.vue +++ b/js/src/views/Event/Event.vue @@ -1,6 +1,5 @@