Skip to content

Commit e2a1c06

Browse files
okmttdhrlsl
authored and
Jess Boctor
committed
Make Site Settings available to duplicate views experiment users (#98875)
* PoC * Tidy up the styles * /sites/settings/administration -> /sites/settings/site * Add "Admin interface style" to General Settings * Redirect /settings/general to /sites/settings/site * Hide settings sidebar for simple sites * Introduce `useRemoveDuplicateViewsExperimentEnabled` * Update flags * Update flags in controllers * Update flags in components * Fix type error * Remove Admin interface style Revert "Add "Admin interface style" to General Settings" This reverts commit b0caa4b. * Use PanelCard instead of HostingCard * Don't use wide Panel card * Proper switching b/w /hosting-feature <-> /hosting-config - Switching to Atomic while on /hosting-feature: Redirect to /hosting-config/:site - Switching to Simple while on /hosting-config: Redirect to /sites/settings/site/:site * Remove the notice for staging sites * Remove /settings/general -> /sites/settings/site redirection * Revert "Remove /settings/general -> /sites/settings/site redirection" This reverts commit 2d5d325. * Limit re-instated /settings/general/:site redirect to classic view only * Redirect if the user is not admin * Add redirects to wp-admin based on #98664 * Fix unexpected redirection to options-general.php * Redirect /settings to site settings if in treatment group * Remove redirects * Move settings redirects to local controller * Typo --------- Co-authored-by: Louis Laugesen <[email protected]>
1 parent 2336119 commit e2a1c06

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+471
-269
lines changed

client/controller/index.web.js

+12-4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { loadExperimentAssignment } from 'calypso/lib/explat';
2121
import { navigate } from 'calypso/lib/navigate';
2222
import { createAccountUrl, login } from 'calypso/lib/paths';
2323
import { CalypsoReactQueryDevtools } from 'calypso/lib/react-query-devtools-helper';
24+
import { getIsRemoveDuplicateViewsExperimentEnabled } from 'calypso/lib/remove-duplicate-views-experiment';
2425
import { addQueryArgs, getSiteFragment } from 'calypso/lib/route';
2526
import {
2627
getProductSlugFromContext,
@@ -312,12 +313,19 @@ export function redirectIfJetpackNonAtomic( context, next ) {
312313
* @param {Function} next Calls next middleware
313314
* @returns {void}
314315
*/
315-
export function redirectToHostingPromoIfNotAtomic( context, next ) {
316+
export async function redirectToHostingPromoIfNotAtomic( context, next ) {
316317
const state = context.store.getState();
317318
const site = getSelectedSite( state );
318319
const isAtomicSite = !! site?.is_wpcom_atomic || !! site?.is_wpcom_staging_site;
319320

320321
if ( ! isAtomicSite || site.plan?.expired ) {
322+
// Keep the user within the Settings tab
323+
const isRemoveDuplicateViewsExperimentEnabled =
324+
await getIsRemoveDuplicateViewsExperimentEnabled();
325+
if ( isRemoveDuplicateViewsExperimentEnabled ) {
326+
return page.redirect( '/sites/settings/site/' + context.params.site_id );
327+
}
328+
321329
return page.redirect( `/hosting-features/${ site?.slug }` );
322330
}
323331

@@ -395,11 +403,11 @@ export const ssrSetupLocale = ( _context, next ) => {
395403
};
396404

397405
export const redirectIfDuplicatedView = ( wpAdminPath ) => async ( context, next ) => {
398-
const experimentName = 'calypso_post_onboarding_holdout_160125';
399406
const aaTestName = 'calypso_post_onboarding_aa_150125';
400407

401408
loadExperimentAssignment( aaTestName );
402-
const duplicateViewsExperimentAssignment = await loadExperimentAssignment( experimentName );
409+
const isRemoveDuplicateViewsExperimentEnabled =
410+
await getIsRemoveDuplicateViewsExperimentEnabled();
403411

404412
const overrideAssignment = getPreference(
405413
context.store.getState(),
@@ -411,7 +419,7 @@ export const redirectIfDuplicatedView = ( wpAdminPath ) => async ( context, next
411419
return;
412420
}
413421

414-
if ( isE2ETest() || duplicateViewsExperimentAssignment.variationName === 'treatment' ) {
422+
if ( isE2ETest() || isRemoveDuplicateViewsExperimentEnabled ) {
415423
const state = context.store.getState();
416424
const siteId = getSelectedSiteId( state );
417425
const wpAdminUrl = getSiteAdminUrl( state, siteId, wpAdminPath );

client/hosting/overview/controller.tsx

+25-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import i18n from 'i18n-calypso';
44
import HostingActivate from 'calypso/hosting/server-settings/hosting-activate';
55
import Hosting from 'calypso/hosting/server-settings/main';
66
import PageViewTracker from 'calypso/lib/analytics/page-view-tracker';
7+
import { getIsRemoveDuplicateViewsExperimentEnabled } from 'calypso/lib/remove-duplicate-views-experiment';
8+
import { PanelWithSidebar } from 'calypso/sites/components/panel-sidebar';
79
import HostingOverview from 'calypso/sites/overview/components/hosting-overview';
10+
import { SettingsSidebar } from 'calypso/sites/settings/controller';
811
import { successNotice } from 'calypso/state/notices/actions';
912

1013
export function hostingOverview( context: PageJSContext, next: () => void ) {
@@ -17,7 +20,7 @@ export function hostingOverview( context: PageJSContext, next: () => void ) {
1720
next();
1821
}
1922

20-
export function hostingConfiguration( context: PageJSContext, next: () => void ) {
23+
export async function hostingConfiguration( context: PageJSContext, next: () => void ) {
2124
// Update the url and show the notice after a redirect
2225
if ( context.query && context.query.hosting_features === 'activated' ) {
2326
context.store.dispatch(
@@ -32,16 +35,34 @@ export function hostingConfiguration( context: PageJSContext, next: () => void )
3235
removeQueryArgs( window.location.href, 'hosting_features' )
3336
);
3437
}
35-
context.primary = (
38+
const isRemoveDuplicateViewsExperimentEnabled =
39+
await getIsRemoveDuplicateViewsExperimentEnabled();
40+
context.primary = isRemoveDuplicateViewsExperimentEnabled ? (
41+
<PanelWithSidebar>
42+
<SettingsSidebar />
43+
<div className="hosting-configuration">
44+
<Hosting />
45+
</div>
46+
</PanelWithSidebar>
47+
) : (
3648
<div className="hosting-configuration">
3749
<Hosting />
3850
</div>
3951
);
4052
next();
4153
}
4254

43-
export function hostingActivate( context: PageJSContext, next: () => void ) {
44-
context.primary = (
55+
export async function hostingActivate( context: PageJSContext, next: () => void ) {
56+
const isRemoveDuplicateViewsExperimentEnabled =
57+
await getIsRemoveDuplicateViewsExperimentEnabled();
58+
context.primary = isRemoveDuplicateViewsExperimentEnabled ? (
59+
<PanelWithSidebar>
60+
<SettingsSidebar />
61+
<div className="hosting-configuration">
62+
<HostingActivate />
63+
</div>
64+
</PanelWithSidebar>
65+
) : (
4566
<div className="hosting-configuration">
4667
<HostingActivate />
4768
</div>

client/hosting/server-settings/main.tsx

+64-37
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ import { SftpCard } from 'calypso/hosting/server-settings/components/sftp-card/c
2626
import HostingActivateStatus from 'calypso/hosting/server-settings/hosting-activate-status';
2727
import PageViewTracker from 'calypso/lib/analytics/page-view-tracker';
2828
import TrackComponentView from 'calypso/lib/analytics/track-component-view';
29+
import { useRemoveDuplicateViewsExperimentEnabled } from 'calypso/lib/remove-duplicate-views-experiment';
2930
import { TrialAcknowledgeModal } from 'calypso/my-sites/plans/trials/trial-acknowledge/acknowlege-modal';
3031
import { WithOnclickTrialRequest } from 'calypso/my-sites/plans/trials/trial-acknowledge/with-onclick-trial-request';
3132
import TrialBanner from 'calypso/my-sites/plans/trials/trial-banner';
3233
import JetpackMonitor from 'calypso/my-sites/site-settings/form-jetpack-monitor';
33-
import SiteAdminInterface from 'calypso/my-sites/site-settings/site-admin-interface';
3434
import CacheCard from 'calypso/sites/settings/caching/form';
3535
import DefensiveModeCard from 'calypso/sites/settings/web-server/defensive-mode-form';
3636
import WebServerSettingsCard from 'calypso/sites/settings/web-server/server-configuration-form';
@@ -109,7 +109,6 @@ const AllCards = ( {
109109
isAdvancedHostingDisabled,
110110
isBasicHostingDisabled,
111111
siteId,
112-
siteSlug,
113112
isJetpack,
114113
}: AllCardsProps ) => {
115114
const allCards: CardEntry[] = [
@@ -135,14 +134,6 @@ const AllCards = ( {
135134
},
136135
];
137136

138-
if ( siteId ) {
139-
allCards.push( {
140-
feature: 'wp-admin',
141-
content: <SiteAdminInterface siteId={ siteId } siteSlug={ siteSlug } isHosting />,
142-
type: 'basic',
143-
} );
144-
}
145-
146137
if ( config.isEnabled( 'hosting-server-settings-enhancements' ) ) {
147138
allCards.push( {
148139
feature: 'defensive-mode',
@@ -177,6 +168,53 @@ const AllCards = ( {
177168
return <ShowEnabledFeatureCards cards={ allCards } availableTypes={ availableTypes } />;
178169
};
179170

171+
const InnerDiv = ( { children }: { children: React.ReactNode } ) => <>{ children }</>;
172+
173+
const Content = ( {
174+
hasAtomicFeature,
175+
hasSftpFeature,
176+
hasTransfer,
177+
isBusinessTrial,
178+
isRemoveDuplicateViewsExperimentEnabled,
179+
isJetpack,
180+
isSiteAtomic,
181+
siteId,
182+
siteSlug,
183+
}: {
184+
hasAtomicFeature: boolean;
185+
hasSftpFeature: boolean;
186+
hasTransfer: boolean;
187+
isBusinessTrial: boolean;
188+
isRemoveDuplicateViewsExperimentEnabled: boolean;
189+
isJetpack: boolean | null;
190+
isSiteAtomic: boolean;
191+
siteId: number | null;
192+
siteSlug: string | null;
193+
} ) => {
194+
const WrapperComponent = ! isSiteAtomic ? FeatureExample : Fragment;
195+
196+
const Inner = isRemoveDuplicateViewsExperimentEnabled ? InnerDiv : MasonryGrid;
197+
198+
return (
199+
<>
200+
{ isSiteAtomic && <QuerySites siteId={ siteId } /> }
201+
{ isJetpack && siteId && <QueryJetpackModules siteId={ siteId } /> }
202+
<WrapperComponent>
203+
<Inner>
204+
<AllCards
205+
isAdvancedHostingDisabled={ ! hasSftpFeature || ! isSiteAtomic }
206+
isBasicHostingDisabled={ ! hasAtomicFeature || ! isSiteAtomic }
207+
isBusinessTrial={ isBusinessTrial && ! hasTransfer }
208+
siteId={ siteId }
209+
siteSlug={ siteSlug }
210+
isJetpack={ isJetpack }
211+
/>
212+
</Inner>
213+
</WrapperComponent>
214+
</>
215+
);
216+
};
217+
180218
type ServerSettingsProps = {
181219
fetchUpdatedData: () => void;
182220
};
@@ -185,6 +223,8 @@ const ServerSettings = ( { fetchUpdatedData }: ServerSettingsProps ) => {
185223
const translate = useTranslate();
186224
const dispatch = useDispatch();
187225

226+
const isRemoveDuplicateViewsExperimentEnabled = useRemoveDuplicateViewsExperimentEnabled();
227+
188228
const clickActivate = () =>
189229
dispatch( recordTracksEvent( 'calypso_hosting_configuration_activate_click' ) );
190230

@@ -236,11 +276,11 @@ const ServerSettings = ( { fetchUpdatedData }: ServerSettingsProps ) => {
236276
fetchUpdatedData();
237277
}
238278
},
239-
[ hasTransfer ]
279+
[ fetchUpdatedData, hasTransfer ]
240280
);
241281

242282
const getPageTitle = () => {
243-
return translate( 'Server Settings' );
283+
return translate( 'Server settings' );
244284
};
245285

246286
const getUpgradeBanner = () => {
@@ -278,29 +318,6 @@ const ServerSettings = ( { fetchUpdatedData }: ServerSettingsProps ) => {
278318
}
279319
};
280320

281-
const getContent = () => {
282-
const WrapperComponent = ! isSiteAtomic ? FeatureExample : Fragment;
283-
284-
return (
285-
<>
286-
{ isSiteAtomic && <QuerySites siteId={ siteId } /> }
287-
{ isJetpack && siteId && <QueryJetpackModules siteId={ siteId } /> }
288-
<WrapperComponent>
289-
<MasonryGrid>
290-
<AllCards
291-
isAdvancedHostingDisabled={ ! hasSftpFeature || ! isSiteAtomic }
292-
isBasicHostingDisabled={ ! hasAtomicFeature || ! isSiteAtomic }
293-
isBusinessTrial={ isBusinessTrial && ! hasTransfer }
294-
siteId={ siteId }
295-
siteSlug={ siteSlug }
296-
isJetpack={ isJetpack }
297-
/>
298-
</MasonryGrid>
299-
</WrapperComponent>
300-
</>
301-
);
302-
};
303-
304321
/* We want to show the upsell banner for the following cases:
305322
* 1. The site is on an eCommerce trial.
306323
* 2. The site does not have the Atomic feature.
@@ -317,7 +334,7 @@ const ServerSettings = ( { fetchUpdatedData }: ServerSettingsProps ) => {
317334
}
318335

319336
return (
320-
<Panel wide className="page-server-settings">
337+
<Panel wide={ ! isRemoveDuplicateViewsExperimentEnabled } className="page-server-settings">
321338
{ ! isLoadingSftpData && (
322339
<ScrollToAnchorOnMount
323340
offset={ HEADING_OFFSET }
@@ -352,7 +369,17 @@ const ServerSettings = ( { fetchUpdatedData }: ServerSettingsProps ) => {
352369
}
353370
/>
354371
) }
355-
{ getContent() }
372+
<Content
373+
hasAtomicFeature={ hasAtomicFeature }
374+
hasSftpFeature={ hasSftpFeature }
375+
hasTransfer={ hasTransfer }
376+
isBusinessTrial={ isBusinessTrial }
377+
isRemoveDuplicateViewsExperimentEnabled={ isRemoveDuplicateViewsExperimentEnabled }
378+
isJetpack={ isJetpack }
379+
isSiteAtomic={ isSiteAtomic }
380+
siteId={ siteId }
381+
siteSlug={ siteSlug }
382+
/>
356383
{ isEligibleForHostingTrial && isTrialAcknowledgeModalOpen && (
357384
<TrialAcknowledgeModal
358385
setOpenModal={ ( isOpen ) => {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { useEffect, useState } from 'react';
2+
import { loadExperimentAssignment } from 'calypso/lib/explat';
3+
4+
const EXPERIMENT_NAME = 'calypso_post_onboarding_holdout_160125';
5+
6+
export const getIsRemoveDuplicateViewsExperimentEnabled = async (): Promise< boolean > => {
7+
const experimentAssignment = await loadExperimentAssignment( EXPERIMENT_NAME );
8+
return experimentAssignment?.variationName === 'treatment';
9+
};
10+
11+
export const useRemoveDuplicateViewsExperimentEnabled = (): boolean => {
12+
const [ isRemoveDuplicateViewsExperimentEnabled, setIsRemoveDuplicateViewsExperimentEnabled ] =
13+
useState( false );
14+
15+
useEffect( () => {
16+
getIsRemoveDuplicateViewsExperimentEnabled().then( setIsRemoveDuplicateViewsExperimentEnabled );
17+
}, [] );
18+
19+
return isRemoveDuplicateViewsExperimentEnabled;
20+
};

client/my-sites/site-settings/form-general.jsx

+17-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { isEnabled } from '@automattic/calypso-config';
21
import { Card, Button, FormLabel, Gridicon } from '@automattic/components';
32
import { guessTimezone, localizeUrl } from '@automattic/i18n-utils';
43
import languages from '@automattic/languages';
@@ -15,6 +14,7 @@ import SiteLanguagePicker from 'calypso/components/language-picker/site-language
1514
import Notice from 'calypso/components/notice';
1615
import NoticeAction from 'calypso/components/notice/notice-action';
1716
import Timezone from 'calypso/components/timezone';
17+
import { getIsRemoveDuplicateViewsExperimentEnabled } from 'calypso/lib/remove-duplicate-views-experiment';
1818
import scrollToAnchor from 'calypso/lib/scroll-to-anchor';
1919
import { domainManagementEdit } from 'calypso/my-sites/domains/paths';
2020
import SettingsSectionHeader from 'calypso/my-sites/site-settings/settings-section-header';
@@ -40,8 +40,22 @@ import SiteIconSetting from './site-icon-setting';
4040
import wrapSettingsForm from './wrap-settings-form';
4141

4242
export class SiteSettingsFormGeneral extends Component {
43+
state = {
44+
isRemoveDuplicateViewsExperimentEnabled: false,
45+
};
46+
4347
componentDidMount() {
4448
setTimeout( () => scrollToAnchor( { offset: 15 } ) );
49+
getIsRemoveDuplicateViewsExperimentEnabled().then(
50+
( isRemoveDuplicateViewsExperimentEnabled ) => {
51+
if (
52+
this.state.isRemoveDuplicateViewsExperimentEnabled !==
53+
isRemoveDuplicateViewsExperimentEnabled
54+
) {
55+
this.setState( { isRemoveDuplicateViewsExperimentEnabled } );
56+
}
57+
}
58+
);
4559
}
4660

4761
getIncompleteLocaleNoticeMessage = ( language ) => {
@@ -382,6 +396,7 @@ export class SiteSettingsFormGeneral extends Component {
382396
translate,
383397
adminInterfaceIsWPAdmin,
384398
} = this.props;
399+
const { isRemoveDuplicateViewsExperimentEnabled } = this.state;
385400
const classes = clsx( 'site-settings__general-settings', {
386401
'is-loading': isRequestingSettings,
387402
} );
@@ -418,7 +433,7 @@ export class SiteSettingsFormGeneral extends Component {
418433
</Card>
419434
</>
420435
) }
421-
{ ! isEnabled( 'untangling/hosting-menu' ) && <SiteSettingsForm { ...this.props } /> }
436+
{ ! isRemoveDuplicateViewsExperimentEnabled && <SiteSettingsForm { ...this.props } /> }
422437
{ ! isDevelopmentSite && this.renderAdminInterface() }
423438
</div>
424439
);

0 commit comments

Comments
 (0)