File size: 4,399 Bytes
1e92f2d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | import { TranslateResult, fixMe } from 'i18n-calypso';
import { capitalize } from 'lodash';
import {
isJetpackCloudOAuth2Client,
isA4AOAuth2Client,
isBlazeProOAuth2Client,
isPartnerPortalOAuth2Client,
isVIPOAuth2Client,
} from 'calypso/lib/oauth2-clients';
import { getOAuth2Client } from 'calypso/state/oauth2-clients/selectors';
import getCurrentQueryArguments from 'calypso/state/selectors/get-current-query-arguments';
interface Props {
twoFactorAuthType: string | null;
isManualRenewalImmediateLoginAttempt: boolean;
socialConnect: boolean;
linkingSocialService: string;
action: string;
oauth2Client: ReturnType< typeof getOAuth2Client >;
twoFactorEnabled: boolean;
currentQuery: ReturnType< typeof getCurrentQueryArguments >;
translate: ( arg0: string, arg1?: object ) => TranslateResult;
isJetpack?: boolean;
twoStepNonce?: string | null;
isSocialFirst?: boolean;
isWooJPC?: boolean;
isWCCOM?: boolean;
isFromAkismet?: boolean;
isFromAutomatticForAgenciesPlugin?: boolean;
isGravPoweredClient?: boolean;
}
/**
* This function is used to get the header text for the login page.
* TODO: We'll convert this to hook form in the future.
*/
export function getHeaderText( {
isSocialFirst,
twoFactorAuthType,
isManualRenewalImmediateLoginAttempt,
socialConnect,
linkingSocialService,
action,
oauth2Client,
isWooJPC,
isJetpack,
isWCCOM,
isFromAkismet,
isFromAutomatticForAgenciesPlugin,
isGravPoweredClient,
twoFactorEnabled,
currentQuery,
translate,
twoStepNonce,
}: Props ): TranslateResult {
let headerText = translate( 'Log in to your account' );
if ( isSocialFirst ) {
let clientName = oauth2Client?.name;
if ( isFromAkismet ) {
clientName = 'Akismet';
} else if ( isBlazeProOAuth2Client( oauth2Client ) ) {
clientName = 'Blaze Pro';
} else if ( isA4AOAuth2Client( oauth2Client ) ) {
clientName = 'Automattic for Agencies';
} else if ( isJetpackCloudOAuth2Client( oauth2Client ) ) {
clientName = 'Jetpack Cloud';
} else if ( isJetpack ) {
clientName = 'Jetpack';
} else if ( isWCCOM || isWooJPC ) {
clientName = 'Woo';
} else if ( isVIPOAuth2Client( oauth2Client ) ) {
clientName = 'VIP';
}
headerText = clientName
? ( fixMe( {
text: 'Log in to {{span}}%(client)s{{/span}} with WordPress.com',
newCopy: translate( 'Log in to {{span}}%(client)s{{/span}} with WordPress.com', {
args: { client: clientName },
components: { span: <span className="wp-login__login-block-header-client-name" /> },
} ),
oldCopy: translate( 'Log in to WordPress.com' ),
} ) as TranslateResult )
: translate( 'Log in to WordPress.com' );
}
if ( twoFactorAuthType === 'authenticator' ) {
headerText = translate( 'Continue with an authentication code' );
}
if ( twoFactorAuthType === 'push' ) {
headerText = translate( 'Continue with the Jetpack app' );
} else if ( twoFactorAuthType === 'backup' ) {
headerText = translate( 'Continue with a backup code' );
}
if ( isManualRenewalImmediateLoginAttempt ) {
headerText = translate( 'Log in to update your payment details and renew your subscription' );
}
if ( twoStepNonce ) {
headerText = translate( 'Two-Step Authentication' );
}
if ( socialConnect ) {
headerText = translate( 'Connect your %(service)s account', {
args: {
service: capitalize( linkingSocialService ),
},
} );
}
if ( action === 'lostpassword' ) {
headerText = translate( 'Forgot your password?' );
} else if ( currentQuery?.lostpassword_flow === 'true' ) {
headerText = translate( "You've got mail" );
} else if ( oauth2Client ) {
if ( isPartnerPortalOAuth2Client( oauth2Client ) ) {
if ( document.location.search?.includes( 'wpcloud' ) ) {
headerText = translate( 'Log in to WP Cloud with WordPress.com' );
} else {
headerText = translate(
'Howdy! Log into the Automattic Partner Portal with your WordPress.com account.'
);
}
}
if ( isGravPoweredClient ) {
headerText = translate( 'Login to %(clientTitle)s', {
args: { clientTitle: oauth2Client.title },
} );
}
} else if ( isWooJPC ) {
if ( twoFactorEnabled ) {
headerText = translate( 'Authenticate your login' );
} else {
headerText = translate( 'Log in to your account' );
}
}
if ( isFromAutomatticForAgenciesPlugin ) {
headerText = translate( 'Log in to Automattic for Agencies' );
}
return headerText;
}
|