Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
64b3322
Add the <AnalyticsDisconnectedNotice> to the User Settings Selection …
jimmymadon Dec 4, 2025
e5d1ac6
Add a story for the Analytics Disconnected state.
jimmymadon Dec 4, 2025
d75f3b9
Prevent storybook warnings for email reporting settings call.
jimmymadon Dec 4, 2025
8e593cc
Add new story for analytics was never connected scenario.
jimmymadon Dec 4, 2025
8c53227
Prevent errors in all stories for the UserSettingsSelectionPanel.
jimmymadon Dec 4, 2025
aaca6dd
Add the Setup Analytics Notice component.
jimmymadon Dec 5, 2025
0c8669f
Update story names to be more descriptive.
jimmymadon Dec 5, 2025
c564347
Render the SetupAnalyticsNotice component.
jimmymadon Dec 5, 2025
8121fcb
Remove unnecessary classname.
jimmymadon Dec 5, 2025
c1c9f9d
Add the Email Reporting disabled warning in selection panel for admins.
jimmymadon Dec 5, 2025
dfe10a9
Render the Email Reporting disabled warning in selection panel for ad…
jimmymadon Dec 5, 2025
0902d2a
Add story for the Email Reporting disabled warning in selection panel…
jimmymadon Dec 5, 2025
26d298a
Prevent analytics disconnected notices on all stories.
jimmymadon Dec 5, 2025
b9a4410
Prevent email reporting disabled warnings on all stories.
jimmymadon Dec 5, 2025
8c746c7
Render the view-only version of Email Reporting disabled warning for …
jimmymadon Dec 5, 2025
76e2b6c
Add the view-only version of Email Reporting disabled warning for adm…
jimmymadon Dec 5, 2025
9861f5f
Add story for the view-only version of Email Reporting disabled warni…
jimmymadon Dec 5, 2025
caad782
Add view-only version of the AnalyticsDisconnectedNotice.
jimmymadon Dec 5, 2025
6aa0430
Shorten story titles.
jimmymadon Dec 5, 2025
ef69922
Add story for view-only version of the Analytics Disconnected Notice.
jimmymadon Dec 5, 2025
6f756ed
Move Email Reporting stories into the components namespace.
jimmymadon Dec 5, 2025
dcf054d
Wrap all notices into a single component.
jimmymadon Dec 5, 2025
d6ceec4
Move all notice components into a new Notices directory.
jimmymadon Dec 5, 2025
85201d1
Standardise storybook titles.
jimmymadon Dec 5, 2025
f1700eb
Merge branch 'develop' into enhancement/11459-user-engagement-selecti…
jimmymadon Dec 5, 2025
01de055
Fix receiveGetWasAnalytcs4Connected data object in Email Reporting st…
jimmymadon Dec 5, 2025
4da3dac
Update VRT reference images.
jimmymadon Dec 7, 2025
820baa5
Convert non-component folder to lowercase.
jimmymadon Dec 7, 2025
ac0b7e8
Move EmailReportingCardNotice to the notices folder.
jimmymadon Dec 7, 2025
ae2fd10
Move EmailReportingCardNotice.
jimmymadon Dec 7, 2025
ad62ee0
Temporarily delete the notices folder.
jimmymadon Dec 7, 2025
ded8edf
Temporarily delete the Notices component.
jimmymadon Dec 7, 2025
070c09b
Temporarily remove unresolved components.
jimmymadon Dec 7, 2025
3fd6445
Remove Notices temporarily.
jimmymadon Dec 7, 2025
74c3079
Readd all notices.
jimmymadon Dec 7, 2025
8b4a355
Re-add the Notices component.
jimmymadon Dec 7, 2025
36ba30b
Re-add SettingsEmailReporting notices.
jimmymadon Dec 7, 2025
9df579d
Add tests for SetupAnalyticsNotice component.
jimmymadon Dec 8, 2025
2e8d3ba
Add test for view only state in AnalyticsDisconnectedNotice component.
jimmymadon Dec 8, 2025
c02292f
Refactor AnalyticsDisconnectedNotice test to simplify rendering and u…
jimmymadon Dec 8, 2025
b82d22c
Add tests for EmailReportingDisabledNotice component.
jimmymadon Dec 8, 2025
2ed556d
Add tests for EmailReportingDisabledNotice component.
jimmymadon Dec 8, 2025
d5ff827
Add tests for EmailReportingDisabledViewOnlyNotice component.
jimmymadon Dec 8, 2025
9977a04
Fix typo.
jimmymadon Dec 8, 2025
1646e78
Remove string concatenation.
jimmymadon Dec 8, 2025
1749ddf
Return undefined when the enabled setting is loading.
jimmymadon Dec 8, 2025
ea86cdf
Correct documentation.
jimmymadon Dec 8, 2025
73a059f
Fix tests.
jimmymadon Dec 8, 2025
f321d62
Merge branch 'develop' into enhancement/11459-user-engagement-selecti…
jimmymadon Dec 9, 2025
cc7d38f
Add useViewOnly hook to SetupAnalyticsNotice component.
jimmymadon Dec 9, 2025
84fe579
Enhance EmailReportingDisabledNotice to close settings panel on CTA c…
jimmymadon Dec 10, 2025
6e733fb
Move incorrect import positioning.
jimmymadon Dec 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* User Settings Selection Notices
*
* Site Kit by Google, Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* WordPress dependencies
*/
import { Fragment } from '@wordpress/element';

