Skip to content

Commit

Permalink
pro-status: Use feature checks for VPScan and VPBackup (#24193)
Browse files Browse the repository at this point in the history
* pro-status: Use feature checks for VPScan and VPBackup
  • Loading branch information
mreishus authored May 4, 2022
1 parent 0266852 commit d1dd13e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
39 changes: 19 additions & 20 deletions projects/plugins/jetpack/_inc/client/pro-status/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
isAkismetKeyValid,
isFetchingAkismetData,
} from 'state/at-a-glance';
import { getSitePlan, isFetchingSiteData } from 'state/site';
import { getSitePlan, hasActiveSiteFeature, isFetchingSiteData } from 'state/site';
import { getRewindStatus } from 'state/rewind';
import { getScanStatus } from 'state/scan';
import { isOfflineMode } from 'state/connection';
Expand Down Expand Up @@ -176,6 +176,7 @@ class ProStatus extends React.Component {
};

render() {
const { purchasedVaultPressBackups, purchasedVaultPressScan, scanStatus } = this.props;
const sitePlan = this.props.sitePlan,
vpData = this.props.getVaultPressData();
let pluginSlug = '';
Expand All @@ -190,20 +191,19 @@ class ProStatus extends React.Component {
pluginSlug = 'akismet/akismet.php';
}

const hasPersonal = /jetpack_personal*/.test( sitePlan.product_slug ),
hasFree = /jetpack_free*/.test( sitePlan.product_slug ),
hasBackups = get( vpData, [ 'data', 'features', 'backups' ], false ),
hasVPScan = get( vpData, [ 'data', 'features', 'security' ], false );

const { scanStatus } = this.props;
const hasFree = /jetpack_free*/.test( sitePlan.product_slug ),
usingVPBackups = get( vpData, [ 'data', 'features', 'backups' ], false ),
usingVPScan = get( vpData, [ 'data', 'features', 'security' ], false );

const getStatus = ( feature, active, installed ) => {
switch ( feature ) {
case 'rewind':
// This is the newer backup technology powered by Jetpack Backup.
return this.getProActions( 'rewind_connected', 'rewind' );

case 'backups':
if ( hasFree && ! hasBackups && this.props.isCompact ) {
// This is the older backup technology powered by VaultPress.
if ( hasFree && ! usingVPBackups && this.props.isCompact ) {
return '';
}
break;
Expand All @@ -213,21 +213,18 @@ class ProStatus extends React.Component {
return '';
}
if ( 'N/A' !== vpData ) {
if ( ( hasFree || hasPersonal ) && ! hasVPScan ) {
if ( ! this.props.isCompact && hasPersonal && ! hasBackups ) {
// Personal plans doesn't have scan but it does have backups.
return this.getSetUpButton( 'backups' );
if ( purchasedVaultPressScan ) {
if ( usingVPScan ) {
return this.getProActions(
0 === this.props.getScanThreats() ? 'secure' : 'threats',
'scan'
);
}
return '';
}
if ( ! hasVPScan ) {
return this.getSetUpButton( 'scan' );
} else if ( purchasedVaultPressBackups && ! usingVPBackups && ! this.props.isCompact ) {
return this.getSetUpButton( 'backups' );
}

return this.getProActions(
0 === this.props.getScanThreats() ? 'secure' : 'threats',
'scan'
);
return '';
} else if ( scanStatus && scanStatus.state !== 'unavailable' ) {
if ( Array.isArray( scanStatus.threats ) && scanStatus.threats.length > 0 ) {
return (
Expand Down Expand Up @@ -316,5 +313,7 @@ export default connect( state => {
fetchingAkismetData: isFetchingAkismetData( state ),
rewindStatus: getRewindStatus( state ),
scanStatus: getScanStatus( state ),
purchasedVaultPressBackups: hasActiveSiteFeature( state, 'vaultpress-backups' ),
purchasedVaultPressScan: hasActiveSiteFeature( state, 'vaultpress-security-scanning' ),
};
} )( ProStatus );
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: other
Comment: pro-status: Use feature checks for VPScan and VPBackup


0 comments on commit d1dd13e

Please sign in to comment.