From cba2075431d1de4bf621e1d2b2a2e5f0641997c6 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 8 Feb 2024 11:27:25 +0100 Subject: [PATCH] fix(front): correctly show error message when a tag is too short Closes #1382 Signed-off-by: Thomas Citharel --- src/i18n/en_US.json | 3 ++- src/i18n/fr_FR.json | 3 ++- src/views/Event/EditView.vue | 25 ++++++++++++++++++++++--- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/i18n/en_US.json b/src/i18n/en_US.json index 7d8b1ec49..acb7bda1f 100644 --- a/src/i18n/en_US.json +++ b/src/i18n/en_US.json @@ -1643,5 +1643,6 @@ "Software details: {software_details}": "Software details: {software_details}", "Only instances with an application actor can be followed": "Only instances with an application actor can be followed", "Domain or instance name": "Domain or instance name", - "You need to enter a text": "You need to enter a text" + "You need to enter a text": "You need to enter a text", + "Error while adding tag: {error}": "Error while adding tag: {error}" } \ No newline at end of file diff --git a/src/i18n/fr_FR.json b/src/i18n/fr_FR.json index ced69a4b1..671f55c16 100644 --- a/src/i18n/fr_FR.json +++ b/src/i18n/fr_FR.json @@ -1637,5 +1637,6 @@ "Software details: {software_details}": "Détails du logiciel : {software_details}", "Only instances with an application actor can be followed": "Seules les instances avec un acteur application peuvent être suivies", "Domain or instance name": "Domaine ou nom de l'instance", - "You need to enter a text": "Vous devez entrer un texte" + "You need to enter a text": "Vous devez entrer un texte", + "Error while adding tag: {error}": "Erreur lors de l'ajout d'un tag : {error}" } diff --git a/src/views/Event/EditView.vue b/src/views/Event/EditView.vue index 48c1f87c5..0f1d15eb2 100644 --- a/src/views/Event/EditView.vue +++ b/src/views/Event/EditView.vue @@ -924,9 +924,28 @@ const handleError = (err: any) => { console.error(err); if (err.graphQLErrors !== undefined) { - err.graphQLErrors.forEach(({ message }: { message: string }) => { - notifier?.error(message); - }); + err.graphQLErrors.forEach( + ({ + message, + field, + }: { + message: string | { slug?: string[] }[]; + field: string; + }) => { + if ( + field === "tags" && + Array.isArray(message) && + message.some((msg) => msg.slug) + ) { + const finalMsg = message.find((msg) => msg.slug?.[0]); + notifier?.error( + t("Error while adding tag: {error}", { error: finalMsg?.slug?.[0] }) + ); + } else if (typeof message === "string") { + notifier?.error(message); + } + } + ); } };