Skip to content

Commit

Permalink
StatsNavigation: control the visibility of video module itself
Browse files Browse the repository at this point in the history
  • Loading branch information
macbre committed Dec 3, 2024
1 parent 0a656d4 commit c860751
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 6 additions & 1 deletion client/blocks/stats-navigation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class StatsNavigation extends Component {
};

static getDerivedStateFromProps( nextProps, prevState ) {
const availableModuleToggles = AVAILABLE_PAGE_MODULES[ nextProps.selectedItem ].map(
const availableModuleToggles = ( AVAILABLE_PAGE_MODULES[ nextProps.selectedItem ] || [] ).map(
( toggleItem ) => {
// disable the "videos" toggle on sites that do not have VideoPress enabled
// the toggle will be disabled (grayed out and non interactive)
Expand All @@ -101,6 +101,11 @@ class StatsNavigation extends Component {
}
);

// toggle the visibility of video module itself
if ( ! nextProps.hasVideoPress ) {
nextProps.pageModuleToggles.videos = false;
}

if (
prevState.pageModules !== nextProps.pageModuleToggles ||
prevState.availableModuleToggles !== nextProps.availableModuleToggles
Expand Down
6 changes: 1 addition & 5 deletions client/my-sites/stats/site.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import getCurrentRouteParameterized from 'calypso/state/selectors/get-current-ro
import isJetpackModuleActive from 'calypso/state/selectors/is-jetpack-module-active';
import isPrivateSite from 'calypso/state/selectors/is-private-site';
import isAtomicSite from 'calypso/state/selectors/is-site-wpcom-atomic';
import siteHasFeature from 'calypso/state/selectors/site-has-feature';
import { getJetpackStatsAdminVersion, isJetpackSite } from 'calypso/state/sites/selectors';
import getEnvStatsFeatureSupportChecks from 'calypso/state/sites/selectors/get-env-stats-feature-supports';
import { requestModuleSettings } from 'calypso/state/stats/module-settings/actions';
Expand Down Expand Up @@ -310,7 +309,6 @@ class StatsSite extends Component {
supportUserFeedback,
momentSiteZone,
wpcomShowUpsell,
hasVideoPress,
} = this.props;
const isNewDateFilteringEnabled = config.isEnabled( 'stats/new-date-filtering' ) || isInternal;
let defaultPeriod = PAST_SEVEN_DAYS;
Expand Down Expand Up @@ -670,7 +668,7 @@ class StatsSite extends Component {
className={ halfWidthModuleClasses }
/>

{ hasVideoPress && ! this.isModuleHidden( 'videos' ) && (
{ ! this.isModuleHidden( 'videos' ) && (
<StatsModuleVideos
moduleStrings={ moduleStrings.videoplays }
period={ this.props.period }
Expand Down Expand Up @@ -845,7 +843,6 @@ export default connect(
const isJetpack = isJetpackSite( state, siteId );
const statsAdminVersion = getJetpackStatsAdminVersion( state, siteId );
const isOdysseyStats = config.isEnabled( 'is_running_in_jetpack_site' );
const hasVideoPress = siteHasFeature( state, siteId, 'videopress' );

// Odyssey Stats: This UX is not possible in Odyssey as this page would not be able to render in the first place.
const showEnableStatsModule =
Expand Down Expand Up @@ -908,7 +905,6 @@ export default connect(
shouldForceDefaultDateRange,
momentSiteZone: getMomentSiteZone( state, siteId ),
wpcomShowUpsell,
hasVideoPress,
};
},
{
Expand Down

0 comments on commit c860751

Please sign in to comment.