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

Try new earn/stats/marketing navigation structure #76970

Draft
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Draft
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
16 changes: 16 additions & 0 deletions client/blocks/stats-navigation/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ const insights = {
path: '/stats/insights',
showIntervals: false,
} as NavItem;
const email = {
label: translate( 'Email' ),
path: '/stats/day/email',
showIntervals: false,
} as NavItem;
const earn = {
label: translate( 'Earn' ),
path: '/stats/earn',
showIntervals: false,
} as NavItem;
// TODO: Consider adding subscriber counts into this nav item in the future.
// See client/blocks/subscribers-count/index.jsx.
const subscribers = {
Expand Down Expand Up @@ -60,13 +70,17 @@ export interface NavItems {
store: NavItem;
wordads: NavItem;
googleMyBusiness: NavItem;
earn?: NavItem;
subscribers?: NavItem;
email?: NavItem;
}

const assembleNavItems = () => {
const navItems = {
traffic,
insights,
earn,
email,
store,
wordads,
googleMyBusiness,
Expand All @@ -92,6 +106,8 @@ Object.defineProperty( year, 'label', { get: () => translate( 'Years' ) } );

Object.defineProperty( traffic, 'label', { get: () => translate( 'Traffic' ) } );
Object.defineProperty( insights, 'label', { get: () => translate( 'Insights' ) } );
Object.defineProperty( earn, 'label', { get: () => translate( 'Earn' ) } );
Object.defineProperty( email, 'label', { get: () => translate( 'Email' ) } );
Object.defineProperty( store, 'label', { get: () => translate( 'Store' ) } );
Object.defineProperty( wordads, 'label', { get: () => translate( 'Ads' ) } );
Object.defineProperty( googleMyBusiness, 'label', {
Expand Down
2 changes: 1 addition & 1 deletion client/my-sites/activity/activity-log/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ class ActivityLog extends Component {
<FormattedHeader
brandFont
className="activity-log__page-heading"
headerText={ translate( 'Activity' ) }
headerText={ translate( 'Jetpack Activity Log' ) }
subHeaderText={ translate(
"Keep tabs on all your site's activity — plugin and theme updates, user logins, " +
'setting modifications, and more.'
Expand Down
2 changes: 1 addition & 1 deletion client/my-sites/earn/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class EarningsMain extends Component {
<FormattedHeader
brandFont
className="earn__page-header"
headerText={ translate( 'Earn' ) }
headerText={ translate( 'Monetization' ) }
subHeaderText={ translate(
'Explore tools to earn money with your site. {{learnMoreLink}}Learn more{{/learnMoreLink}}.',
{
Expand Down
15 changes: 0 additions & 15 deletions client/my-sites/marketing/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import NavItem from 'calypso/components/section-nav/item';
import NavTabs from 'calypso/components/section-nav/tabs';
import { canCurrentUser } from 'calypso/state/selectors/can-current-user';
import isSiteP2Hub from 'calypso/state/selectors/is-site-p2-hub';
import isSiteWpcomAtomic from 'calypso/state/selectors/is-site-wpcom-atomic';
import isVipSite from 'calypso/state/selectors/is-vip-site';
import { getSiteSlug, isJetpackSite } from 'calypso/state/sites/selectors';
import { getSelectedSiteId } from 'calypso/state/ui/selectors';
Expand All @@ -27,7 +26,6 @@ export const Sharing = ( {
showButtons,
showConnections,
showTraffic,
showBusinessTools,
siteId,
isJetpack,
isP2Hub,
Expand Down Expand Up @@ -105,16 +103,6 @@ export const Sharing = ( {
} );
}

// Include Business Tools link if a site is selected and the
// site is not VIP
if ( ! isVip && showBusinessTools ) {
filters.push( {
id: 'business-buttons',
route: '/marketing/business-tools' + pathSuffix,
title: translate( 'Business Tools' ),
} );
}

// For p2 hub sites show only connections tab
let titleHeader = translate( 'Marketing and Integrations' );

Expand Down Expand Up @@ -178,7 +166,6 @@ Sharing.propTypes = {
path: PropTypes.string,
showButtons: PropTypes.bool,
showConnections: PropTypes.bool,
showBusinessTools: PropTypes.bool,
siteId: PropTypes.number,
siteSlug: PropTypes.string,
translate: PropTypes.func,
Expand All @@ -187,15 +174,13 @@ Sharing.propTypes = {
export default connect( ( state ) => {
const siteId = getSelectedSiteId( state );
const isJetpack = isJetpackSite( state, siteId );
const isAtomic = isSiteWpcomAtomic( state, siteId );
const canManageOptions = canCurrentUser( state, siteId, 'manage_options' );

return {
isP2Hub: isSiteP2Hub( state, siteId ),
showButtons: siteId && canManageOptions,
showConnections: !! siteId,
showTraffic: canManageOptions && !! siteId,
showBusinessTools: ( !! siteId && canManageOptions && ! isJetpack ) || isAtomic,
isVip: isVipSite( state, siteId ),
siteId,
siteSlug: getSiteSlug( state, siteId ),
Expand Down
155 changes: 114 additions & 41 deletions client/my-sites/sidebar/static-data/fallback-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,43 @@ export default function buildFallbackResponse( {
title: translate( 'Stats' ),
type: 'menu-item',
url: `/stats/day/${ siteDomain }`,
children: [
{
parent: 'stats',
slug: 'stats-traffic',
title: translate( 'Traffic' ),
type: 'menu-item',
url: `/stats/day/${ siteDomain }`,
},
{
parent: 'stats',
slug: 'stats-insights',
title: translate( 'Insights' ),
type: 'menu-item',
url: `/stats/insights/${ siteDomain }`,
},
{
parent: 'stats',
slug: 'stats-earn',
title: translate( 'Earn' ),
type: 'menu-item',
url: `/stats/earn/${ siteDomain }`,
},
{
parent: 'stats',
slug: 'stats-subscribers',
title: translate( 'Subscribers' ),
type: 'menu-item',
url: `/stats/subscribers/${ siteDomain }`,
},
{
parent: 'stats',
slug: 'stats-email',
title: translate( 'Email' ),
type: 'menu-item',
url: `/stats/email/${ siteDomain }`,
},
],
},
{
icon: 'dashicons-cart',
Expand Down Expand Up @@ -296,15 +333,22 @@ export default function buildFallbackResponse( {
},
{
icon: 'dashicons-feedback',
slug: 'feedback',
title: translate( 'Feedback' ),
slug: 'communication',
title: translate( 'Communication' ),
type: 'menu-item',
url: `https://${ siteDomain }/wp-admin/?page=feedback`,
children: [
{
parent: 'marketing.php',
slug: 'marketing-subscribers',
title: translate( 'Subscribers' ),
type: 'submenu-item',
url: `/people/subscribers/${ siteDomain }`,
},
{
parent: 'feedback',
slug: 'edit-phppost_typefeedback',
title: translate( 'Feedback' ),
title: translate( 'Form submissions' ),
type: 'submenu-item',
url: `https://${ siteDomain }/wp-admin/edit.php?post_type=feedback`,
},
Expand All @@ -324,35 +368,6 @@ export default function buildFallbackResponse( {
},
],
},
{
type: 'separator',
},
{
icon: JETPACK_ICON,
slug: 'jetpack',
title: translate( 'Jetpack' ),
type: 'menu-item',
url: `/activity-log/${ siteDomain }`,
children: [
{
parent: 'jetpack',
slug: 'jetpack-activity-log',
title: translate( 'Activity Log' ),
type: 'submenu-item',
url: `/activity-log/${ siteDomain }`,
},
{
parent: 'jetpack',
slug: 'jetpack-backup',
title: translate( 'VaultPress Backup' ),
type: 'submenu-item',
url: `/backup/${ siteDomain }`,
},
],
},
{
type: 'separator',
},
// Add WooCommerce here
...( shouldShowWooCommerce
? [
Expand Down Expand Up @@ -477,26 +492,84 @@ export default function buildFallbackResponse( {
],
},
{
icon: 'dashicons-admin-tools',
slug: 'tools-php',
title: translate( 'Tools' ),
icon: JETPACK_ICON,
slug: 'marketing-php',
title: translate( 'Marketing' ),
type: 'menu-item',
url: `/marketing/tools/${ siteDomain }`,
children: [
{
parent: 'tools.php',
slug: 'tools-marketing',
title: translate( 'Marketing' ),
parent: 'marketing.php',
slug: 'marketing-home',
title: translate( 'Marketing home' ),
type: 'menu-item',
url: `/marketing/tools/${ siteDomain }`,
},
{
parent: 'tools.php',
slug: 'tools-earn',
title: translate( 'Earn' ),
parent: 'marketing.php',
slug: 'marketing-monetization',
title: translate( 'Monetization' ),
type: 'menu-item',
url: `/earn/${ siteDomain }`,
},
{
parent: 'marketing.php',
slug: 'marketing-subscribers',
title: translate( 'Subscribers' ),
type: 'submenu-item',
url: `/people/subscribers/${ siteDomain }`,
},
{
parent: 'marketing.php',
slug: 'marketing-traffic',
title: translate( 'Traffic' ),
type: 'menu-item',
url: `/marketing/traffic/${ siteDomain }`,
},
{
parent: 'marketing.php',
slug: 'marketing-connections',
title: translate( 'Connections' ),
type: 'menu-item',
url: `/marketing/connections/${ siteDomain }`,
},
{
parent: 'marketing.php',
slug: 'marketing-marketing',
title: translate( 'Sharing buttons' ),
type: 'menu-item',
url: `/marketing/sharing-buttons/${ siteDomain }`,
},
{
parent: 'marketing.php',
slug: 'tools-advertising',
title: translate( 'Advertising' ),
type: 'submenu-item',
url: `/advertising/${ siteDomain }`,
},
],
},
{
icon: 'dashicons-admin-tools',
slug: 'tools-php',
title: translate( 'Tools' ),
type: 'menu-item',
url: `/marketing/tools/${ siteDomain }`,
children: [
{
parent: 'jetpack',
slug: 'jetpack-activity-log',
title: translate( 'Activity Log' ),
type: 'submenu-item',
url: `/activity-log/${ siteDomain }`,
},
{
parent: 'jetpack',
slug: 'jetpack-backup',
title: translate( 'VaultPress Backup' ),
type: 'submenu-item',
url: `/backup/${ siteDomain }`,
},
{
parent: 'tools.php',
slug: 'tools-import',
Expand Down
3 changes: 2 additions & 1 deletion client/my-sites/sidebar/use-site-menu-items.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ const useSiteMenuItems = () => {
showSiteLogs: isAtomic,
};

return menuItems ?? buildFallbackResponse( fallbackDataOverrides );
// return menuItems ?? buildFallbackResponse( fallbackDataOverrides );
return buildFallbackResponse( fallbackDataOverrides );
};

export default useSiteMenuItems;
7 changes: 7 additions & 0 deletions client/my-sites/stats/controller.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,13 @@ export function insights( context, next ) {
next();
}

export function earn( context, next ) {
context.primary = (
<AsyncLoad require="calypso/my-sites/stats/stats-earn" placeholder={ PageLoading } />
);
next();
}

export function subscribers( context, next ) {
const givenSiteId = context.params.site;
const filters = getSiteFilters( givenSiteId );
Expand Down
7 changes: 6 additions & 1 deletion client/my-sites/stats/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { navigation, siteSelection, sites } from 'calypso/my-sites/controller';
import {
follows,
insights,
earn,
overview,
post,
site,
Expand Down Expand Up @@ -55,6 +56,10 @@ export default function () {
// Stat Insights Page
statsPage( '/stats/insights/:site', insights );

// Stat Earn Page
statsPage( '/stats/earn', sites );
statsPage( '/stats/earn/:site', earn );

if ( config.isEnabled( 'stats/subscribers-section' ) ) {
// Stat Subscribers Page (do not cofuse with people/subscribers/)
statsPage( '/stats/subscribers/:site', subscribers );
Expand Down Expand Up @@ -93,7 +98,7 @@ export default function () {
`/stats/email/:statType/:period(${ validEmailPeriods })/:email_id/:site`,
emailStats
);
statsPage( `/stats/day/emails/:site`, emailSummary );
statsPage( '/stats/day/emails/:site', emailSummary );
}

// Anything else should redirect to default stats page
Expand Down
Loading