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

Stats: Refactor Insights page away from connect pattern #99472

Merged
merged 1 commit into from
Feb 9, 2025
Merged
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
22 changes: 8 additions & 14 deletions client/my-sites/stats/pages/insights/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import config from '@automattic/calypso-config';
import clsx from 'clsx';
import { useTranslate } from 'i18n-calypso';
import { useEffect } from 'react';
import { connect, useDispatch } from 'react-redux';
import { useDispatch } from 'react-redux';
import StatsNavigation from 'calypso/blocks/stats-navigation';
import { navItems } from 'calypso/blocks/stats-navigation/constants';
import DocumentHead from 'calypso/components/data/document-head';
Expand All @@ -15,6 +15,7 @@ import StatShares from 'calypso/my-sites/stats/features/modules/stats-shares';
import StatsModuleTags from 'calypso/my-sites/stats/features/modules/stats-tags';
import usePlanUsageQuery from 'calypso/my-sites/stats/hooks/use-plan-usage-query';
import { useShouldGateStats } from 'calypso/my-sites/stats/hooks/use-should-gate-stats';
import { useSelector } from 'calypso/state';
import { STATS_PLAN_USAGE_RECEIVE } from 'calypso/state/action-types';
import { isJetpackSite } from 'calypso/state/sites/selectors';
import { getSelectedSiteId, getSelectedSiteSlug } from 'calypso/state/ui/selectors';
Expand All @@ -28,8 +29,10 @@ import statsStrings from '../../stats-strings';
import StatsUpsell from '../../stats-upsell/insights-upsell';
import StatsModuleListing from '../shared/stats-module-listing';

const StatsInsights = ( props ) => {
const { siteId, siteSlug, isJetpack } = props;
function StatsInsights() {
const siteId = useSelector( ( state ) => getSelectedSiteId( state ) );
const siteSlug = useSelector( ( state ) => getSelectedSiteSlug( state, siteId ) );
const isJetpack = useSelector( ( state ) => isJetpackSite( state, siteId ) );
const translate = useTranslate();
const moduleStrings = statsStrings();
const isEmptyStateV2 = config.isEnabled( 'stats/empty-module-v2' );
Expand Down Expand Up @@ -138,15 +141,6 @@ const StatsInsights = ( props ) => {
</Main>
);
/* eslint-enable wpcalypso/jsx-classname-namespace */
};
}

const connectComponent = connect( ( state ) => {
const siteId = getSelectedSiteId( state );
return {
siteId,
siteSlug: getSelectedSiteSlug( state, siteId ),
isJetpack: isJetpackSite( state, siteId ),
};
} );

export default connectComponent( StatsInsights );
export default StatsInsights;
Loading