From dbffd72b296ae0f072dc328a88c2d2b522619523 Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Wed, 7 Jun 2023 23:53:35 +0300 Subject: [PATCH 1/5] Move code from AbracadabraModal to TfaRequiredModal --- src/components/ValidateCode/TfaRequiredModal.js | 16 ++++++++++++---- src/pages/ValidateLoginPage/index.website.js | 4 ++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/components/ValidateCode/TfaRequiredModal.js b/src/components/ValidateCode/TfaRequiredModal.js index a4afb79c84b2..5736d1a5d1c3 100644 --- a/src/components/ValidateCode/TfaRequiredModal.js +++ b/src/components/ValidateCode/TfaRequiredModal.js @@ -1,4 +1,5 @@ import React, {PureComponent} from 'react'; +import PropTypes from 'prop-types'; import {View} from 'react-native'; import colors from '../../styles/colors'; import styles from '../../styles/styles'; @@ -11,6 +12,9 @@ import variables from '../../styles/variables'; const propTypes = { ...withLocalizePropTypes, + + /** Whether the 2FA is needed to get fully authenticated. */ + is2FARequired: PropTypes.bool.isRequired, }; class TfaRequiredModal extends PureComponent { @@ -21,13 +25,17 @@ class TfaRequiredModal extends PureComponent { - {this.props.translate('validateCodeModal.tfaRequiredTitle')} + + {this.props.translate(this.props.is2FARequired ? 'validateCodeModal.tfaRequiredTitle' : 'validateCodeModal.successfulSignInTitle')} + - {this.props.translate('validateCodeModal.tfaRequiredDescription')} + + {this.props.translate(this.props.is2FARequired ? 'validateCodeModal.tfaRequiredDescription' : 'validateCodeModal.successfulSignInDescription')} + diff --git a/src/pages/ValidateLoginPage/index.website.js b/src/pages/ValidateLoginPage/index.website.js index 6dfc5d8d87b7..a89de087d3a2 100644 --- a/src/pages/ValidateLoginPage/index.website.js +++ b/src/pages/ValidateLoginPage/index.website.js @@ -124,8 +124,8 @@ class ValidateLoginPage extends Component { return ( <> {currentAuthState === CONST.AUTO_AUTH_STATE.FAILED && } - {currentAuthState === CONST.AUTO_AUTH_STATE.JUST_SIGNED_IN && is2FARequired && !isSignedIn && } - {currentAuthState === CONST.AUTO_AUTH_STATE.JUST_SIGNED_IN && isSignedIn && } + {currentAuthState === CONST.AUTO_AUTH_STATE.JUST_SIGNED_IN && is2FARequired && !isSignedIn && } + {currentAuthState === CONST.AUTO_AUTH_STATE.JUST_SIGNED_IN && isSignedIn && } {currentAuthState === CONST.AUTO_AUTH_STATE.NOT_STARTED && !isSignedIn && ( Date: Wed, 7 Jun 2023 23:54:49 +0300 Subject: [PATCH 2/5] Remove AbracadabraModal --- .../ValidateCode/AbracadabraModal.js | 47 ------------------- src/pages/ValidateLoginPage/index.website.js | 1 - 2 files changed, 48 deletions(-) delete mode 100644 src/components/ValidateCode/AbracadabraModal.js diff --git a/src/components/ValidateCode/AbracadabraModal.js b/src/components/ValidateCode/AbracadabraModal.js deleted file mode 100644 index 8debd439bf64..000000000000 --- a/src/components/ValidateCode/AbracadabraModal.js +++ /dev/null @@ -1,47 +0,0 @@ -import React, {PureComponent} from 'react'; -import {View} from 'react-native'; -import colors from '../../styles/colors'; -import styles from '../../styles/styles'; -import Icon from '../Icon'; -import withLocalize, {withLocalizePropTypes} from '../withLocalize'; -import Text from '../Text'; -import * as Expensicons from '../Icon/Expensicons'; -import * as Illustrations from '../Icon/Illustrations'; -import variables from '../../styles/variables'; - -const propTypes = { - ...withLocalizePropTypes, -}; - -class AbracadabraModal extends PureComponent { - render() { - return ( - - - - - - {this.props.translate('validateCodeModal.successfulSignInTitle')} - - {this.props.translate('validateCodeModal.successfulSignInDescription')} - - - - - - - ); - } -} - -AbracadabraModal.propTypes = propTypes; -export default withLocalize(AbracadabraModal); diff --git a/src/pages/ValidateLoginPage/index.website.js b/src/pages/ValidateLoginPage/index.website.js index a89de087d3a2..374c08304970 100644 --- a/src/pages/ValidateLoginPage/index.website.js +++ b/src/pages/ValidateLoginPage/index.website.js @@ -11,7 +11,6 @@ import ONYXKEYS from '../../ONYXKEYS'; import * as Session from '../../libs/actions/Session'; import Permissions from '../../libs/Permissions'; import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; -import AbracadabraModal from '../../components/ValidateCode/AbracadabraModal'; import ExpiredValidateCodeModal from '../../components/ValidateCode/ExpiredValidateCodeModal'; import Navigation from '../../libs/Navigation/Navigation'; import ROUTES from '../../ROUTES'; From e384cfaf297820c1e8d1fbc531c34e931524aa9a Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Wed, 7 Jun 2023 23:56:47 +0300 Subject: [PATCH 3/5] Rename the new component --- .../{TfaRequiredModal.js => JustSignedInModal.js} | 6 +++--- src/pages/ValidateLoginPage/index.website.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) rename src/components/ValidateCode/{TfaRequiredModal.js => JustSignedInModal.js} (94%) diff --git a/src/components/ValidateCode/TfaRequiredModal.js b/src/components/ValidateCode/JustSignedInModal.js similarity index 94% rename from src/components/ValidateCode/TfaRequiredModal.js rename to src/components/ValidateCode/JustSignedInModal.js index 5736d1a5d1c3..03a045e023ab 100644 --- a/src/components/ValidateCode/TfaRequiredModal.js +++ b/src/components/ValidateCode/JustSignedInModal.js @@ -17,7 +17,7 @@ const propTypes = { is2FARequired: PropTypes.bool.isRequired, }; -class TfaRequiredModal extends PureComponent { +class JustSignedInModal extends PureComponent { render() { return ( @@ -51,5 +51,5 @@ class TfaRequiredModal extends PureComponent { } } -TfaRequiredModal.propTypes = propTypes; -export default withLocalize(TfaRequiredModal); +JustSignedInModal.propTypes = propTypes; +export default withLocalize(JustSignedInModal); diff --git a/src/pages/ValidateLoginPage/index.website.js b/src/pages/ValidateLoginPage/index.website.js index 374c08304970..a7b25951e702 100644 --- a/src/pages/ValidateLoginPage/index.website.js +++ b/src/pages/ValidateLoginPage/index.website.js @@ -15,7 +15,7 @@ import ExpiredValidateCodeModal from '../../components/ValidateCode/ExpiredValid import Navigation from '../../libs/Navigation/Navigation'; import ROUTES from '../../ROUTES'; import CONST from '../../CONST'; -import TfaRequiredModal from '../../components/ValidateCode/TfaRequiredModal'; +import JustSignedInModal from '../../components/ValidateCode/JustSignedInModal'; const propTypes = { /** The accountID and validateCode are passed via the URL */ @@ -123,8 +123,8 @@ class ValidateLoginPage extends Component { return ( <> {currentAuthState === CONST.AUTO_AUTH_STATE.FAILED && } - {currentAuthState === CONST.AUTO_AUTH_STATE.JUST_SIGNED_IN && is2FARequired && !isSignedIn && } - {currentAuthState === CONST.AUTO_AUTH_STATE.JUST_SIGNED_IN && isSignedIn && } + {currentAuthState === CONST.AUTO_AUTH_STATE.JUST_SIGNED_IN && is2FARequired && !isSignedIn && } + {currentAuthState === CONST.AUTO_AUTH_STATE.JUST_SIGNED_IN && isSignedIn && } {currentAuthState === CONST.AUTO_AUTH_STATE.NOT_STARTED && !isSignedIn && ( Date: Thu, 8 Jun 2023 00:00:21 +0300 Subject: [PATCH 4/5] Make the new component a function component. --- .../ValidateCode/JustSignedInModal.js | 56 +++++++++---------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/src/components/ValidateCode/JustSignedInModal.js b/src/components/ValidateCode/JustSignedInModal.js index 03a045e023ab..40b25e4a19e0 100644 --- a/src/components/ValidateCode/JustSignedInModal.js +++ b/src/components/ValidateCode/JustSignedInModal.js @@ -1,4 +1,4 @@ -import React, {PureComponent} from 'react'; +import React from 'react'; import PropTypes from 'prop-types'; import {View} from 'react-native'; import colors from '../../styles/colors'; @@ -17,38 +17,36 @@ const propTypes = { is2FARequired: PropTypes.bool.isRequired, }; -class JustSignedInModal extends PureComponent { - render() { - return ( - - - - - - - {this.props.translate(this.props.is2FARequired ? 'validateCodeModal.tfaRequiredTitle' : 'validateCodeModal.successfulSignInTitle')} - - - - {this.props.translate(this.props.is2FARequired ? 'validateCodeModal.tfaRequiredDescription' : 'validateCodeModal.successfulSignInDescription')} - - - - +function JustSignedInModal(props) { + return ( + + + + + {props.translate(props.is2FARequired ? 'validateCodeModal.tfaRequiredTitle' : 'validateCodeModal.successfulSignInTitle')} + + + + {props.translate(props.is2FARequired ? 'validateCodeModal.tfaRequiredDescription' : 'validateCodeModal.successfulSignInDescription')} + + + + + - ); - } + + ); } JustSignedInModal.propTypes = propTypes; From 0ec73b92d4fa6b3d0d15784695edc9e23b1fdaea Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Thu, 8 Jun 2023 00:18:51 +0300 Subject: [PATCH 5/5] Run Prettier --- src/pages/ValidateLoginPage/index.website.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/ValidateLoginPage/index.website.js b/src/pages/ValidateLoginPage/index.website.js index a7b25951e702..26bfdf902a22 100644 --- a/src/pages/ValidateLoginPage/index.website.js +++ b/src/pages/ValidateLoginPage/index.website.js @@ -123,8 +123,8 @@ class ValidateLoginPage extends Component { return ( <> {currentAuthState === CONST.AUTO_AUTH_STATE.FAILED && } - {currentAuthState === CONST.AUTO_AUTH_STATE.JUST_SIGNED_IN && is2FARequired && !isSignedIn && } - {currentAuthState === CONST.AUTO_AUTH_STATE.JUST_SIGNED_IN && isSignedIn && } + {currentAuthState === CONST.AUTO_AUTH_STATE.JUST_SIGNED_IN && is2FARequired && !isSignedIn && } + {currentAuthState === CONST.AUTO_AUTH_STATE.JUST_SIGNED_IN && isSignedIn && } {currentAuthState === CONST.AUTO_AUTH_STATE.NOT_STARTED && !isSignedIn && (