From 2ed398f30f24c2c47a5c564fb7c8d2bf588bf046 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C5=BEe=20Fortun?= Date: Thu, 22 Dec 2022 15:11:35 +0100 Subject: [PATCH] Fix toast errors not displaying full message if it contained : --- client/web/admin/src/mixins/toast.js | 7 ++++++- client/web/discovery/src/mixins/toast.js | 7 ++++++- client/web/reporter/src/mixins/toast.js | 7 ++++++- client/web/workflow/src/mixins/toast.js | 7 ++++++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/client/web/admin/src/mixins/toast.js b/client/web/admin/src/mixins/toast.js index e8c09cc5d..0ac0bda6d 100644 --- a/client/web/admin/src/mixins/toast.js +++ b/client/web/admin/src/mixins/toast.js @@ -36,7 +36,12 @@ export default { const { prefix, title } = opt return (err = {}) => { - const msg = err.message ? (prefix + ': ' + err.message) : prefix + // only messages starting with 'notification:' or 'notification.' should be translated + if (err.message && err.message.startsWith('notification')) { + err.message = this.$t(`notification:${err.message.substring('notification.'.length)}`) + } + // all other messages should be shown as they are + const msg = err.message ? `${prefix}: ${err.message}` : prefix this.toastDanger(msg, title) } }, diff --git a/client/web/discovery/src/mixins/toast.js b/client/web/discovery/src/mixins/toast.js index 362f81fd9..e29feb615 100644 --- a/client/web/discovery/src/mixins/toast.js +++ b/client/web/discovery/src/mixins/toast.js @@ -36,7 +36,12 @@ export default { const { prefix, title } = opt return (err = {}) => { - const msg = err.message ? (prefix + ': ' + this.$t(err.message)) : prefix + // only messages starting with 'notification:' or 'notification.' should be translated + if (err.message && err.message.startsWith('notification')) { + err.message = this.$t(`notification:${err.message.substring('notification.'.length)}`) + } + // all other messages should be shown as they are + const msg = err.message ? `${prefix}: ${err.message}` : prefix this.toastDanger(msg, title) } }, diff --git a/client/web/reporter/src/mixins/toast.js b/client/web/reporter/src/mixins/toast.js index 362f81fd9..e29feb615 100644 --- a/client/web/reporter/src/mixins/toast.js +++ b/client/web/reporter/src/mixins/toast.js @@ -36,7 +36,12 @@ export default { const { prefix, title } = opt return (err = {}) => { - const msg = err.message ? (prefix + ': ' + this.$t(err.message)) : prefix + // only messages starting with 'notification:' or 'notification.' should be translated + if (err.message && err.message.startsWith('notification')) { + err.message = this.$t(`notification:${err.message.substring('notification.'.length)}`) + } + // all other messages should be shown as they are + const msg = err.message ? `${prefix}: ${err.message}` : prefix this.toastDanger(msg, title) } }, diff --git a/client/web/workflow/src/mixins/toast.js b/client/web/workflow/src/mixins/toast.js index adc407603..7f5304cd3 100644 --- a/client/web/workflow/src/mixins/toast.js +++ b/client/web/workflow/src/mixins/toast.js @@ -28,7 +28,12 @@ export default { const { prefix, title } = opt return (err = {}) => { - const msg = err.message ? (prefix + ': ' + err.message) : prefix + // only messages starting with 'notification:' or 'notification.' should be translated + if (err.message && err.message.startsWith('notification')) { + err.message = this.$t(`notification:${err.message.substring('notification.'.length)}`) + } + // all other messages should be shown as they are + const msg = err.message ? `${prefix}: ${err.message}` : prefix this.toastDanger(msg, title) } },