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

Fix User can not validate an account in Desktop app #19125

Merged
merged 5 commits into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import React from 'react';
import PropTypes from 'prop-types';
import {View} from 'react-native';
import TextLink from '../TextLink';
import Text from '../Text';
import Icon from '../Icon';
import * as Illustrations from '../Icon/Illustrations';
import * as Expensicons from '../Icon/Expensicons';
import colors from '../../styles/colors';
import styles from '../../styles/styles';
import withLocalize, {withLocalizePropTypes} from '../withLocalize';

const propTypes = {
openLinkInBrowser: PropTypes.func.isRequired,

...withLocalizePropTypes,
};

const DeeplinkRedirectLoadingIndicator = (props) => (
<View style={styles.deeplinkWrapperContainer}>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<View style={styles.deeplinkWrapperMessage}>
<View style={styles.mb2}>
<Icon
width={200}
height={164}
src={Illustrations.RocketBlue}
/>
</View>
<Text style={[styles.textHeadline, styles.textXXLarge]}>{props.translate('deeplinkWrapper.launching')}</Text>
<View style={[styles.mt2, styles.fontSizeNormal, styles.textAlignCenter]}>
<Text>{props.translate('deeplinkWrapper.redirectedToDesktopApp')}</Text>
<Text>
{props.translate('deeplinkWrapper.youCanAlso')} <TextLink onPress={props.openLinkInBrowser}>{props.translate('deeplinkWrapper.openLinkInBrowser')}</TextLink>.
</Text>
</View>
</View>
<View style={styles.deeplinkWrapperFooter}>
<Icon
width={154}
height={34}
fill={colors.green}
src={Expensicons.ExpensifyWordmark}
/>
</View>
</View>
);

DeeplinkRedirectLoadingIndicator.propTypes = propTypes;
DeeplinkRedirectLoadingIndicator.displayName = 'DeeplinkRedirectLoadingIndicator';

export default withLocalize(DeeplinkRedirectLoadingIndicator);
17 changes: 17 additions & 0 deletions src/components/DeeplinkWrapper/index.website.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import CONFIG from '../../CONFIG';
import * as Browser from '../../libs/Browser';
import ONYXKEYS from '../../ONYXKEYS';
import * as Authentication from '../../libs/Authentication';
import DeeplinkRedirectLoadingIndicator from './DeeplinkRedirectLoadingIndicator';

const propTypes = {
/** Children to render. */
Expand Down Expand Up @@ -37,8 +38,10 @@ class DeeplinkWrapper extends PureComponent {
this.state = {
appInstallationCheckStatus:
this.isMacOSWeb() && CONFIG.ENVIRONMENT !== CONST.ENVIRONMENT.DEV ? CONST.DESKTOP_DEEPLINK_APP_STATE.CHECKING : CONST.DESKTOP_DEEPLINK_APP_STATE.NOT_INSTALLED,
isOpenLinkInBrowser: false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB: rename to shouldOpenLinkInBrowser

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated PR for above suggestion. Thank you

};
this.focused = true;
this.openLinkInBrowser = this.openLinkInBrowser.bind(this);
}

componentDidMount() {
Expand Down Expand Up @@ -118,11 +121,25 @@ class DeeplinkWrapper extends PureComponent {
return !Browser.isMobile() && typeof navigator === 'object' && typeof navigator.userAgent === 'string' && /Mac/i.test(navigator.userAgent) && !/Electron/i.test(navigator.userAgent);
}

openLinkInBrowser() {
this.setState({isOpenLinkInBrowser: true});
}

deeplinkNeedRedirectLoadingIndicator() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB: rename for clarity that it returns a boolean

Suggested change
deeplinkNeedRedirectLoadingIndicator() {
shouldShowDeeplinkLoadingIndicator() {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated PR for above suggestion. Thank you

const validateLoginUrlPattern = '/v($|(//*))';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/v($|(//*))

@hoangzinh this can be move to CONST file -> REGEX

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated PR for above suggestion

const routeRegex = new RegExp(validateLoginUrlPattern);
return routeRegex.test(window.location.pathname);
}

render() {
if (this.state.appInstallationCheckStatus === CONST.DESKTOP_DEEPLINK_APP_STATE.CHECKING) {
return <FullScreenLoadingIndicator style={styles.flex1} />;
}

if (this.state.appInstallationCheckStatus === CONST.DESKTOP_DEEPLINK_APP_STATE.INSTALLED && this.deeplinkNeedRedirectLoadingIndicator() && !this.state.isOpenLinkInBrowser) {
return <DeeplinkRedirectLoadingIndicator openLinkInBrowser={this.openLinkInBrowser} />;
}

return this.props.children;
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ export default {
launching: 'Launching Expensify',
expired: 'Your session has expired.',
signIn: 'Please sign in again.',
redirectedToDesktopApp: "We've redirected you to the desktop app.",
youCanAlso: 'You can also',
openLinkInBrowser: 'open this link in your browser',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hoangzinh has this been approved by any internal person?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah, I copied those text from previous PR https://github.com/Expensify/App/pull/16383/files#diff-22037c1e4dbdea8803b450b3fce06e6c475762a31ecf84b34dc264ba0e443637L158-L163

Basicallly this PR reimplement what we had before. So do I need to ask on Slack again? Or we can make decision here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hoangzinh thanks for confirming, sound good!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i think this is fine

},
validateCodeModal: {
successfulSignInTitle: 'Abracadabra,\nyou are signed in!',
Expand Down
3 changes: 3 additions & 0 deletions src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ export default {
launching: 'Cargando Expensify',
expired: 'Tu sesión ha expirado.',
signIn: 'Por favor, inicia sesión de nuevo.',
redirectedToDesktopApp: 'Te hemos redirigido a la aplicación de escritorio.',
youCanAlso: 'También puedes',
openLinkInBrowser: 'abrir este enlace en tu navegador',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same with translations

},
validateCodeModal: {
successfulSignInTitle: 'Abracadabra,\n¡sesión iniciada!',
Expand Down