Skip to content

Commit 546a44f

Browse files
authored
Merge pull request #12913 from google/fix/12870-notification-view-only-users
Do not show notification to view-only user without permission.
2 parents 30c6e8c + c74506b commit 546a44f

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

assets/js/components/notifications/ActivateAnalyticsNotification.test.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,22 @@ describe( 'ActivateAnalyticsNotification', () => {
565565
expect( isActive ).toBe( false );
566566
} );
567567

568+
it( 'is not active when the user is unauthenticated', async () => {
569+
provideUserAuthentication( registry, { authenticated: false } );
570+
provideModules( registry, [
571+
{
572+
slug: MODULE_SLUG_ANALYTICS_4,
573+
active: false,
574+
},
575+
] );
576+
registry
577+
.dispatch( MODULES_SEARCH_CONSOLE )
578+
.receiveIsDataAvailableOnLoad( true );
579+
580+
const isActive = await notification.checkRequirements( registry );
581+
expect( isActive ).toBe( false );
582+
} );
583+
568584
it( 'is not active when the user cannot activate Analytics', async () => {
569585
provideModules( registry, [
570586
{

assets/js/googlesitekit/notifications/register-defaults.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ export const DEFAULT_NOTIFICATIONS = {
124124
false,
125125
requireModuleGatheringData( MODULES_SEARCH_CONSOLE )
126126
),
127+
requireIsAuthenticatedUser(),
127128
requireCanActivateModule( MODULE_SLUG_ANALYTICS_4 )
128129
),
129130
featureFlag: 'setupFlowRefresh',

0 commit comments

Comments
 (0)