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

Redirect admin interface from default to classic style #98664

Open
wants to merge 8 commits into
base: trunk
Choose a base branch
from
2 changes: 2 additions & 0 deletions client/controller/index.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,5 @@ export const notFound = () => null;
export const setSelectedSiteIdByOrigin = () => {};
// eslint-disable-next-line no-unused-vars
export const redirectIfDuplicatedView = ( wpAdminPath ) => () => {};
// eslint-disable-next-line no-unused-vars
export const redirectIfDuplicatedSettingsView = ( wpAdminPath ) => () => {};
36 changes: 24 additions & 12 deletions client/controller/index.web.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,20 +393,32 @@ export const ssrSetupLocale = ( _context, next ) => {
next();
};

const redirectToAdminView =
( wpAdminPath, experimentName, aaTestName ) => async ( context, next ) => {
if ( aaTestName ) {
loadExperimentAssignment( aaTestName );
}
const duplicateViewsExperimentAssignment = await loadExperimentAssignment( experimentName );
if ( isE2ETest() || duplicateViewsExperimentAssignment.variationName === 'treatment' ) {
const state = context.store.getState();
const siteId = getSelectedSiteId( state );
const wpAdminUrl = getSiteAdminUrl( state, siteId, wpAdminPath );
if ( wpAdminUrl ) {
window.location = wpAdminUrl;
return;
}
}
next();
};

export const redirectIfDuplicatedView = ( wpAdminPath ) => async ( context, next ) => {
const experimentName = 'calypso_post_onboarding_holdout_160125';
const aaTestName = 'calypso_post_onboarding_aa_150125';

loadExperimentAssignment( aaTestName );
const duplicateViewsExperimentAssignment = await loadExperimentAssignment( experimentName );
if ( isE2ETest() || duplicateViewsExperimentAssignment.variationName === 'treatment' ) {
const state = context.store.getState();
const siteId = getSelectedSiteId( state );
const wpAdminUrl = getSiteAdminUrl( state, siteId, wpAdminPath );
if ( wpAdminUrl ) {
window.location = wpAdminUrl;
return;
}
}
next();
await redirectToAdminView( wpAdminPath, experimentName, aaTestName )( context, next );
};

export const redirectIfDuplicatedSettingsView = ( wpAdminPath ) => async ( context, next ) => {
const experimentName = 'calypso_post_onboarding_holdout_160125';
await redirectToAdminView( wpAdminPath, experimentName )( context, next );
mmtr marked this conversation as resolved.
Show resolved Hide resolved
};
7 changes: 6 additions & 1 deletion client/my-sites/site-settings/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { isEnabled } from '@automattic/calypso-config';
import page from '@automattic/calypso-router';
import { get } from 'lodash';
import { makeLayout, render as clientRender } from 'calypso/controller';
import {
makeLayout,
render as clientRender,
redirectIfDuplicatedSettingsView,
} from 'calypso/controller';
import { navigation, siteSelection, sites } from 'calypso/my-sites/controller';
import {
acceptSiteTransfer,
Expand Down Expand Up @@ -29,6 +33,7 @@ export default function () {
page(
'/settings/general/:site_id',
siteSelection,
redirectIfDuplicatedSettingsView( 'options-general.php' ),
navigation,
setScroll,
siteSettings,
Expand Down
7 changes: 6 additions & 1 deletion client/my-sites/site-settings/settings-discussion/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import page from '@automattic/calypso-router';
import { makeLayout, render as clientRender } from 'calypso/controller';
import {
makeLayout,
render as clientRender,
redirectIfDuplicatedSettingsView,
} from 'calypso/controller';
import { navigation, siteSelection } from 'calypso/my-sites/controller';
import { siteSettings } from 'calypso/my-sites/site-settings/settings-controller';
import { discussion } from './controller';
Expand All @@ -8,6 +12,7 @@ export default function () {
page(
'/settings/discussion/:site_id',
siteSelection,
redirectIfDuplicatedSettingsView( 'options-discussion.php' ),
navigation,
siteSettings,
discussion,
Expand Down
7 changes: 6 additions & 1 deletion client/my-sites/site-settings/settings-reading/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import page from '@automattic/calypso-router';
import { makeLayout, render as clientRender } from 'calypso/controller';
import {
makeLayout,
render as clientRender,
redirectIfDuplicatedSettingsView,
} from 'calypso/controller';
import { navigation, siteSelection } from 'calypso/my-sites/controller';
import { siteSettings } from 'calypso/my-sites/site-settings/settings-controller';
import { createReadingSettings } from './controller';
Expand All @@ -8,6 +12,7 @@ export default function () {
page(
'/settings/reading/:site_id',
siteSelection,
redirectIfDuplicatedSettingsView( 'options-reading.php' ),
navigation,
siteSettings,
createReadingSettings,
Expand Down
2 changes: 2 additions & 0 deletions client/my-sites/site-settings/settings-writing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
makeLayout,
render as clientRender,
redirectIfDuplicatedView as _redirectIfDuplicatedView,
redirectIfDuplicatedSettingsView,
} from 'calypso/controller';
import { navigation, siteSelection, sites } from 'calypso/my-sites/controller';
import { setScroll, siteSettings } from 'calypso/my-sites/site-settings/settings-controller';
Expand All @@ -19,6 +20,7 @@ export default function () {
page(
'/settings/writing/:site_id',
siteSelection,
redirectIfDuplicatedSettingsView( 'options-writing.php' ),
navigation,
siteSettings,
writing,
Expand Down
Loading