Skip to content

Commit

Permalink
Update/mailbox link professional email without feature flags (#64986)
Browse files Browse the repository at this point in the history
  • Loading branch information
AllTerrainDeveloper authored and bangank36 committed Jun 29, 2022
1 parent 59ece71 commit d497f45
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 58 deletions.

This file was deleted.

This file was deleted.

42 changes: 30 additions & 12 deletions client/lib/titan/get-titan-urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,53 @@ export function getTitanAppsUrlPrefix( domain ) {
* @param {string?} email - The email address of the Titan account. Used for autofill on Titan's login page.
* @param {string?} app - Can be one of the `TITAN_APPS` - `email`, `calendar` or `contacts`
* @param {boolean?} clearPreviousSessions - Whether to clear previously logged-in sessions.
* @returns The URL with app and prefilled `email_account` as query parameter
* @param {string?} redirectUrl - Where the Professional Email client should redirect the user back to WordPress.
* @returns {string} The URL with app and prefilled `email_account` as query parameter
*/
function getTitanUrl(
titanAppsUrlPrefix,
email,
app = TITAN_APPS.EMAIL,
clearPreviousSessions = false
clearPreviousSessions = false,
redirectUrl = null
) {
const titanAppUrl = new URL( `${ titanAppsUrlPrefix }/${ app }/` );

if ( email?.includes( '@' ) ) {
titanAppUrl.searchParams.append( 'email_account', email );
}

if ( redirectUrl ) {
titanAppUrl.searchParams.append( 'topbar.redirect_url', redirectUrl );
}

if ( clearPreviousSessions ) {
titanAppUrl.searchParams.append( 'clearSession', 'true' );
}

return titanAppUrl.href;
}

export function getTitanCalendarUrl( titanAppsUrlPrefix, email ) {
return getTitanUrl( titanAppsUrlPrefix, email, TITAN_APPS.CALENDAR );
}

export function getTitanContactsUrl( titanAppsUrlPrefix, email ) {
return getTitanUrl( titanAppsUrlPrefix, email, TITAN_APPS.CONTACTS );
}

export function getTitanEmailUrl( titanAppsUrlPrefix, email, clearPreviousSessions = false ) {
return getTitanUrl( titanAppsUrlPrefix, email, TITAN_APPS.EMAIL, clearPreviousSessions );
/**
* Gets the Web client URL for Professional Email
*
* @param { string } titanAppsUrlPrefix URL prefix to build the final URL based on the next parameters
* @param { string | undefined } email Email account is going to be used
* @param { boolean } clearPreviousSessions Flag to clear session in the Web Client
* @param { string } redirectUrl URL to go back from the Web Client
* @returns { string } Path to be used to send the user to the Web Client
*/
export function getTitanEmailUrl(
titanAppsUrlPrefix,
email,
clearPreviousSessions = false,
redirectUrl = null
) {
return getTitanUrl(
titanAppsUrlPrefix,
email,
TITAN_APPS.EMAIL,
clearPreviousSessions,
redirectUrl
);
}
2 changes: 1 addition & 1 deletion client/lib/titan/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export { getTitanMailOrderId } from './get-titan-mail-order-id';
export { getTitanProductName } from './get-titan-product-name';
export { getTitanProductSlug } from './get-titan-product-slug';
export { getTitanSubscriptionId } from './get-titan-subscription-id';
export { getTitanCalendarUrl, getTitanContactsUrl, getTitanEmailUrl } from './get-titan-urls';
export { getTitanEmailUrl } from './get-titan-urls';
export { hasTitanMailWithUs } from './has-titan-mail-with-us';
export { isDomainEligibleForTitanFreeTrial } from './is-domain-eligible-for-titan-free-trial';
export { isTitanMonthlyProduct } from './is-titan-monthly-product';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const StepCTA = ( { email, primary, domainType }: StepCTAProps ) => {
return (
<FullWidthButton
href={ getTitanEmailUrl( titanAppsUrlPrefix, email, true ) }
target="_blank"
primary={ primary }
onClick={ () => {
recordEmailAppLaunchEvent( {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import googleDriveIcon from 'calypso/assets/images/email-providers/google-worksp
import gmailIcon from 'calypso/assets/images/email-providers/google-workspace/services/flat/gmail.svg';
import googleSheetsIcon from 'calypso/assets/images/email-providers/google-workspace/services/flat/sheets.svg';
import googleSlidesIcon from 'calypso/assets/images/email-providers/google-workspace/services/flat/slides.svg';
import titanCalendarIcon from 'calypso/assets/images/email-providers/titan/services/flat/calendar.svg';
import titanContactsIcon from 'calypso/assets/images/email-providers/titan/services/flat/contacts.svg';
import titanMailIcon from 'calypso/assets/images/email-providers/titan/services/flat/mail.svg';
import EllipsisMenu from 'calypso/components/ellipsis-menu';
import MaterialIcon from 'calypso/components/material-icon';
Expand All @@ -37,13 +35,7 @@ import {
getGoogleSlidesUrl,
hasGSuiteWithUs,
} from 'calypso/lib/gsuite';
import {
getTitanCalendarUrl,
getTitanContactsUrl,
getTitanEmailUrl,
hasTitanMailWithUs,
useTitanAppsUrlPrefix,
} from 'calypso/lib/titan';
import { getTitanEmailUrl, hasTitanMailWithUs, useTitanAppsUrlPrefix } from 'calypso/lib/titan';
import { recordEmailAppLaunchEvent } from 'calypso/my-sites/email/email-management/home/utils';
import { errorNotice, successNotice } from 'calypso/state/notices/actions';

Expand Down Expand Up @@ -89,32 +81,15 @@ const getTitanMenuItems = ( {

return [
{
href: getTitanEmailUrl( titanAppsUrlPrefix, email ),
href: getTitanEmailUrl( titanAppsUrlPrefix, email, false, window.location.href ),
image: titanMailIcon,
imageAltText: translate( 'Titan Mail icon' ),
isInternalLink: true,
title: translate( 'View Mail', {
comment: 'View the Email application (i.e. the webmail) for Titan',
} ),
onClick: getTitanClickHandler( 'webmail' ),
},
{
href: getTitanCalendarUrl( titanAppsUrlPrefix, email ),
image: titanCalendarIcon,
imageAltText: translate( 'Titan Calendar icon' ),
title: translate( 'View Calendar', {
comment: 'View the Calendar application for Titan',
} ),
onClick: getTitanClickHandler( 'calendar' ),
},
{
href: getTitanContactsUrl( titanAppsUrlPrefix, email ),
image: titanContactsIcon,
imageAltText: translate( 'Titan Contacts icon' ),
title: translate( 'View Contacts', {
comment: 'View the Contacts application for Titan',
} ),
onClick: getTitanClickHandler( 'contacts' ),
},
...( canCurrentUserAddEmail( domain )
? [
{
Expand Down
9 changes: 7 additions & 2 deletions client/my-sites/email/inbox/mailbox-selection-list/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ import './style.scss';

const getExternalUrl = ( mailbox, titanAppsUrlPrefix ) => {
if ( isTitanMailAccount( mailbox ) ) {
return getTitanEmailUrl( titanAppsUrlPrefix, getEmailAddress( mailbox ), true );
return getTitanEmailUrl(
titanAppsUrlPrefix,
getEmailAddress( mailbox ),
! titanAppsUrlPrefix,
window.location.href
);
}

if ( isGoogleEmailAccount( mailbox ) ) {
Expand Down Expand Up @@ -109,7 +114,7 @@ const MailboxItem = ( { mailbox } ) => {
}
className="mailbox-selection-list__item"
href={ getExternalUrl( mailbox, titanAppsUrlPrefix ) }
target="external"
target={ isTitanMailAccount( mailbox ) ? null : 'external' }
>
<span className="mailbox-selection-list__icon">
<MailboxItemIcon mailbox={ mailbox } />
Expand Down
9 changes: 6 additions & 3 deletions client/my-sites/email/titan-set-up-thank-you/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,13 @@ const TitanSetUpThankYou = ( {
stepDescription: translate( 'Access your email from anywhere with our webmail.' ),
stepCta: (
<FullWidthButton
href={ getTitanEmailUrl( titanAppsUrlPrefix, emailAddress, true ) }
href={ getTitanEmailUrl(
titanAppsUrlPrefix,
emailAddress,
true,
`${ window.location.protocol }//${ window.location.host }/${ emailManagementPath }`
) }
primary
target="_blank"
onClick={ () => {
recordEmailAppLaunchEvent( {
provider: 'titan',
Expand All @@ -79,7 +83,6 @@ const TitanSetUpThankYou = ( {
} }
>
{ translate( 'Go to Inbox' ) }
<Gridicon className="titan-set-up-thank-you__icon-external" icon="external" />
</FullWidthButton>
),
},
Expand Down

0 comments on commit d497f45

Please sign in to comment.