Skip to content

Commit

Permalink
Customer Home: explicitly exclude VIP sites from loading Customer Home (
Browse files Browse the repository at this point in the history
  • Loading branch information
gwwar authored Jan 28, 2020
1 parent 1cc6238 commit d077255
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
5 changes: 5 additions & 0 deletions client/my-sites/sites/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ class Sites extends Component {
return true;
}

// Supported on Simple and Atomic Sites
if ( /^\/home/.test( path ) ) {
return ! site.is_vip && ! ( site.jetpack && ! site.options.is_automated_transfer );
}

return site;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { get } from 'lodash';
import canCurrentUser from 'state/selectors/can-current-user';
import getSiteOptions from 'state/selectors/get-site-options';
import { isJetpackSite } from 'state/sites/selectors';
import isVipSite from 'state/selectors/is-vip-site';
import isAtomicSite from 'state/selectors/is-site-automated-transfer';
import { getSelectedSiteId } from 'state/ui/selectors';
import getSite from './get-site';
Expand All @@ -25,6 +26,10 @@ export default function canCurrentUserUseCustomerHome( state, siteId = null ) {
siteId = getSelectedSiteId( state );
}

if ( isVipSite( state, siteId ) ) {
return false;
}

if ( isJetpackSite( state, siteId ) && ! isAtomicSite( state, siteId ) ) {
return false;
}
Expand Down
25 changes: 23 additions & 2 deletions client/state/sites/test/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -3829,7 +3829,13 @@ describe( 'selectors', () => {
} );

describe( 'canCurrentUserUseCustomerHome()', () => {
const createState = ( { created_at, manage_options = true, jetpack = false } = {} ) => ( {
const createState = ( {
created_at,
manage_options = true,
jetpack = false,
vip = false,
atomic = false,
} = {} ) => ( {
ui: {
selectedSiteId: 1,
},
Expand All @@ -3844,7 +3850,8 @@ describe( 'selectors', () => {
items: {
1: {
jetpack,
options: { is_automated_transfer: false, created_at },
...( vip ? { is_vip: true } : {} ),
options: { is_automated_transfer: atomic, created_at },
},
},
},
Expand Down Expand Up @@ -3887,5 +3894,19 @@ describe( 'selectors', () => {
canCurrentUserUseCustomerHome( createState( { created_at: '2020-01-01', jetpack: true } ) )
).toBe( false );
} );

test( 'should return false for VIP site', () => {
expect(
canCurrentUserUseCustomerHome( createState( { created_at: '2020-01-01', vip: true } ) )
).toBe( false );
} );

test( 'should return true for Atomic site', () => {
expect(
canCurrentUserUseCustomerHome(
createState( { created_at: '2020-01-01', jetpack: true, atomic: true } )
)
).toBe( true );
} );
} );
} );

0 comments on commit d077255

Please sign in to comment.