1
0
Fork 0
mirror of https://framagit.org/framasoft/mobilizon.git synced 2024-12-22 07:52:43 +00:00

fix(front): correctly show error message when a tag is too short

Closes #1382

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2024-02-08 11:27:25 +01:00
parent 6a482b0d97
commit cba2075431
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773
3 changed files with 26 additions and 5 deletions

View file

@ -1643,5 +1643,6 @@
"Software details: {software_details}": "Software details: {software_details}", "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", "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", "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}"
} }

View file

@ -1637,5 +1637,6 @@
"Software details: {software_details}": "Détails du logiciel : {software_details}", "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", "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", "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}"
} }

View file

@ -924,9 +924,28 @@ const handleError = (err: any) => {
console.error(err); console.error(err);
if (err.graphQLErrors !== undefined) { if (err.graphQLErrors !== undefined) {
err.graphQLErrors.forEach(({ message }: { message: string }) => { err.graphQLErrors.forEach(
notifier?.error(message); ({
}); 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);
}
}
);
} }
}; };