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: check visibility as well to show another login message #34791

Merged
merged 3 commits into from
Jan 29, 2024
Merged
Changes from 1 commit
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
15 changes: 9 additions & 6 deletions src/pages/signin/SignInPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import * as Localize from '@libs/Localize';
import Log from '@libs/Log';
import Navigation from '@libs/Navigation/Navigation';
import Performance from '@libs/Performance';
import Visibility from '@libs/Visibility';
import * as App from '@userActions/App';
import * as Session from '@userActions/Session';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -96,7 +97,7 @@ const defaultProps = {
* @param {Boolean} hasEmailDeliveryFailure
* @returns {Object}
*/
function getRenderOptions({hasLogin, hasValidateCode, account, isPrimaryLogin, isUsingMagicCode, hasInitiatedSAMLLogin, isClientTheLeader}) {
function getRenderOptions({hasLogin, hasValidateCode, account, isPrimaryLogin, isUsingMagicCode, hasInitiatedSAMLLogin, shouldShowAnotherLogin}) {
const hasAccount = !_.isEmpty(account);
const isSAMLEnabled = Boolean(account.isSAMLEnabled);
const isSAMLRequired = Boolean(account.isSAMLRequired);
Expand All @@ -113,13 +114,13 @@ function getRenderOptions({hasLogin, hasValidateCode, account, isPrimaryLogin, i
Session.clearSignInData();
}

const shouldShowLoginForm = isClientTheLeader && !hasLogin && !hasValidateCode;
const shouldShowLoginForm = !shouldShowAnotherLogin && !hasLogin && !hasValidateCode;
const shouldShowEmailDeliveryFailurePage = hasLogin && hasEmailDeliveryFailure && !shouldShowChooseSSOOrMagicCode && !shouldInitiateSAMLLogin;
const isUnvalidatedSecondaryLogin = hasLogin && !isPrimaryLogin && !account.validated && !hasEmailDeliveryFailure;
const shouldShowValidateCodeForm =
hasAccount && (hasLogin || hasValidateCode) && !isUnvalidatedSecondaryLogin && !hasEmailDeliveryFailure && !shouldShowChooseSSOOrMagicCode && !isSAMLRequired;
const shouldShowWelcomeHeader = shouldShowLoginForm || shouldShowValidateCodeForm || shouldShowChooseSSOOrMagicCode || isUnvalidatedSecondaryLogin;
const shouldShowWelcomeText = shouldShowLoginForm || shouldShowValidateCodeForm || shouldShowChooseSSOOrMagicCode || !isClientTheLeader;
const shouldShowWelcomeText = shouldShowLoginForm || shouldShowValidateCodeForm || shouldShowChooseSSOOrMagicCode || shouldShowAnotherLogin;
return {
shouldShowLoginForm,
shouldShowEmailDeliveryFailurePage,
Expand Down Expand Up @@ -154,6 +155,8 @@ function SignInPageInner({credentials, account, isInModal, activeClients, prefer
const [hasInitiatedSAMLLogin, setHasInitiatedSAMLLogin] = useState(false);

const isClientTheLeader = activeClients && ActiveClientManager.isClientTheLeader();
// eslint-disable-next-line rulesdir/no-negated-variables
const shouldShowAnotherLogin = Visibility.isVisible() && !isClientTheLeader;
Copy link
Contributor

Choose a reason for hiding this comment

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

A brief comment explaining what this does would be useful I think as the name by itself isn't super clear!

Copy link
Contributor

Choose a reason for hiding this comment

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

In fact I think we need to tweak the name, as it reads to me as more like "should we show another login form" (which obviously doesn't make sense!), what do you think about something like hasAnotherLoginPageOpen?

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 think shouldShowAnotherLoginPageOpenedMessage would be nice. What do you think @jjcoffee ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Name updated and comment added


useEffect(() => Performance.measureTTI(), []);
useEffect(() => {
Expand Down Expand Up @@ -192,7 +195,7 @@ function SignInPageInner({credentials, account, isInModal, activeClients, prefer
isPrimaryLogin: !account.primaryLogin || account.primaryLogin === credentials.login,
isUsingMagicCode,
hasInitiatedSAMLLogin,
isClientTheLeader,
shouldShowAnotherLogin,
});

if (shouldInitiateSAMLLogin) {
Expand All @@ -204,7 +207,7 @@ function SignInPageInner({credentials, account, isInModal, activeClients, prefer
let welcomeText = '';
const headerText = translate('login.hero.header');

if (!isClientTheLeader) {
if (shouldShowAnotherLogin) {
welcomeHeader = translate('welcomeText.anotherLoginPageIsOpen');
welcomeText = translate('welcomeText.anotherLoginPageIsOpenExplanation');
} else if (shouldShowLoginForm) {
Expand Down Expand Up @@ -270,7 +273,7 @@ function SignInPageInner({credentials, account, isInModal, activeClients, prefer
blurOnSubmit={account.validated === false}
scrollPageToTop={signInPageLayoutRef.current && signInPageLayoutRef.current.scrollPageToTop}
/>
{isClientTheLeader && (
{!shouldShowAnotherLogin && (
<>
{shouldShowValidateCodeForm && (
<ValidateCodeForm
Expand Down
Loading