/**
* Internal dependencies
*/
import AnalyticsDisconnectedNotice from '@/js/components/email-reporting/notices/AnalyticsDisconnectedNotice';
import EmailReportingDisabledNotice from '@/js/components/email-reporting/notices/EmailReportingDisabledNotice';
import EmailReportingDisabledViewOnlyNotice from '@/js/components/email-reporting/notices/EmailReportingDisabledViewOnlyNotice';
import SetupAnalyticsNotice from '@/js/components/email-reporting/notices/SetupAnalyticsNotice';

export default function Notices() {
return (
<Fragment>
<AnalyticsDisconnectedNotice />
<SetupAnalyticsNotice />
<EmailReportingDisabledNotice />
<EmailReportingDisabledViewOnlyNotice />
</Fragment>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import P from '@/js/components/Typography/P';
import Typography from '@/js/components/Typography';
import FrequencySelector from '@/js/components/email-reporting/FrequencySelector';
import SubscribeActions from '@/js/components/email-reporting/UserSettingsSelectionPanel/SubscribeActions';
import Notices from './Notices';

export default function PanelContent( {
notice,
Expand All @@ -57,6 +58,8 @@ export default function PanelContent( {
<div className="googlesitekit-user-settings-selection__panel-content">
<Header closePanel={ closePanel } />

<Notices />

<div className="googlesitekit-user-settings-selection__panel-description">
<P type="body" size="small">
{ __(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import {
provideUserAuthentication,
provideSiteInfo,
provideUserInfo,
provideModules,
provideUserCapabilities,
} from '../../../../../tests/js/utils';
import {
VIEW_CONTEXT_MAIN_DASHBOARD,
Expand All @@ -34,6 +36,8 @@ import { CORE_USER } from '@/js/googlesitekit/datastore/user/constants';
import { USER_SETTINGS_SELECTION_PANEL_OPENED_KEY } from '@/js/components/email-reporting/constants';
import { Provider as ViewContextProvider } from '@/js/components/Root/ViewContextContext';
import UserSettingsSelectionPanel from '.';
import { MODULE_SLUG_ANALYTICS_4 } from '@/js/modules/analytics-4/constants';
import { CORE_SITE } from '@/js/googlesitekit/datastore/site/constants';

function Template( { viewContext } ) {
return (
Expand All @@ -48,6 +52,11 @@ function Template( { viewContext } ) {
export const Default = Template.bind( {} );
Default.storyName = 'Default';
Default.scenario = {};
Default.args = {
setupRegistry: ( registry ) => {
registry.dispatch( CORE_USER ).receiveGetEmailReportingSettings( {} );
},
};

export const ViewOnly = Template.bind( {} );
ViewOnly.storyName = 'View-only user';
Expand All @@ -65,17 +74,134 @@ Subscribed.args = {
},
};

export const AnalyticsWasConnected = Template.bind( {} );
AnalyticsWasConnected.storyName =
'Analytics disconnected, was connected before';
AnalyticsWasConnected.args = {
setupRegistry: ( registry ) => {
provideModules( registry, [
{
slug: MODULE_SLUG_ANALYTICS_4,
active: false,
connected: false,
},
] );
registry.dispatch( CORE_USER ).receiveGetEmailReportingSettings( {
subscribed: true,
} );
registry.dispatch( CORE_SITE ).receiveGetEmailReportingSettings( {
enabled: true,
} );
},
};

export const AnalyticsWasConnectedViewOnly = Template.bind( {} );
AnalyticsWasConnectedViewOnly.storyName =
'Analytics disconnected, was connected before, view-only user';
AnalyticsWasConnectedViewOnly.args = {
setupRegistry: ( registry ) => {
provideModules( registry, [
{
slug: MODULE_SLUG_ANALYTICS_4,
active: false,
connected: false,
},
] );
registry.dispatch( CORE_USER ).receiveGetEmailReportingSettings( {
subscribed: true,
} );
registry.dispatch( CORE_SITE ).receiveGetEmailReportingSettings( {
enabled: true,
} );
},
viewContext: VIEW_CONTEXT_MAIN_DASHBOARD_VIEW_ONLY,
};

export const AnalyticsWasNeverConnected = Template.bind( {} );
AnalyticsWasNeverConnected.storyName =
'Analytics disconnected, never connected before';
AnalyticsWasNeverConnected.args = {
setupRegistry: ( registry ) => {
provideModules( registry, [
{
slug: MODULE_SLUG_ANALYTICS_4,
active: false,
connected: false,
},
] );
registry.dispatch( CORE_USER ).receiveGetEmailReportingSettings( {
subscribed: true,
} );
registry.dispatch( CORE_SITE ).receiveGetEmailReportingSettings( {
enabled: true,
} );
registry
.dispatch( CORE_SITE )
.receiveGetWasAnalytics4Connected( { wasConnected: false } );
},
};

export const EmailReportingDisabled = Template.bind( {} );
EmailReportingDisabled.storyName = 'Email reporting disabled';
EmailReportingDisabled.args = {
setupRegistry: ( registry ) => {
registry.dispatch( CORE_SITE ).receiveGetEmailReportingSettings( {
enabled: false,
} );
registry
.dispatch( CORE_SITE )
.receiveGetWasAnalytics4Connected( { wasConnected: false } );
},
};

export const EmailReportingDisabledViewOnly = Template.bind( {} );
EmailReportingDisabledViewOnly.storyName =
'Email reporting disabled, view-only user';
EmailReportingDisabledViewOnly.args = {
setupRegistry: ( registry ) => {
registry.dispatch( CORE_SITE ).receiveGetEmailReportingSettings( {
enabled: false,
} );
registry
.dispatch( CORE_SITE )
.receiveGetWasAnalytics4Connected( { wasConnected: false } );
},
viewContext: VIEW_CONTEXT_MAIN_DASHBOARD_VIEW_ONLY,
};

export default {
title: 'EmailReporting/UserSettingsSelectionPanel',
title: 'Components/EmailReporting/UserSettingsSelectionPanel',
component: UserSettingsSelectionPanel,
decorators: [
( Story, { args } ) => {
function setupRegistry( registry ) {
provideModules( registry, [
{
slug: MODULE_SLUG_ANALYTICS_4,
active: true,
connected: true,
},
] );
provideUserAuthentication( registry );
provideUserCapabilities( registry );
provideSiteInfo( registry );
provideUserInfo( registry, {
wpEmail: 'someone@anybusiness.com',
} );
registry.dispatch( CORE_USER ).receiveGetDismissedItems( [] );
registry
.dispatch( CORE_SITE )
.receiveGetWasAnalytics4Connected( { wasConnected: true } );
registry
.dispatch( CORE_SITE )
.receiveGetEmailReportingSettings( {
enabled: true,
} );
registry
.dispatch( CORE_USER )
.receiveGetEmailReportingSettings( {
subscribed: true,
} );

registry
.dispatch( CORE_UI )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ import { CORE_SITE } from '@/js/googlesitekit/datastore/site/constants';
import { CORE_MODULES } from '@/js/googlesitekit/modules/datastore/constants';
import { MODULE_SLUG_ANALYTICS_4 } from '@/js/modules/analytics-4/constants';
import useActivateModuleCallback from '@/js/hooks/useActivateModuleCallback';
import useViewOnly from '@/js/hooks/useViewOnly';

export const EMAIL_REPORTING_ANALYTICS_DISCONNECTED_NOTICE_DISMISSED_ITEM =
'email-reporting-analytics-disconnected-notice';

export default function AnalyticsDisconnectedNotice() {
const isViewOnly = useViewOnly();

const isEmailReportingEnabled = useSelect( ( select ) =>
select( CORE_SITE ).isEmailReportingEnabled()
);
Expand Down Expand Up @@ -77,19 +80,32 @@ export default function AnalyticsDisconnectedNotice() {
return null;
}

let description = __(
'Email reports won’t include Analytics data and metrics',
'google-site-kit'
);

if ( isViewOnly ) {
description = __(
'Email reports won’t include Analytics data and metrics. To fix the issue contact your administrator.',
'google-site-kit'
);
}

return (
<Notice
className="googlesitekit-email-reporting__analytics-disconnected-notice"
type={ TYPES.WARNING }
title={ __( 'Analytics is disconnected', 'google-site-kit' ) }
description={ __(
'Email reports won’t include Analytics data and metrics',
'google-site-kit'
) }
ctaButton={ {
label: __( 'Connect Analytics', 'google-site-kit' ),
onClick: activateAnalytics,
} }
description={ description }
ctaButton={
isViewOnly
? undefined
: {
label: __( 'Connect Analytics', 'google-site-kit' ),
onClick: activateAnalytics,
}
}
dismissButton={ {
label: __( 'Got it', 'google-site-kit' ),
onClick: handleDismiss,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ import {
provideUserAuthentication,
provideModuleRegistrations,
provideSiteInfo,
} from '../../../../tests/js/test-utils';
} from '../../../../../tests/js/test-utils';
import { CORE_USER } from '@/js/googlesitekit/datastore/user/constants';
import { MODULE_SLUG_ANALYTICS_4 } from '@/js/modules/analytics-4/constants';
import { CORE_SITE } from '@/js/googlesitekit/datastore/site/constants';
import { mockLocation } from '../../../../tests/js/mock-browser-utils';
import { mockLocation } from '../../../../../tests/js/mock-browser-utils';
import { VIEW_CONTEXT_MAIN_DASHBOARD_VIEW_ONLY } from '@/js/googlesitekit/constants';

describe( 'AnalyticsDisconnectedNotice', () => {
mockLocation();
Expand Down Expand Up @@ -90,6 +91,29 @@ describe( 'AnalyticsDisconnectedNotice', () => {
).toBeInTheDocument();
} );

it( 'renders the view only description without action buttons when the user is view only', () => {
const { getByText, container } = render(
<AnalyticsDisconnectedNotice />,
{
registry,
viewContext: VIEW_CONTEXT_MAIN_DASHBOARD_VIEW_ONLY,
}
);

// Title and description should be present.
expect( getByText( /Analytics is disconnected/i ) ).toBeInTheDocument();
expect(
getByText(
/Email reports won’t include Analytics data and metrics. To fix the issue contact your administrator./i
)
).toBeInTheDocument();

// CTA button should not be present.
expect(
container.querySelector( '.googlesitekit-notice__cta-button' )
).not.toBeInTheDocument();
} );

it( 'renders the "Reconnect Analytics" button and activates the module on click', async () => {
const moduleActivationEndpoint = RegExp(
'google-site-kit/v1/core/modules/data/activation'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
render,
fireEvent,
freezeFetch,
} from '../../../../tests/js/test-utils';
} from '../../../../../tests/js/test-utils';
import { CORE_USER } from '@/js/googlesitekit/datastore/user/constants';
import { CORE_UI } from '@/js/googlesitekit/datastore/ui/constants';
import { USER_SETTINGS_SELECTION_PANEL_OPENED_KEY } from '@/js/components/email-reporting/constants';
Expand Down
Loading
Loading