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

Prevents upsell for Jetpack Backup for multisite installations #44187

Merged
merged 4 commits into from
Jul 17, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion client/components/jetpack/upsell/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import './style.scss';

interface Props {
bodyText: TranslateResult;
buttonLink: TranslateResult;
buttonLink?: TranslateResult;
buttonText?: TranslateResult;
headerText: TranslateResult;
iconComponent?: ReactChild;
Expand Down
23 changes: 0 additions & 23 deletions client/landing/jetpack-cloud/sections/wpcom-upsell.tsx

This file was deleted.

43 changes: 34 additions & 9 deletions client/my-sites/backup/backup-upsell/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ const BackupsUpsellIcon: FunctionComponent = () => (
</div>
);

const BackupsMultisiteBody: FunctionComponent = () => {
const translate = useTranslate();
return (
<Upsell
headerText={ translate( 'WordPress multi-sites are not supported' ) }
bodyText={ translate(
"We're sorry, Jetpack Backup is not compatible with multisite WordPress installations at this time."
) }
iconComponent={ <BackupsUpsellIcon /> }
/>
);
};

const BackupsVPActiveBody: FunctionComponent = () => {
const translate = useTranslate();
const dispatch = useDispatch();
Expand Down Expand Up @@ -64,14 +77,26 @@ const BackupsUpsellBody: FunctionComponent = () => {
);
};

const BackupsUpsellPage: FunctionComponent< UpsellComponentProps > = ( { reason } ) => (
<Main className="backup-upsell">
<DocumentHead title="Backup" />
<SidebarNavigation />
<div className="backup-upsell__content">
{ 'vp_active_on_site' === reason ? <BackupsVPActiveBody /> : <BackupsUpsellBody /> }
</div>
</Main>
);
const BackupsUpsellPage: FunctionComponent< UpsellComponentProps > = ( { reason } ) => {
let body;
switch ( reason ) {
case 'vp_active_on_site':
body = <BackupsVPActiveBody />;
break;
case 'multisite_not_supported':
body = <BackupsMultisiteBody />;
break;
default:
body = <BackupsUpsellBody />;
break;
}
return (
<Main className="backup-upsell">
<DocumentHead title="Backup" />
<SidebarNavigation />
<div className="backup-upsell__content">{ body }</div>
</Main>
);
};

export default BackupsUpsellPage;
13 changes: 11 additions & 2 deletions client/my-sites/scan/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import getSiteUrl from 'state/sites/selectors/get-site-url';
import getSiteScanProgress from 'state/selectors/get-site-scan-progress';
import getSiteScanIsInitial from 'state/selectors/get-site-scan-is-initial';
import getSiteScanState from 'state/selectors/get-site-scan-state';
import isRequestingJetpackScan from 'state/selectors/is-requesting-jetpack-scan';
import { withLocalizedMoment } from 'components/localized-moment';
import contactSupportUrl from 'lib/jetpack/contact-support-url';
import isJetpackCloud from 'lib/jetpack/is-jetpack-cloud';
Expand All @@ -51,6 +52,7 @@ interface Props {
scanState?: Scan;
scanProgress?: number;
isInitialScan?: boolean;
isRequestingScan: boolean;
timezone: string | null;
gmtOffset: number | null;
moment: {
Expand All @@ -59,6 +61,7 @@ interface Props {
applySiteOffset: applySiteOffsetType;
dispatchRecordTracksEvent: Function;
dispatchScanRun: Function;
isAdmin: boolean;
}

class ScanPage extends Component< Props > {
Expand Down Expand Up @@ -206,11 +209,15 @@ class ScanPage extends Component< Props > {
}

renderScanState() {
const { site, scanState } = this.props;
if ( ! scanState || ! site ) {
const { site, scanState, isRequestingScan } = this.props;
if ( isRequestingScan || ! site ) {
return <ScanPlaceholder />;
}

if ( ! scanState ) {
return this.renderScanError();
}

const { state, mostRecent, threats } = scanState;

if ( state === 'provisioning' ) {
Expand Down Expand Up @@ -288,6 +295,7 @@ export default connect(
const siteUrl = getSiteUrl( state, siteId ) ?? undefined;
const scanState = ( getSiteScanState( state, siteId ) as Scan ) ?? undefined;
const scanProgress = getSiteScanProgress( state, siteId ) ?? undefined;
const isRequestingScan = isRequestingJetpackScan( state, siteId );
const isInitialScan = getSiteScanIsInitial( state, siteId );
const isAdmin = canCurrentUser( state, siteId, 'manage_options' );

Expand All @@ -298,6 +306,7 @@ export default connect(
scanState,
scanProgress,
isInitialScan,
isRequestingScan,
isAdmin,
};
},
Expand Down
5 changes: 3 additions & 2 deletions client/state/data-layer/wpcom/sites/scan/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,16 @@ export const formatScanThreat = ( threat ) => ( {
const formatScanStateRawResponse = ( {
state,
threats,
credentials,
most_recent: mostRecent,
current,
...rest
} ) => {
if ( ! threats ) {
threats = [];
}
return {
state,
threats: threats.map( formatScanThreat ),
credentials,
mostRecent: mostRecent
? {
...omit( mostRecent, [ 'is_initial' ] ),
Expand Down