Skip to content

Commit

Permalink
Merge pull request #553 from etn-ccis/dev
Browse files Browse the repository at this point in the history
Publish v7.0.1
  • Loading branch information
surajeaton authored Dec 30, 2024
2 parents 02cd896 + c6918a0 commit 32d8f26
Show file tree
Hide file tree
Showing 25 changed files with 1,996 additions and 3,159 deletions.
2 changes: 1 addition & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @JeffGreiner-eaton @daileytj @surajeaton @joebochill
* @JeffGreiner-eaton @surajeaton @joebochill @ektaghag-eaton
7 changes: 7 additions & 0 deletions login-workflow/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ 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).

## v7.0.1 (December 27, 2024)

### Fixed

- Android - Registration workflow not loading [546](https://github.com/etn-ccis/blui-react-native-workflows/issues/546).
- Pressing login does not dismiss keyboard and can obscure error modal [514](https://github.com/etn-ccis/blui-react-native-workflows/issues/514).

## v7.0.0 (September 20, 2024)

### Fixed
Expand Down
5 changes: 2 additions & 3 deletions login-workflow/example/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,13 @@ export const App = (): JSX.Element => {
getAccessToken() // eslint-disable-next-line
.then((res) => console.log(res.access_token)) // eslint-disable-next-line
.catch((err) => console.log(err));
} catch (error) { // eslint-disable-next-line
} catch (error) {
// eslint-disable-next-line
console.error('Okta error for access token', error);
}
};

useEffect(() => {


EventEmitter.addListener('signInSuccess', handleSignInSuccess);

return () => {
Expand Down
6 changes: 3 additions & 3 deletions login-workflow/example/okta.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export default {
oidc: {
oidc: {
clientId: process.env.OKTA_CLIENT_ID,
redirectUri: process.env.OKTA_REDIRECT_URI,
endSessionRedirectUri: process.env.OKTA_LOGOUT_REDIRECT_URI,
discoveryUri: process.env.OKTA_ISSUER,
scopes: ['openid', 'profile', 'offline_access', 'groups'],
requireHardwareBackedKeyStore: false,
}
};
},
};
2 changes: 1 addition & 1 deletion login-workflow/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@react-native-community/masked-view": "^0.1.10",
"@react-navigation/drawer": "^6.6.6",
"@react-navigation/native": "^6.1.9",
"@react-navigation/native-stack": "^6.9.26",
"@react-navigation/native-stack": "^6.11.0",
"@react-navigation/stack": "^6.3.20",
"date-fns": "^3.6.0",
"i18next": "^23.15.1",
Expand Down
8 changes: 4 additions & 4 deletions login-workflow/example/src/components/UserMenuComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ export const UserMenuComponent: React.FC<UserMenuExampleProps> = (props) => {
const logout = async (): Promise<void> => {
LocalStorage.clearAuthCredentials();
try {
await signOut();
await revokeAccessToken();
await clearTokens();
await signOut();
await revokeAccessToken();
await clearTokens();
} catch (_error) {
// eslint-disable-next-line no-console
console.log(_error as Error);
}
}
app.onUserNotAuthenticated();
};
const handleLogout = (): void => {
Expand Down
8 changes: 4 additions & 4 deletions login-workflow/example/src/screens/ChangePassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ export const ChangePassword = (): JSX.Element => {
try {
await revokeAccessToken();
await clearTokens();
} catch (_error) {
// eslint-disable-next-line no-console
console.log(_error as Error);
}
} catch (_error) {
// eslint-disable-next-line no-console
console.log(_error as Error);
}
app.onUserNotAuthenticated();
// below line is not need for okta workflow
// app.setLoginData({ email: '', rememberMe: false });
Expand Down
78 changes: 41 additions & 37 deletions login-workflow/example/src/screens/OktaLogin.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import React from 'react';
import { Image } from 'react-native';
import { OktaAuthContextProvider, OktaLoginScreenProps, OktaRedirectLoginScreen } from '@brightlayer-ui/react-native-auth-workflow';
import {
OktaAuthContextProvider,
OktaLoginScreenProps,
OktaRedirectLoginScreen,
} from '@brightlayer-ui/react-native-auth-workflow';
import { useApp } from '../contexts/AppContextProvider';
import { useNavigation } from '@react-navigation/native';
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
Expand All @@ -13,43 +17,43 @@ export const OktaLogin: React.FC<React.PropsWithChildren<OktaLoginScreenProps>>

return (
<OktaAuthContextProvider
language={app.language}
i18n={i18nAppInstance}
navigate={(destination: -1 | string) => {
if (typeof destination === 'string') {
switch (destination) {
case 'SelfRegister':
case 'RegisterInvite':
navigation.navigate('RegistrationProviderExample', { screen: destination });
break;
default:
navigation.navigate(destination);
break;
}
} else if (destination === -1) {
navigation.goBack();
language={app.language}
i18n={i18nAppInstance}
navigate={(destination: -1 | string) => {
if (typeof destination === 'string') {
switch (destination) {
case 'SelfRegister':
case 'RegisterInvite':
navigation.navigate('RegistrationProviderExample', { screen: destination });
break;
default:
navigation.navigate(destination);
break;
}
}}
routeConfig={{
LOGIN: 'Login',
FORGOT_PASSWORD: 'ForgotPassword',
RESET_PASSWORD: 'ResetPassword',
REGISTER_INVITE: 'RegisterInvite',
REGISTER_SELF: 'SelfRegister',
SUPPORT: 'ContactSupport',
}}
>
<OktaRedirectLoginScreen
projectImage={
<Image
style={{ width: '100%' }}
resizeMode="contain"
source={require('../assets/images/eaton_stacked_logo.png')}
/>
}
// eslint-disable-next-line
oktaConfigObject={oktaConfig.oidc}
} else if (destination === -1) {
navigation.goBack();
}
}}
routeConfig={{
LOGIN: 'Login',
FORGOT_PASSWORD: 'ForgotPassword',
RESET_PASSWORD: 'ResetPassword',
REGISTER_INVITE: 'RegisterInvite',
REGISTER_SELF: 'SelfRegister',
SUPPORT: 'ContactSupport',
}}
>
<OktaRedirectLoginScreen
projectImage={
<Image
style={{ width: '100%' }}
resizeMode="contain"
source={require('../assets/images/eaton_stacked_logo.png')}
/>
}
// eslint-disable-next-line
oktaConfigObject={oktaConfig.oidc}
/>
</OktaAuthContextProvider>
</OktaAuthContextProvider>
);
};
39 changes: 17 additions & 22 deletions login-workflow/example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3418,22 +3418,17 @@
color "^4.2.3"
warn-once "^0.1.0"

"@react-navigation/elements@^1.3.21":
version "1.3.21"
resolved "https://registry.yarnpkg.com/@react-navigation/elements/-/elements-1.3.21.tgz#debac6becc6b6692da09ec30e705e476a780dfe1"
integrity sha512-eyS2C6McNR8ihUoYfc166O1D8VYVh9KIl0UQPI8/ZJVsStlfSTgeEEh+WXge6+7SFPnZ4ewzEJdSAHH+jzcEfg==

"@react-navigation/elements@^1.3.30":
version "1.3.30"
resolved "https://registry.yarnpkg.com/@react-navigation/elements/-/elements-1.3.30.tgz#a81371f599af1070b12014f05d6c09b1a611fd9a"
integrity sha512-plhc8UvCZs0UkV+sI+3bisIyn78wz9O/BiWZXpounu72k/R/Sj5PuZYFJ1fi6psvriUveMCGh4LeZckAZu2qiQ==

"@react-navigation/native-stack@^6.9.26":
version "6.9.26"
resolved "https://registry.yarnpkg.com/@react-navigation/native-stack/-/native-stack-6.9.26.tgz#90facf7783c9927f094bc9f01c613af75b6c241e"
integrity sha512-++dueQ+FDj2XkZ902DVrK79ub1vp19nSdAZWxKRgd6+Bc0Niiesua6rMCqymYOVaYh+dagwkA9r00bpt/U5WLw==
dependencies:
"@react-navigation/elements" "^1.3.30"
"@react-navigation/elements@^1.3.21", "@react-navigation/elements@^1.3.31":
version "1.3.31"
resolved "https://registry.yarnpkg.com/@react-navigation/elements/-/elements-1.3.31.tgz#28dd802a0787bb03fc0e5be296daf1804dbebbcf"
integrity sha512-bUzP4Awlljx5RKEExw8WYtif8EuQni2glDaieYROKTnaxsu9kEIA515sXQgUDZU4Ob12VoL7+z70uO3qrlfXcQ==

"@react-navigation/native-stack@^6.11.0":
version "6.11.0"
resolved "https://registry.yarnpkg.com/@react-navigation/native-stack/-/native-stack-6.11.0.tgz#a33f92cbd55dfe28fb0ba67df99aaa95240eb87c"
integrity sha512-U5EcUB9Q2NQspCFwYGGNJm0h6wBCOv7T30QjndmvlawLkNt7S7KWbpWyxS9XBHSIKF57RgWjfxuJNTgTstpXxw==
dependencies:
"@react-navigation/elements" "^1.3.31"
warn-once "^0.1.0"

"@react-navigation/native@^6.1.9":
Expand Down Expand Up @@ -4887,9 +4882,9 @@ cross-fetch@^3.1.5:
node-fetch "^2.6.12"

cross-spawn@^7.0.2, cross-spawn@^7.0.3:
version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==
version "7.0.6"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.6.tgz#8a58fe78f00dcd70c370451759dfbfaf03e8ee9f"
integrity sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==
dependencies:
path-key "^3.1.0"
shebang-command "^2.0.0"
Expand Down Expand Up @@ -7674,9 +7669,9 @@ [email protected]:
integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==

nanoid@^3.1.23:
version "3.3.7"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.7.tgz#d0c301a691bc8d54efa0a2226ccf3fe2fd656bd8"
integrity sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==
version "3.3.8"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.8.tgz#b1be3030bee36aaff18bacb375e5cce521684baf"
integrity sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==

natural-compare@^1.4.0:
version "1.4.0"
Expand Down
4 changes: 1 addition & 3 deletions login-workflow/jestSetupFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ jest.mock('react-i18next', () => ({
...jest.requireActual('react-i18next'),
}));
jest.mock('react-native-reanimated', () => require('react-native-reanimated/mock'));
jest.mock('@brightlayer-ui/react-native-components/node_modules/react-native-reanimated', () =>
require('react-native-reanimated/mock')
);

jest.mock('react-native-safe-area-context', () => mockSafeAreaContext);
jest.mock('react-native-webview', () => {
const { View } = require('react-native');
Expand Down
4 changes: 2 additions & 2 deletions login-workflow/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@brightlayer-ui/react-native-auth-workflow",
"description": "Re-usable workflow components for Authentication and Registration within Eaton applications.",
"version": "7.0.0",
"version": "7.0.1",
"license": "BSD-3-Clause",
"author": {
"name": "Brightlayer UI",
Expand Down Expand Up @@ -94,7 +94,7 @@
"@react-native-community/bob": "^0.10.0",
"@react-native-community/masked-view": "^0.1.10",
"@react-native/eslint-config": "0.75.2",
"@react-native/metro-config": "0.75.2",
"@react-native/metro-config": "0.76.3",
"@react-native/typescript-config": "0.75.2",
"@react-navigation/drawer": "^6.6.6",
"@react-navigation/native": "^6.1.18",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ describe('OktaRedirectLoginScreen', () => {
jest.clearAllMocks();
});


it('should call navigate with FORGOT_PASSWORD route when forgot password is clicked', () => {
render(<OktaRedirectLoginScreen />);
fireEvent.press(screen.getByText('bluiCommon:LABELS.FORGOT_PASSWORD'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ describe('OktaRedirectLoginScreenBase', () => {

test('calls handleContactSupport when contact support label is pressed', () => {
const handleContactSupport = jest.fn();
const { getByTestId } = render(<OktaRedirectLoginScreenBase showContactSupport={true} onContactSupport={handleContactSupport} />);
const { getByTestId } = render(
<OktaRedirectLoginScreenBase showContactSupport={true} onContactSupport={handleContactSupport} />
);
const contactSupportLabel = getByTestId('blui-okta-login-contact-support-label');
fireEvent.press(contactSupportLabel);
expect(handleContactSupport).toHaveBeenCalled();
Expand Down Expand Up @@ -108,4 +110,4 @@ describe('OktaRedirectLoginScreenBase', () => {
fireEvent.press(getByTestId('blui-okta-login-contact-support-label'));
expect(defaultProps.onContactSupport).toHaveBeenCalled();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ export const RegistrationWorkflow: React.FC<React.PropsWithChildren<Registration
initialPage={currentScreen ?? initialScreenIndex}
ref={viewPagerRef}
scrollEnabled={false}
collapsable={false}
key={viewPagerIndex}
onPageSelected={(e) => {
selectedPage.current = e.nativeEvent.position;
Expand All @@ -263,7 +264,9 @@ export const RegistrationWorkflow: React.FC<React.PropsWithChildren<Registration
}}
>
{screens.map((screen, index) => (
<View key={index + 1}>{screen}</View>
<View style={{ flex: 1 }} key={index + 1}>
{screen}
</View>
))}
</PagerView>
)}
Expand Down
2 changes: 1 addition & 1 deletion login-workflow/src/contexts/OktaAuthContext/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ import { OktaAuthContextProviderProps } from './types';
/**
* Okta Auth Context is used to access context in the okta authentication workflow
*/
export const OktaAuthContext = createContext<OktaAuthContextProviderProps | null>(null);
export const OktaAuthContext = createContext<OktaAuthContextProviderProps | null>(null);
2 changes: 1 addition & 1 deletion login-workflow/src/contexts/OktaAuthContext/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ export const useOktaAuthContext = (): OktaAuthContextProviderProps => {

export type { OktaAuthContextProviderProps };

export { OktaAuthContext, OktaAuthContextProvider };
export { OktaAuthContext, OktaAuthContextProvider };
13 changes: 5 additions & 8 deletions login-workflow/src/contexts/OktaAuthContext/provider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import React, { useEffect } from 'react';
import { OktaAuthContextProviderProps } from './types';
import { OktaAuthContext } from './context';
Expand All @@ -9,9 +8,9 @@ import { SharedDictionaries } from '../SharedDictionaries';
import { ErrorManagerProps } from '../../components/Error/types';
import { i18nAuthInstance } from '../AuthContext/i18nAuthInstance';

const OktaAuthContextProviderContent: React.FC<
React.PropsWithChildren<Omit<OktaAuthContextProviderProps, 'i18n'>>
> = (props) => {
const OktaAuthContextProviderContent: React.FC<React.PropsWithChildren<Omit<OktaAuthContextProviderProps, 'i18n'>>> = (
props
) => {
const { children, errorConfig, ...oktaAuthContextProps } = props;
const { t } = useTranslation();
const mergedErrorConfig: ErrorManagerProps = {
Expand All @@ -32,9 +31,7 @@ const OktaAuthContextProviderContent: React.FC<
);
};

export const OktaAuthContextProvider: React.FC<
React.PropsWithChildren<OktaAuthContextProviderProps>
> = (props) => {
export const OktaAuthContextProvider: React.FC<React.PropsWithChildren<OktaAuthContextProviderProps>> = (props) => {
const i18nInstance = props.i18n ?? i18nAuthInstance;
const { language, i18n = i18nInstance, children, ...other } = props;

Expand Down Expand Up @@ -62,4 +59,4 @@ export const OktaAuthContextProvider: React.FC<
</OktaAuthContextProviderContent>
</I18nextProvider>
);
};
};
2 changes: 1 addition & 1 deletion login-workflow/src/contexts/OktaAuthContext/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ export type OktaAuthContextProviderProps = {
* An error config for error context provider
*/
errorConfig?: ErrorContextProviderProps;
};
};
2 changes: 1 addition & 1 deletion login-workflow/src/contexts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ export * from './RegistrationContext';
export * from './SharedDictionaries';
export * from './ErrorContext';
export * from './AuthContext';
export * from './OktaAuthContext';
export * from './OktaAuthContext';
Loading

0 comments on commit 32d8f26

Please sign in to comment.