Skip to content

Commit

Permalink
Hosting Configuration: Avoid accessing “Server Settings” to the “Host…
Browse files Browse the repository at this point in the history
…ing Features” if the plan is expired (#94106)

* Hosting Configuration: Rename the menu title under the settings

* Hosting Configuration: Redirect to Hosting Features if the plan is expired
  • Loading branch information
arthur791004 authored Sep 3, 2024
1 parent d9e847a commit b0e9f18
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion client/controller/index.web.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ export function redirectToHostingPromoIfNotAtomic( context, next ) {
const site = getSelectedSite( state );
const isAtomicSite = !! site?.is_wpcom_atomic || !! site?.is_wpcom_staging_site;

if ( ! isAtomicSite ) {
if ( ! isAtomicSite || site.plan?.expired ) {
return page.redirect( `/hosting-features/${ site?.slug }` );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ const HostingFeatures = () => {
// `siteTransferData?.isTransferring` is not a fully reliable indicator by itself, which is why
// we also look at `siteTransferData.status`
const isTransferInProgress =
siteTransferData?.isTransferring || siteTransferData?.status === transferStates.COMPLETED;
( siteTransferData?.isTransferring || siteTransferData?.status === transferStates.COMPLETED ) &&
! isPlanExpired;

useEffect( () => {
if ( ! siteId ) {
Expand Down
7 changes: 6 additions & 1 deletion client/my-sites/sidebar/static-data/fallback-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const WOOCOMMERCE_ICON = `data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3

export default function buildFallbackResponse( {
siteDomain = '',
isAtomic,
isPlanExpired,
shouldShowMailboxes = false,
shouldShowLinks = false,
shouldShowTestimonials = false,
Expand Down Expand Up @@ -600,7 +602,10 @@ export default function buildFallbackResponse( {
{
parent: 'options-general.php',
slug: 'options-hosting-configuration-php',
title: translate( 'Hosting Configuration' ),
title:
isAtomic && ! isPlanExpired
? translate( 'Server Settings' )
: translate( 'Hosting Features' ),
type: 'submenu-item',
url: `/hosting-config/${ siteDomain }`,
},
Expand Down
5 changes: 4 additions & 1 deletion client/my-sites/sidebar/use-site-menu-items.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import isAtomicSite from 'calypso/state/selectors/is-site-automated-transfer';
import isSiteWpcomStaging from 'calypso/state/selectors/is-site-wpcom-staging';
import isSiteWPForTeams from 'calypso/state/selectors/is-site-wpforteams';
import { getSiteDomain, isJetpackSite } from 'calypso/state/sites/selectors';
import { getSelectedSiteId } from 'calypso/state/ui/selectors';
import { getSelectedSite, getSelectedSiteId } from 'calypso/state/ui/selectors';
import { requestAdminMenu } from '../../state/admin-menu/actions';
import allSitesMenu from './static-data/all-sites-menu';
import buildFallbackResponse from './static-data/fallback-menu';
Expand All @@ -32,6 +32,7 @@ const useSiteMenuItems = () => {
const isJetpack = useSelector( ( state ) => isJetpackSite( state, selectedSiteId ) );
const isAtomic = useSelector( ( state ) => isAtomicSite( state, selectedSiteId ) );
const isStagingSite = useSelector( ( state ) => isSiteWpcomStaging( state, selectedSiteId ) );
const isPlanExpired = useSelector( ( state ) => !! getSelectedSite( state )?.plan?.expired );
const locale = useLocale();
const isAllDomainsView = '/domains/manage' === currentRoute;
const { currentSection } = useCurrentRoute();
Expand Down Expand Up @@ -109,6 +110,8 @@ const useSiteMenuItems = () => {
*/
const fallbackDataOverrides = {
siteDomain,
isAtomic,
isPlanExpired,
shouldShowWooCommerce,
shouldShowThemes,
shouldShowMailboxes,
Expand Down

0 comments on commit b0e9f18

Please sign in to comment.