Skip to content

Commit

Permalink
re-apply "change add a menu link to point to the top level of customi…
Browse files Browse the repository at this point in the history
…zer with the tour shown (#54583)"

This reverts commit 2a0eddb.
  • Loading branch information
roo2 authored and p-jackson committed Sep 6, 2021
1 parent e10d909 commit 1c7fa26
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ import { getCurrentUser, isCurrentUserEmailVerified } from 'calypso/state/curren
import { CHECKLIST_KNOWN_TASKS } from 'calypso/state/data-layer/wpcom/checklist/index.js';
import { requestGuidedTour } from 'calypso/state/guided-tours/actions';
import getChecklistTaskUrls from 'calypso/state/selectors/get-checklist-task-urls';
import getMenusUrl from 'calypso/state/selectors/get-menus-url';
import getSiteChecklist from 'calypso/state/selectors/get-site-checklist';
import isUnlaunchedSite from 'calypso/state/selectors/is-unlaunched-site';
import { getSiteOption, getSiteSlug } from 'calypso/state/sites/selectors';
import { getSiteOption, getSiteSlug, getCustomizerUrl } from 'calypso/state/sites/selectors';
import { getSelectedSiteId } from 'calypso/state/ui/selectors';
import CurrentTaskItem from './current-task-item';
import { getTask } from './get-task';
Expand Down Expand Up @@ -340,7 +339,7 @@ export default connect( ( state ) => {
firstIncompleteTask: taskList.getFirstIncompleteTask(),
isEmailUnverified: ! isCurrentUserEmailVerified( state ),
isPodcastingSite: !! getSiteOption( state, siteId, 'anchor_podcast' ),
menusUrl: getMenusUrl( state, siteId ),
menusUrl: getCustomizerUrl( state, siteId, null, null, 'add-menu' ),
siteId,
siteSlug: getSiteSlug( state, siteId ),
tasks: taskList.getAll(),
Expand Down
16 changes: 10 additions & 6 deletions client/state/sites/selectors/get-customizer-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,22 @@ import isJetpackSite from './is-jetpack-site';
/**
* Returns the customizer URL for a site, or null if it cannot be determined.
*
* @param {object} state Global state tree
* @param {?number} siteId Site ID
* @param {string} panel Optional panel to autofocus
* @param {string} returnUrl Optional return url for when the user closes the customizer
* @returns {string} Customizer URL
* @param {object} state Global state tree
* @param {?number} siteId Site ID
* @param {?string} panel Optional panel to autofocus
* @param {?string} returnUrl Optional return url for when the user closes the customizer
* @param {?string} guide Optional parameter to show a help guide in the customizer. possible values:
* 'add-menu' and 'social-media' show custom guides, any other value shows the default guide
* @returns {string} Customizer URL
*/
export default function getCustomizerUrl( state, siteId, panel, returnUrl ) {
export default function getCustomizerUrl( state, siteId, panel, returnUrl, guide ) {
if ( ! isJetpackSite( state, siteId ) ) {
const siteSlug = getSiteSlug( state, siteId );
const url = [ '' ].concat( [ 'customize', panel, siteSlug ].filter( Boolean ) ).join( '/' );
return addQueryArgs(
{
return: returnUrl,
guide,
},
url
);
Expand All @@ -39,6 +42,7 @@ export default function getCustomizerUrl( state, siteId, panel, returnUrl ) {
{
return: returnUrl,
...getCustomizerFocus( panel ),
guide,
},
adminUrl
);
Expand Down
49 changes: 49 additions & 0 deletions client/state/sites/test/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -3157,6 +3157,55 @@ describe( 'selectors', () => {
);
} );

test( 'should prepend guide parameter for WordPress.com site', () => {
const customizerUrl = getCustomizerUrl(
{
sites: {
items: {
77203199: {
ID: 77203199,
URL: 'https://example.com',
jetpack: false,
},
},
},
},
77203199,
'identity',
null,
'test-guide'
);

chaiExpect( customizerUrl ).to.equal( '/customize/identity/example.com?guide=test-guide' );
} );

test( 'should prepend guide parameter for Jetpack site', () => {
const customizerUrl = getCustomizerUrl(
{
sites: {
items: {
77203199: {
ID: 77203199,
URL: 'https://example.com',
jetpack: true,
options: {
admin_url: 'https://example.com/wp-admin/',
},
},
},
},
},
77203199,
'identity',
null,
'test-guide'
);

chaiExpect( customizerUrl ).to.equal(
'https://example.com/wp-admin/customize.php?autofocus%5Bsection%5D=title_tagline&guide=test-guide'
);
} );

describe( 'browser', () => {
beforeAll( () => {
global.window = {
Expand Down

0 comments on commit 1c7fa26

Please sign in to comment.