Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update release derms auth branch with dev #518

Merged
merged 13 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions login-workflow/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ 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)).
- Added loader to the login action ([#511](https://github.com/etn-ccis/blui-react-workflows/issues/511)).

## v4.0.0 (October 4, 2023)

### Added
Expand Down
2 changes: 1 addition & 1 deletion login-workflow/example/src/actions/AuthUIActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion login-workflow/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@brightlayer-ui/react-auth-workflow",
"version": "4.0.0",
"version": "4.0.1",
"author": "Brightlayer UI <[email protected]> (https://github.com/brightlayer-ui)",
"license": "BSD-3-Clause",
"description": "Re-usable workflow components for Authentication and Registration within Eaton applications.",
Expand Down
6 changes: 4 additions & 2 deletions login-workflow/src/components/Error/ErrorManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type ErrorManagerProps = {
dismissLabel?: string;
};
messageBoxConfig?: {
title?: string;
dismissible?: boolean;
position?: 'top' | 'bottom';
fontColor?: string;
Expand Down Expand Up @@ -79,7 +80,7 @@ const ErrorManager: React.FC<ErrorManagerProps> = (props): JSX.Element => {
<BasicDialog
open={error.length > 0}
title={dialogConfig?.title ?? t('bluiCommon:MESSAGES.ERROR')}
body={error}
body={t(error)}
onClose={onClose}
dismissButtonText={dialogConfig?.dismissLabel}
/>
Expand All @@ -92,7 +93,8 @@ const ErrorManager: React.FC<ErrorManagerProps> = (props): JSX.Element => {

return (
<ErrorMessageBox
errorMessage={error}
title={dialogConfig?.title ?? t('bluiCommon:MESSAGES.ERROR')}
errorMessage={t(error)}
dismissible={dismissible}
sx={sx}
backgroundColor={backgroundColor}
Expand Down
14 changes: 11 additions & 3 deletions login-workflow/src/components/Error/ErrorMessageBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export type ErrorMessageBoxProps = {
/**
* The text to show in the title
*/
title: string;
/**
* The text to show in the message
*/
errorMessage: string;

/**
Expand Down Expand Up @@ -41,7 +45,8 @@ export type ErrorMessageBoxProps = {
/**
* Component that renders a basic message box with an error message and a configurable dismiss button.
*
* @param errorMessage 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
* @param fontColor the font color of the text inside the message box
Expand All @@ -51,7 +56,7 @@ export type ErrorMessageBoxProps = {
* @category Component
*/
const ErrorMessageBox = (props: ErrorMessageBoxProps): JSX.Element => {
const { errorMessage, backgroundColor, dismissible = true, fontColor, onClose = (): void => {}, sx } = props;
const { title, errorMessage, backgroundColor, dismissible = true, fontColor, onClose = (): void => {}, sx } = props;

return (
<Box
Expand Down Expand Up @@ -81,7 +86,10 @@ const ErrorMessageBox = (props: ErrorMessageBoxProps): JSX.Element => {
}}
/>
)}
<Typography variant="body2">{errorMessage}</Typography>
<Box>
<Typography>{title}</Typography>
<Typography variant="body2">{errorMessage}</Typography>
</Box>
</Box>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export const useErrorManager = (): {
}
return {
...errorConfig,
dialogConfig: { title: 'Error' },
error: err.message,
onClose: (): void => {
setError(new Error());
Expand Down
7 changes: 6 additions & 1 deletion login-workflow/src/screens/LoginScreen/LoginScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect } from 'react';
import React, { useEffect, useState } from 'react';
import { LoginScreenProps } from './types';
import { LoginScreenBase } from './LoginScreenBase';
import { useAuthContext } from '../../contexts';
Expand Down Expand Up @@ -48,6 +48,7 @@ export const LoginScreen: React.FC<React.PropsWithChildren<LoginScreenProps>> =
const auth = useAuthContext();
const { actions, navigate, routeConfig, rememberMeDetails } = auth;
const { triggerError, errorManagerConfig } = useErrorManager();
const [isLoading, setIsLoading] = useState(false);
const errorDisplayConfig = {
...errorManagerConfig,
...props.errorDisplayConfig,
Expand Down Expand Up @@ -105,6 +106,7 @@ export const LoginScreen: React.FC<React.PropsWithChildren<LoginScreenProps>> =

return (
<LoginScreenBase
loading={isLoading}
usernameLabel={usernameLabel}
usernameTextFieldProps={usernameTextFieldProps}
usernameValidator={usernameValidator}
Expand All @@ -120,10 +122,13 @@ export const LoginScreen: React.FC<React.PropsWithChildren<LoginScreenProps>> =
onLogin={
(async (username: string, password: string, rememberMe: boolean): Promise<void> => {
try {
setIsLoading(true);
await actions.logIn(username, password, rememberMe);
await props.onLogin?.(username, password, rememberMe);
} catch (_error) {
triggerError(_error as Error);
} finally {
setIsLoading(false);
}
}) as any
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export const LoginScreenBase: React.FC<React.PropsWithChildren<LoginScreenProps>
projectImage,
header,
footer,
...otherProps
} = props;

const theme = useTheme();
Expand Down Expand Up @@ -189,7 +190,7 @@ export const LoginScreenBase: React.FC<React.PropsWithChildren<LoginScreenProps>
};

return (
<WorkflowCard className={defaultClasses.root} data-testid={defaultClasses.root}>
<WorkflowCard className={defaultClasses.root} data-testid={defaultClasses.root} {...otherProps}>
<WorkflowCardBody sx={{ py: { xs: 4, sm: 4, md: 4 }, px: { xs: 4, sm: 8, md: 8 } }}>
{header}
<Box
Expand Down
Loading