Skip to content

Commit 97081ee

Browse files
authored
Merge pull request #12843 from google/enhancement/12790-sec-admin-splash
Update the splash screen copy for secondary administrators.
2 parents 99cf76b + 033fa8a commit 97081ee

9 files changed

Lines changed: 181 additions & 9 deletions

assets/js/components/setup/SetupUsingProxyWithSignIn/Splash.js

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ import { MODULE_SLUG_ANALYTICS_4 } from '@/js/modules/analytics-4/constants';
4545

4646
export default function Splash( { children } ) {
4747
const setupFlowRefreshEnabled = useFeature( 'setupFlowRefresh' );
48+
const setupFlowRefreshPhase4Enabled = useFeature(
49+
'setupFlowRefreshPhase4'
50+
);
4851

4952
const analyticsModuleAvailable = useSelect( ( select ) =>
5053
select( CORE_MODULES ).isModuleAvailable( MODULE_SLUG_ANALYTICS_4 )
@@ -55,6 +58,9 @@ export default function Splash( { children } ) {
5558
const isSecondAdmin = useSelect( ( select ) =>
5659
select( CORE_SITE ).hasConnectedAdmins()
5760
);
61+
const hasViewableModules = useSelect(
62+
( select ) => !! select( CORE_USER ).getViewableModules()?.length
63+
);
5864
const siteURL = useSelect( ( select ) =>
5965
select( CORE_SITE ).getReferenceSiteURL()
6066
);
@@ -98,15 +104,30 @@ export default function Splash( { children } ) {
98104

99105
getHelpURL = changedURLHelpLink;
100106
} else if ( isSecondAdmin ) {
101-
title = __(
102-
'Connect your Google account to Site Kit',
103-
'google-site-kit'
104-
);
105-
description = __(
106-
'Site Kit has already been configured by another admin of this site. To use Site Kit as well, sign in with your Google account which has access to Google services for this site (e.g. Google Analytics). Once you complete the 3 setup steps, you’ll see stats from all activated Google services.',
107-
'google-site-kit'
108-
);
109-
showLearnMoreLink = true;
107+
if ( setupFlowRefreshPhase4Enabled ) {
108+
title = __( "Let's get started!", 'google-site-kit' );
109+
110+
description =
111+
analyticsModuleActive && hasViewableModules
112+
? __(
113+
'Site Kit has already been configured by another admin of this site. To use Site Kit as well, sign in with your Google account which has access to Google services for this site (e.g. Google Analytics). Once you complete the setup, you’ll see stats from all connected Google services that are shared with you:',
114+
'google-site-kit'
115+
)
116+
: __(
117+
'Site Kit has already been configured by another admin of this site. To use Site Kit as well, sign in with your Google account which has access to Google services for this site (e.g. Google Analytics). Once you complete the setup, you’ll see stats from all connected Google services.',
118+
'google-site-kit'
119+
);
120+
} else {
121+
title = __(
122+
'Connect your Google account to Site Kit',
123+
'google-site-kit'
124+
);
125+
description = __(
126+
'Site Kit has already been configured by another admin of this site. To use Site Kit as well, sign in with your Google account which has access to Google services for this site (e.g. Google Analytics). Once you complete the 3 setup steps, you’ll see stats from all activated Google services.',
127+
'google-site-kit'
128+
);
129+
showLearnMoreLink = true;
130+
}
110131
} else if ( setupFlowRefreshEnabled ) {
111132
title = __( 'Let’s get started!', 'google-site-kit' );
112133
} else {

assets/js/components/setup/SetupUsingProxyWithSignIn/index-setupFlowRefresh.stories.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,65 @@ WithAnalyticsActive.args = {
252252
};
253253
WithAnalyticsActive.scenario = {};
254254

255+
export const SecondaryAdminAnalyticsNotActive = Template.bind( {} );
256+
SecondaryAdminAnalyticsNotActive.storyName =
257+
'Secondary admin, Analytics not setup (setupFlowRefreshPhase4 enabled)';
258+
SecondaryAdminAnalyticsNotActive.args = {
259+
setupRegistry: ( registry ) => {
260+
provideSiteConnection( registry, {
261+
hasConnectedAdmins: true,
262+
hasMultipleAdmins: true,
263+
resettable: false,
264+
} );
265+
266+
provideModules( registry, [
267+
{
268+
slug: MODULE_SLUG_ANALYTICS_4,
269+
active: false,
270+
connected: false,
271+
},
272+
] );
273+
},
274+
};
275+
SecondaryAdminAnalyticsNotActive.parameters = {
276+
features: [ 'setupFlowRefresh', 'setupFlowRefreshPhase4' ],
277+
};
278+
SecondaryAdminAnalyticsNotActive.scenario = {};
279+
280+
export const SecondaryAdminWithSharedServices = Template.bind( {} );
281+
SecondaryAdminWithSharedServices.storyName =
282+
'Secondary admin with shared services (setupFlowRefreshPhase4 enabled)';
283+
SecondaryAdminWithSharedServices.args = {
284+
setupRegistry: ( registry ) => {
285+
provideSiteConnection( registry, {
286+
hasConnectedAdmins: true,
287+
hasMultipleAdmins: true,
288+
resettable: false,
289+
} );
290+
291+
provideUserCapabilities( registry, {
292+
[ PERMISSION_AUTHENTICATE ]: true,
293+
[ getMetaCapabilityPropertyName(
294+
PERMISSION_READ_SHARED_MODULE_DATA,
295+
MODULE_SLUG_ANALYTICS_4
296+
) ]: true,
297+
} );
298+
299+
provideModules( registry, [
300+
{
301+
slug: MODULE_SLUG_ANALYTICS_4,
302+
active: true,
303+
connected: true,
304+
shareable: true,
305+
},
306+
] );
307+
},
308+
};
309+
SecondaryAdminWithSharedServices.parameters = {
310+
features: [ 'setupFlowRefresh', 'setupFlowRefreshPhase4' ],
311+
};
312+
SecondaryAdminWithSharedServices.scenario = {};
313+
255314
export default {
256315
title: 'Setup / Using Proxy With Sign-in and setupFlowRefresh enabled',
257316
decorators: [

assets/js/components/setup/SetupUsingProxyWithSignIn/index.test.js

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import {
4646
muteFetch,
4747
provideModuleRegistrations,
4848
provideModules,
49+
provideSiteConnection,
4950
provideSiteInfo,
5051
provideUserAuthentication,
5152
provideUserCapabilities,
@@ -503,6 +504,97 @@ describe( 'SetupUsingProxyWithSignIn', () => {
503504
).not.toBeInTheDocument();
504505
} );
505506

507+
it( 'should show the correct title and description for a secondary admin when Analytics is not active with the setupFlowRefreshPhase4 feature flag enabled', async () => {
508+
provideSiteConnection( registry, {
509+
hasConnectedAdmins: true,
510+
hasMultipleAdmins: true,
511+
} );
512+
513+
registry.dispatch( CORE_MODULES ).receiveGetModules(
514+
coreModulesFixture.map( ( module ) => {
515+
if ( MODULE_SLUG_ANALYTICS_4 === module.slug ) {
516+
return {
517+
...module,
518+
active: false,
519+
};
520+
}
521+
522+
return module;
523+
} )
524+
);
525+
526+
const { getByRole, getByText, queryByText, waitForRegistry } =
527+
render( <SetupUsingProxyWithSignIn />, {
528+
registry,
529+
viewContext: VIEW_CONTEXT_SPLASH,
530+
features: [ 'setupFlowRefresh', 'setupFlowRefreshPhase4' ],
531+
} );
532+
533+
await waitForRegistry();
534+
535+
expect(
536+
getByRole( 'heading', { name: "Let's get started!" } )
537+
).toBeInTheDocument();
538+
539+
expect(
540+
getByText(
541+
/Once you complete the setup, youll see stats from all connected Google services\./
542+
)
543+
).toBeInTheDocument();
544+
545+
expect(
546+
queryByText(
547+
/all connected Google services that are shared with you:/
548+
)
549+
).not.toBeInTheDocument();
550+
} );
551+
552+
it( 'should show the correct title and description for a secondary admin when Analytics is active and shared services are viewable with the setupFlowRefreshPhase4 feature flag enabled', async () => {
553+
provideSiteConnection( registry, {
554+
hasConnectedAdmins: true,
555+
hasMultipleAdmins: true,
556+
} );
557+
558+
registry.dispatch( CORE_MODULES ).receiveGetModules(
559+
coreModulesFixture.map( ( module ) => {
560+
if ( MODULE_SLUG_ANALYTICS_4 === module.slug ) {
561+
return {
562+
...module,
563+
active: true,
564+
shareable: true,
565+
};
566+
}
567+
568+
return module;
569+
} )
570+
);
571+
572+
registry.dispatch( CORE_USER ).receiveGetCapabilities( {
573+
'googlesitekit_read_shared_module_data::["analytics-4"]': true,
574+
} );
575+
576+
const { getByRole, getByText, waitForRegistry } = render(
577+
<SetupUsingProxyWithSignIn />,
578+
{
579+
registry,
580+
viewContext: VIEW_CONTEXT_SPLASH,
581+
features: [ 'setupFlowRefresh', 'setupFlowRefreshPhase4' ],
582+
}
583+
);
584+
585+
await waitForRegistry();
586+
587+
expect(
588+
getByRole( 'heading', { name: "Let's get started!" } )
589+
).toBeInTheDocument();
590+
591+
expect(
592+
getByText(
593+
/all connected Google services that are shared with you:/
594+
)
595+
).toBeInTheDocument();
596+
} );
597+
506598
it( 'should navigate to the proxy setup URL with Analytics re-auth redirect URL and `showProgress` query argument on CTA click if chosen to connect Analytics', async () => {
507599
fetchMock.postOnce( initialSetupSettingsEndpoint, {
508600
body: { settings: { isAnalyticsSetupComplete: false } },

0 commit comments

Comments
 (0)