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

A4A: Enable Jetpack Monitor paid tier by cleaning up feature flag logic #98829

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { isEnabled } from '@automattic/calypso-config';
import { ToggleControl } from '@wordpress/components';
import { useTranslate } from 'i18n-calypso';
import ContactList from '../../contact-list';
Expand All @@ -21,15 +20,12 @@ export default function EmailNotification( {
verifiedItem,
enableEmailNotification,
setEnableEmailNotification,
defaultUserEmailAddresses,
toggleAddEmailModal,
allEmailItems,
restriction,
}: Props ) {
const translate = useTranslate();

const isPaidTierEnabled = isEnabled( 'jetpack/pro-dashboard-monitor-paid-tier' );

return (
<>
<div className="notification-settings__toggle-container">
Expand All @@ -52,23 +48,15 @@ export default function EmailNotification( {
<div className="notification-settings__content-heading-with-beta">
<div className="notification-settings__content-heading">{ translate( 'Email' ) }</div>
</div>
{ isPaidTierEnabled ? (
<>
<div className="notification-settings__content-sub-heading">
{ translate( 'Receive email notifications with one or more recipients.' ) }
</div>
</>
) : (
<>
<div className="notification-settings__content-sub-heading">
{ translate( 'Receive email notifications with your account email address %s.', {
args: defaultUserEmailAddresses,
} ) }
{ translate( 'Receive email notifications with one or more recipients.' ) }
</div>
) }
</>
</div>
</div>

{ enableEmailNotification && isPaidTierEnabled && (
{ enableEmailNotification && (
<ContactList
type="email"
onAction={ toggleAddEmailModal }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { isEnabled } from '@automattic/calypso-config';
import { SelectDropdown } from '@automattic/components';
import { useTranslate } from 'i18n-calypso';
import { useMemo } from 'react';
import clockIcon from 'calypso/assets/images/jetpack/clock-icon.svg';
import useNotificationDurations from '../../../sites-overview/hooks/use-notification-durations';
import FeatureRestrictionBadge from '../../feature-restriction-badge';
Expand All @@ -24,13 +22,7 @@ export default function NotificationDuration( {
}: Props ) {
const translate = useTranslate();

const showPaidDuration = isEnabled( 'jetpack/pro-dashboard-monitor-paid-tier' );

const durations = useNotificationDurations();
const selectableDuration = useMemo(
() => ( showPaidDuration ? durations : durations.filter( ( duration ) => ! duration.isPaid ) ),
[ durations, showPaidDuration ]
);

return (
<div className="notification-settings__content-block">
Expand All @@ -52,7 +44,7 @@ export default function NotificationDuration( {
}
selectedText={ selectedDuration?.label }
>
{ selectableDuration.map( ( duration ) => (
{ durations.map( ( duration ) => (
<SelectDropdown.Item
key={ duration.time }
selected={ duration.time === selectedDuration?.time }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useTranslate } from 'i18n-calypso';
import ContactList from '../../contact-list';
import FeatureRestrictionBadge from '../../feature-restriction-badge';
import { RestrictionType } from '../../types';
import UpgradeLink from '../../upgrade-link';
import type { MonitorSettings, StateMonitorSettingsSMS } from '../../../sites-overview/types';

interface Props {
Expand Down Expand Up @@ -60,11 +59,6 @@ export default function SMSNotification( {
<div className="notification-settings__content-sub-heading">
{ translate( 'Set up text messages to send to one or more people.' ) }
</div>
{ restriction === 'upgrade_required' && (
<div>
<UpgradeLink />
</div>
) }
Comment on lines -63 to -67
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 removed this for now because the link didn't work and also, it's a bit too aggressive to have that many upgrade nudges.

</div>
</div>
{ enableSMSNotification && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ import configureStore from 'redux-mock-store';
import EmailNotification from '../email-notification';
import type { RestrictionType } from '../../../types';

jest.mock( '@automattic/calypso-config', () => {
const config = () => 'development';
config.isEnabled = ( property: string ) => property === 'jetpack/pro-dashboard-monitor-paid-tier';
return config;
} );

describe( 'EmailNotification', () => {
const defaultProps = {
recordEvent: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ import configureStore from 'redux-mock-store';
import DashboardDataContext from '../../../../sites-overview/dashboard-data-context';
import NotificationDuration from '../notification-duration';

jest.mock( '@automattic/calypso-config', () => {
const config = () => 'development';
config.isEnabled = ( property: string ) => property === 'jetpack/pro-dashboard-monitor-paid-tier';
return config;
} );

describe( 'NotificationDuration', () => {
const defaultProps = {
selectDuration: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ export default function NotificationSettings( {
'jetpack/pro-dashboard-monitor-sms-notification'
);

const isPaidTierEnabled = isEnabled( 'jetpack/pro-dashboard-monitor-paid-tier' );

// Check if current site or all sites selected has a paid license.
const hasPaidLicenses = ! sites.find( ( site ) => ! site.has_paid_agency_monitor );

Expand Down Expand Up @@ -484,18 +482,16 @@ export default function NotificationSettings( {
restriction={ restriction }
/>

{ isPaidTierEnabled && (
<SMSNotification
recordEvent={ recordEvent }
enableSMSNotification={ enableSMSNotification }
setEnableSMSNotification={ setEnableSMSNotification }
toggleModal={ toggleAddSMSModal }
allPhoneItems={ allPhoneItems }
verifiedItem={ verifiedItem }
restriction={ restriction }
settings={ settings }
/>
) }
<SMSNotification
recordEvent={ recordEvent }
enableSMSNotification={ enableSMSNotification }
setEnableSMSNotification={ setEnableSMSNotification }
toggleModal={ toggleAddSMSModal }
allPhoneItems={ allPhoneItems }
verifiedItem={ verifiedItem }
restriction={ restriction }
settings={ settings }
/>

<EmailNotification
recordEvent={ recordEvent }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { isEnabled } from '@automattic/calypso-config';
import { Button, Tooltip } from '@automattic/components';
import { ToggleControl } from '@wordpress/components';
import { useTranslate } from 'i18n-calypso';
Expand Down Expand Up @@ -43,10 +42,8 @@ export default function ToggleActivateMonitoring( {
const [ showNotificationSettings, setShowNotificationSettings ] = useState< boolean >( false );
const [ showTooltip, setShowTooltip ] = useState( false );

const isPaidTierEnabled = isEnabled( 'jetpack/pro-dashboard-monitor-paid-tier' );

const shouldDisplayUpgradePopover =
status === 'success' && isPaidTierEnabled && ! site.has_paid_agency_monitor && ! site.is_atomic;
status === 'success' && ! site.has_paid_agency_monitor && ! site.is_atomic;

const handleShowTooltip = () => {
setShowTooltip( true );
Expand Down Expand Up @@ -131,7 +128,7 @@ export default function ToggleActivateMonitoring( {
) as string
}
>
{ isPaidTierEnabled && smsLimitReached ? (
{ smsLimitReached ? (
<img src={ alertIcon } alt={ translate( 'Alert' ) } />
) : (
<img src={ clockIcon } alt={ translate( 'Current Schedule' ) } />
Expand Down Expand Up @@ -174,7 +171,7 @@ export default function ToggleActivateMonitoring( {
}

let tooltipText = tooltip;
if ( isPaidTierEnabled && smsLimitReached && status === 'success' ) {
if ( smsLimitReached && status === 'success' ) {
tooltipText = translate( 'You have reached the SMS limit' );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ import configureStore from 'redux-mock-store';
import { site } from '../../../sites-overview/test/test-utils/constants';
import ToggleActivateMonitoring from '../index';

jest.mock( '@automattic/calypso-config', () => {
const config = () => 'development';
config.isEnabled = ( property: string ) => property === 'jetpack/pro-dashboard-monitor-paid-tier';
return config;
} );

describe( 'ToggleActivateMonitoring', () => {
const defaultProps = {
site,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
*/

import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { render, screen, fireEvent } from '@testing-library/react';
import { render, screen } from '@testing-library/react';
import React from 'react';
import { Provider } from 'react-redux';
import configureStore from 'redux-mock-store';
import SitesOverviewContext from '../../../sites-overview/context';
import DashboardDataContext from '../../../sites-overview/dashboard-data-context';
import UpgradeLink from '../index';

Expand Down Expand Up @@ -43,37 +42,6 @@ describe( 'UpgradeLink', () => {
</Provider>
);

it( 'renders the upgrade link text', () => {
render(
<DashboardDataContext.Provider value={ dashboardContextValue }>
<UpgradeLink />
</DashboardDataContext.Provider>,
{ wrapper: Wrapper }
);
const upgradeLink = screen.getByText( 'Upgrade ($1.00/m)' );
expect( upgradeLink ).toBeInTheDocument();
} );

it( 'renders the upgrade link text and onclick works', () => {
const mockShowLicenseInfo = jest.fn();

render(
// We need only the showLicenseInfo function from the context
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
<SitesOverviewContext.Provider value={ { showLicenseInfo: mockShowLicenseInfo } }>
<DashboardDataContext.Provider value={ dashboardContextValue }>
<UpgradeLink />
</DashboardDataContext.Provider>
</SitesOverviewContext.Provider>,
{ wrapper: Wrapper }
);
const upgradeLink = screen.getByText( 'Upgrade ($1.00/m)' );
expect( upgradeLink ).toBeInTheDocument();
fireEvent.click( upgradeLink );
expect( mockShowLicenseInfo ).toHaveBeenCalledWith( 'monitor' );
} );

it( 'renders the upgrade link text inline', () => {
render(
<DashboardDataContext.Provider value={ dashboardContextValue }>
Expand All @@ -85,15 +53,4 @@ describe( 'UpgradeLink', () => {
const upgradeLink = screen.getByText( 'Upgrade ($1.00/m)' );
expect( upgradeLink.parentElement ).toHaveClass( 'is-inline' );
} );

it( 'renders the upgrade link text when the price is undefined', () => {
render(
<DashboardDataContext.Provider value={ { ...dashboardContextValue, products: [] } }>
<UpgradeLink />
</DashboardDataContext.Provider>,
{ wrapper: Wrapper }
);
const upgradeLink = screen.getByText( 'Upgrade' );
expect( upgradeLink ).toBeInTheDocument();
} );
} );
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { isEnabled } from '@automattic/calypso-config';
import showBanner from 'calypso/jetpack-cloud/sections/utils/show-banner';
import { useSelector } from 'calypso/state';
import {
Expand Down Expand Up @@ -27,7 +26,6 @@ export default function DashboardBanners() {
getPreference( state, downtimeMonitoringUpgradeBannerPreferenceName )
),
showDays: 7,
hideBanner: ! isEnabled( 'jetpack/pro-dashboard-monitor-paid-tier' ),
},
{
component: () => <SiteSurveyBanner isDashboardView />,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ type SiteColumn = {
const useDefaultSiteColumns = ( isLargeScreen = false ): SiteColumns => {
const translate = useTranslate();
const isBoostEnabled = isEnabled( 'jetpack/pro-dashboard-jetpack-boost' );
const isPaidMonitorEnabled = isEnabled( 'jetpack/pro-dashboard-monitor-paid-tier' );
const isWPCOMAtomicSiteCreationEnabled = isEnabled(
'jetpack/pro-dashboard-wpcom-atomic-hosting'
);
Expand Down Expand Up @@ -71,21 +70,15 @@ const useDefaultSiteColumns = ( isLargeScreen = false ): SiteColumns => {
title: translate( 'Monitor' ),
className: 'min-width-100px jetpack-cloud-site-column__monitor',
isExpandable: true,
showInfo: isPaidMonitorEnabled,
showInfo: true,
},
{
key: 'plugin',
title: translate( 'Plugins' ),
className: 'width-fit-content jetpack-cloud-site-column__plugin',
},
];
}, [
isBoostEnabled,
isPaidMonitorEnabled,
isWPCOMAtomicSiteCreationEnabled,
translate,
isLargeScreen,
] );
}, [ isBoostEnabled, isWPCOMAtomicSiteCreationEnabled, translate, isLargeScreen ] );
};

export default useDefaultSiteColumns;
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { isEnabled } from '@automattic/calypso-config';
import { useTranslate } from 'i18n-calypso';
import { useCallback, useContext, useEffect } from 'react';
import CelebrationIcon from 'calypso/assets/images/jetpack/celebration-icon.svg';
Expand Down Expand Up @@ -35,12 +34,8 @@ export default function SiteDowntimeMonitoringUpgradeBanner() {
[ dispatch, preference, preferenceName ]
);

const isDowntimeMonitoringPaidTierEnabled = isEnabled(
'jetpack/pro-dashboard-monitor-paid-tier'
);

useEffect( () => {
if ( isDowntimeMonitoringPaidTierEnabled && ! isDismissed && ! viewDate ) {
if ( ! isDismissed && ! viewDate ) {
savePreferenceType( 'view_date', Date.now() );
dispatch(
recordTracksEvent( 'calypso_jetpack_agency_dashboard_monitor_upgrade_banner_view' )
Expand All @@ -50,7 +45,7 @@ export default function SiteDowntimeMonitoringUpgradeBanner() {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [] );

if ( ! isDowntimeMonitoringPaidTierEnabled || isDismissed ) {
if ( isDismissed ) {
return null;
}

Expand Down
1 change: 0 additions & 1 deletion config/jetpack-cloud-development.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"jetpack/pricing-page-annual-only": true,
"jetpack/pro-dashboard-jetpack-boost": true,
"jetpack/pro-dashboard-monitor-multiple-email-recipients": true,
"jetpack/pro-dashboard-monitor-paid-tier": true,
"jetpack/pro-dashboard-monitor-sms-notification": true,
"jetpack/pro-dashboard-wpcom-atomic-hosting": true,
"jetpack/manage-simple-sites": true,
Expand Down
1 change: 0 additions & 1 deletion config/jetpack-cloud-horizon.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
"jetpack/pricing-page-annual-only": true,
"jetpack/pro-dashboard-jetpack-boost": true,
"jetpack/pro-dashboard-monitor-multiple-email-recipients": true,
"jetpack/pro-dashboard-monitor-paid-tier": true,
"jetpack/pro-dashboard-monitor-sms-notification": true,
"jetpack/pro-dashboard-wpcom-atomic-hosting": true,
"jetpack/manage-simple-sites": true,
Expand Down
1 change: 0 additions & 1 deletion config/jetpack-cloud-production.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
"jetpack/pricing-page-annual-only": true,
"jetpack/pro-dashboard-jetpack-boost": true,
"jetpack/pro-dashboard-monitor-multiple-email-recipients": true,
"jetpack/pro-dashboard-monitor-paid-tier": true,
"jetpack/pro-dashboard-monitor-sms-notification": true,
"jetpack/pro-dashboard-wpcom-atomic-hosting": true,
"jetpack/manage-simple-sites": true,
Expand Down
1 change: 0 additions & 1 deletion config/jetpack-cloud-stage.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
"jetpack/pricing-page-annual-only": true,
"jetpack/pro-dashboard-jetpack-boost": true,
"jetpack/pro-dashboard-monitor-multiple-email-recipients": true,
"jetpack/pro-dashboard-monitor-paid-tier": true,
"jetpack/pro-dashboard-monitor-sms-notification": true,
"jetpack/manage-sites-v2-menu": false,
"jetpack/search-product": true,
Expand Down
Loading