From 447427c5e4055960d7aa1823f7f61067e58f595a Mon Sep 17 00:00:00 2001 From: jeffgreiner-eaton Date: Fri, 17 Nov 2023 14:54:43 -0500 Subject: [PATCH 1/5] Blui 4933 error translations --- .../example/src/actions/AuthUIActions.tsx | 4 ++-- .../src/components/Error/ErrorManager.tsx | 6 ++++-- .../src/components/Error/ErrorMessageBox.tsx | 14 +++++++++++--- .../src/contexts/ErrorContext/useErrorManager.tsx | 1 - 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/login-workflow/example/src/actions/AuthUIActions.tsx b/login-workflow/example/src/actions/AuthUIActions.tsx index bb8d9dcd..5bb1a892 100644 --- a/login-workflow/example/src/actions/AuthUIActions.tsx +++ b/login-workflow/example/src/actions/AuthUIActions.tsx @@ -11,7 +11,7 @@ function getRandomInt(max: number): number { function isRandomFailure(): boolean { const randomResponseNumber = getRandomInt(100); - return false; // randomResponseNumber < 10; + return true; // randomResponseNumber < 10; } type AuthUIActionsWithApp = (appHelper: AppContextType) => AuthUIActions; @@ -90,7 +90,7 @@ export const ProjectAuthUIActions: AuthUIActionsWithApp = (appHelper) => ({ if (isRandomFailure()) { // reject(new Error('LOGIN.GENERIC_ERROR')); - throw new Error('LOGIN.INVALID_CREDENTIALS'); + throw new Error('bluiAuth:LOGIN.INVALID_CREDENTIALS'); } LocalStorage.saveAuthCredentials(email, email); diff --git a/login-workflow/src/components/Error/ErrorManager.tsx b/login-workflow/src/components/Error/ErrorManager.tsx index 1f4f6648..2254de15 100644 --- a/login-workflow/src/components/Error/ErrorManager.tsx +++ b/login-workflow/src/components/Error/ErrorManager.tsx @@ -33,6 +33,7 @@ export type ErrorManagerProps = { dismissLabel?: string; }; messageBoxConfig?: { + title?: string; dismissible?: boolean; position?: 'top' | 'bottom'; fontColor?: string; @@ -79,7 +80,7 @@ const ErrorManager: React.FC = (props): JSX.Element => { 0} title={dialogConfig?.title ?? t('bluiCommon:MESSAGES.ERROR')} - body={error} + body={t(error)} onClose={onClose} dismissButtonText={dialogConfig?.dismissLabel} /> @@ -92,7 +93,8 @@ const ErrorManager: React.FC = (props): JSX.Element => { return ( { - const { errorMessage, backgroundColor, dismissible = true, fontColor, onClose = (): void => {}, sx } = props; + const { title, errorMessage, backgroundColor, dismissible = true, fontColor, onClose = (): void => {}, sx } = props; return ( { }} /> )} - {errorMessage} + + {title} + {errorMessage} + ); }; diff --git a/login-workflow/src/contexts/ErrorContext/useErrorManager.tsx b/login-workflow/src/contexts/ErrorContext/useErrorManager.tsx index 517e285c..23500bff 100644 --- a/login-workflow/src/contexts/ErrorContext/useErrorManager.tsx +++ b/login-workflow/src/contexts/ErrorContext/useErrorManager.tsx @@ -24,7 +24,6 @@ export const useErrorManager = (): { } return { ...errorConfig, - dialogConfig: { title: 'Error' }, error: err.message, onClose: (): void => { setError(new Error()); From 8949e86b90f5bc7c0bc0e5ece0a66fac966fa142 Mon Sep 17 00:00:00 2001 From: jeffgreiner-eaton Date: Fri, 17 Nov 2023 15:16:57 -0500 Subject: [PATCH 2/5] set return to default --- login-workflow/example/src/actions/AuthUIActions.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/login-workflow/example/src/actions/AuthUIActions.tsx b/login-workflow/example/src/actions/AuthUIActions.tsx index 5bb1a892..f55036d9 100644 --- a/login-workflow/example/src/actions/AuthUIActions.tsx +++ b/login-workflow/example/src/actions/AuthUIActions.tsx @@ -11,7 +11,7 @@ function getRandomInt(max: number): number { function isRandomFailure(): boolean { const randomResponseNumber = getRandomInt(100); - return true; // randomResponseNumber < 10; + return false; // randomResponseNumber < 10; } type AuthUIActionsWithApp = (appHelper: AppContextType) => AuthUIActions; From 267d764afa0f2302720e6373d6d47d0260e109db Mon Sep 17 00:00:00 2001 From: jeffgreiner-eaton Date: Fri, 17 Nov 2023 15:32:55 -0500 Subject: [PATCH 3/5] add change log entry --- login-workflow/CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/login-workflow/CHANGELOG.md b/login-workflow/CHANGELOG.md index e94a25ab..0152deef 100644 --- a/login-workflow/CHANGELOG.md +++ b/login-workflow/CHANGELOG.md @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## v4.0.1 (Unreleased) + +### Fixed + +- Translations not working while throwing error from actions ([#513](https://github.com/etn-ccis/blui-react-workflows/issues/513)). +- Error in the dialog / message box does not translate ([#510](https://github.com/etn-ccis/blui-react-workflows/issues/510)). +- Title missing in the messageBoxConfig of ErrorManager ([#507](https://github.com/etn-ccis/blui-react-workflows/issues/507)). + ## v4.0.0 (October 4, 2023) ### Added From 024a57f6e579971c673910be0124aac5f8c51b11 Mon Sep 17 00:00:00 2001 From: JeffGreiner-eaton <119693939+JeffGreiner-eaton@users.noreply.github.com> Date: Mon, 20 Nov 2023 10:54:21 -0500 Subject: [PATCH 4/5] Update login-workflow/src/components/Error/ErrorMessageBox.tsx Co-authored-by: Thomas Dailey --- login-workflow/src/components/Error/ErrorMessageBox.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/login-workflow/src/components/Error/ErrorMessageBox.tsx b/login-workflow/src/components/Error/ErrorMessageBox.tsx index 52f47e4b..6451f1a4 100644 --- a/login-workflow/src/components/Error/ErrorMessageBox.tsx +++ b/login-workflow/src/components/Error/ErrorMessageBox.tsx @@ -45,7 +45,7 @@ export type ErrorMessageBoxProps = { /** * Component that renders a basic message box with an error message and a configurable dismiss button. * - * @param title text to show in the title + * @param text to show as the title * @param errorMessage text to show in the message * @param backgroundColor the background color of the message box * @param dismissible whether the message box can be dismissed From 24ec601c25907989b9cf2c2fd890b0d61f957dd0 Mon Sep 17 00:00:00 2001 From: jeffgreiner-eaton Date: Mon, 20 Nov 2023 11:02:12 -0500 Subject: [PATCH 5/5] update typography to use variant --- login-workflow/src/components/Error/ErrorMessageBox.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/login-workflow/src/components/Error/ErrorMessageBox.tsx b/login-workflow/src/components/Error/ErrorMessageBox.tsx index 6451f1a4..01b51be0 100644 --- a/login-workflow/src/components/Error/ErrorMessageBox.tsx +++ b/login-workflow/src/components/Error/ErrorMessageBox.tsx @@ -88,7 +88,7 @@ const ErrorMessageBox = (props: ErrorMessageBoxProps): JSX.Element => { )} {title} - {errorMessage} + {errorMessage} );