Skip to content

Commit fd4e133

Browse files
authored
Merge pull request #12117 from google/enhancement/#12005-rrm-policy-violation-notification
Enhancement/#12005 - Implement RRM policy violations dashboard notifications
2 parents dbc9d34 + 693b0bf commit fd4e133

24 files changed

Lines changed: 1023 additions & 19 deletions

File tree

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`PolicyViolationNotification should render error notification for immediate organization violation 1`] = `
4+
<div>
5+
<section
6+
id="rrm-policy-violation-extreme-notification"
7+
>
8+
<div
9+
class="mdc-layout-grid"
10+
>
11+
<div
12+
class="mdc-layout-grid__inner"
13+
>
14+
<div
15+
class="mdc-layout-grid__cell mdc-layout-grid__cell--align-middle mdc-layout-grid__cell--span-12"
16+
>
17+
<div
18+
class="googlesitekit-notice-container"
19+
>
20+
<div
21+
class="googlesitekit-notice googlesitekit-notice--error"
22+
>
23+
<div
24+
class="googlesitekit-notice__icon"
25+
>
26+
<svg />
27+
</div>
28+
<div
29+
class="googlesitekit-notice__content"
30+
>
31+
<p
32+
class="googlesitekit-notice__title"
33+
>
34+
Action needed: Your Reader Revenue Manager account is terminated
35+
</p>
36+
<p
37+
class="googlesitekit-notice__description"
38+
>
39+
Your account is terminated because your site content doesn’t follow the rules. Visit Publisher Center for more information.
40+
</p>
41+
</div>
42+
<div
43+
class="googlesitekit-notice__action"
44+
>
45+
<button
46+
class="mdc-button mdc-button--tertiary"
47+
target="_self"
48+
>
49+
<span
50+
class="mdc-button__label"
51+
>
52+
Got it
53+
</span>
54+
</button>
55+
<a
56+
aria-label="Learn more (opens in a new tab)"
57+
class="mdc-button googlesitekit-notice__cta googlesitekit-button-icon--spinner googlesitekit-button-icon--spinner__after mdc-button--raised"
58+
href="https://accounts.google.com/accountchooser?continue=https%3A%2F%2Fexample.com%2Fpolicy-info%3Futm_source%3Dsitekit&Email=wapuu.wordpress%40gmail.com&utm_source=sitekit"
59+
role="button"
60+
target="_blank"
61+
>
62+
<span
63+
class="mdc-button__label"
64+
>
65+
Learn more
66+
</span>
67+
<svg />
68+
</a>
69+
</div>
70+
</div>
71+
</div>
72+
</div>
73+
</div>
74+
</div>
75+
</section>
76+
</div>
77+
`;
78+
79+
exports[`PolicyViolationNotification should render warning notification for pending grace period violation 1`] = `
80+
<div>
81+
<section
82+
id="rrm-policy-violation-moderate-high-notification"
83+
>
84+
<div
85+
class="mdc-layout-grid"
86+
>
87+
<div
88+
class="mdc-layout-grid__inner"
89+
>
90+
<div
91+
class="mdc-layout-grid__cell mdc-layout-grid__cell--align-middle mdc-layout-grid__cell--span-12"
92+
>
93+
<div
94+
class="googlesitekit-notice-container"
95+
>
96+
<div
97+
class="googlesitekit-notice googlesitekit-notice--warning"
98+
>
99+
<div
100+
class="googlesitekit-notice__icon"
101+
>
102+
<svg />
103+
</div>
104+
<div
105+
class="googlesitekit-notice__content"
106+
>
107+
<p
108+
class="googlesitekit-notice__title"
109+
>
110+
Action needed: fix a policy issue with Reader Revenue Manager
111+
</p>
112+
<p
113+
class="googlesitekit-notice__description"
114+
>
115+
Your site has content that breaks the rules for Reader Revenue Manager. To keep your account active and CTAs public, you must resolve all policy violations.
116+
</p>
117+
</div>
118+
<div
119+
class="googlesitekit-notice__action"
120+
>
121+
<button
122+
class="mdc-button mdc-button--tertiary"
123+
target="_self"
124+
>
125+
<span
126+
class="mdc-button__label"
127+
>
128+
Got it
129+
</span>
130+
</button>
131+
<a
132+
aria-label="View violations (opens in a new tab)"
133+
class="mdc-button googlesitekit-notice__cta googlesitekit-button-icon--spinner googlesitekit-button-icon--spinner__after mdc-button--raised"
134+
href="https://accounts.google.com/accountchooser?continue=https%3A%2F%2Fexample.com%2Fpolicy-info%3Futm_source%3Dsitekit&Email=wapuu.wordpress%40gmail.com&utm_source=sitekit"
135+
role="button"
136+
target="_blank"
137+
>
138+
<span
139+
class="mdc-button__label"
140+
>
141+
View violations
142+
</span>
143+
<svg />
144+
</a>
145+
</div>
146+
</div>
147+
</div>
148+
</div>
149+
</div>
150+
</div>
151+
</section>
152+
</div>
153+
`;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/**
2+
* Get notification copy utility tests.
3+
*
4+
* Site Kit by Google, Copyright 2026 Google LLC
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* https://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/**
20+
* Internal dependencies
21+
*/
22+
import { TYPES } from '@/js/components/Notice/constants';
23+
import { CONTENT_POLICY_STATES } from '@/js/modules/reader-revenue-manager/datastore/constants';
24+
import { getPolicyViolationNotificationCopy } from './get-policy-violation-notification-copy';
25+
26+
const {
27+
CONTENT_POLICY_VIOLATION_GRACE_PERIOD,
28+
CONTENT_POLICY_ORGANIZATION_VIOLATION_GRACE_PERIOD,
29+
CONTENT_POLICY_VIOLATION_ACTIVE,
30+
CONTENT_POLICY_ORGANIZATION_VIOLATION_ACTIVE,
31+
CONTENT_POLICY_ORGANIZATION_VIOLATION_IMMEDIATE,
32+
} = CONTENT_POLICY_STATES;
33+
34+
describe( 'getPolicyViolationNotificationCopy', () => {
35+
it( 'should return the correct copy for content policy state `CONTENT_POLICY_ORGANIZATION_VIOLATION_IMMEDIATE`', () => {
36+
const result = getPolicyViolationNotificationCopy(
37+
CONTENT_POLICY_ORGANIZATION_VIOLATION_IMMEDIATE
38+
);
39+
40+
expect( result ).toEqual( {
41+
type: TYPES.ERROR,
42+
title: 'Action needed: Your Reader Revenue Manager account is terminated',
43+
description:
44+
'Your account is terminated because your site content doesn’t follow the rules. Visit Publisher Center for more information.',
45+
ctaLabel: 'Learn more',
46+
} );
47+
} );
48+
49+
it.each( [
50+
[ CONTENT_POLICY_VIOLATION_ACTIVE ],
51+
[ CONTENT_POLICY_ORGANIZATION_VIOLATION_ACTIVE ],
52+
] )(
53+
'should return the correct copy for content policy state %s',
54+
( contentPolicyState ) => {
55+
const result =
56+
getPolicyViolationNotificationCopy( contentPolicyState );
57+
58+
expect( result ).toEqual( {
59+
type: TYPES.WARNING,
60+
title: 'Action needed: Your Reader Revenue Manager account is restricted',
61+
description:
62+
'Your site has content that doesn’t follow the rules. To see more details and resolve the violation, please visit Publisher Center.',
63+
ctaLabel: 'View violations',
64+
} );
65+
}
66+
);
67+
68+
it.each( [
69+
[ CONTENT_POLICY_VIOLATION_GRACE_PERIOD ],
70+
[ CONTENT_POLICY_ORGANIZATION_VIOLATION_GRACE_PERIOD ],
71+
] )(
72+
'should return the correct copy for content policy state %s',
73+
( contentPolicyState ) => {
74+
const result =
75+
getPolicyViolationNotificationCopy( contentPolicyState );
76+
77+
expect( result ).toEqual( {
78+
type: TYPES.WARNING,
79+
title: 'Action needed: fix a policy issue with Reader Revenue Manager',
80+
description:
81+
'Your site has content that breaks the rules for Reader Revenue Manager. To keep your account active and CTAs public, you must resolve all policy violations.',
82+
ctaLabel: 'View violations',
83+
} );
84+
}
85+
);
86+
} );
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/**
2+
* Get notification copy utility.
3+
*
4+
* Site Kit by Google, Copyright 2026 Google LLC
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* https://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/**
20+
* WordPress dependencies
21+
*/
22+
import { __ } from '@wordpress/i18n';
23+
24+
/**
25+
* Internal dependencies
26+
*/
27+
import { TYPES } from '@/js/components/Notice/constants';
28+
import {
29+
CONTENT_POLICY_STATES,
30+
ACTIVE_POLICY_VIOLATION_STATES,
31+
} from '@/js/modules/reader-revenue-manager/datastore/constants';
32+
33+
const { CONTENT_POLICY_ORGANIZATION_VIOLATION_IMMEDIATE } =
34+
CONTENT_POLICY_STATES;
35+
36+
export interface NotificationCopy {
37+
title: string;
38+
description: string;
39+
ctaLabel: string;
40+
type: string;
41+
}
42+
43+
/**
44+
* Returns the notification copy based on the content policy state.
45+
*
46+
* @since n.e.x.t
47+
*
48+
* @param {string} contentPolicyState The content policy state.
49+
* @return {Object} An object with title, description, ctaLabel, and type.
50+
*/
51+
export function getPolicyViolationNotificationCopy(
52+
contentPolicyState: string
53+
): NotificationCopy {
54+
// Extreme severity - terminated account.
55+
if (
56+
contentPolicyState === CONTENT_POLICY_ORGANIZATION_VIOLATION_IMMEDIATE
57+
) {
58+
return {
59+
title: __(
60+
'Action needed: Your Reader Revenue Manager account is terminated',
61+
'google-site-kit'
62+
),
63+
description: __(
64+
'Your account is terminated because your site content doesn’t follow the rules. Visit Publisher Center for more information.',
65+
'google-site-kit'
66+
),
67+
ctaLabel: __( 'Learn more', 'google-site-kit' ),
68+
type: TYPES.ERROR,
69+
};
70+
}
71+
72+
// Active moderate/high severity - restricted account.
73+
if ( ACTIVE_POLICY_VIOLATION_STATES.includes( contentPolicyState ) ) {
74+
return {
75+
title: __(
76+
'Action needed: Your Reader Revenue Manager account is restricted',
77+
'google-site-kit'
78+
),
79+
description: __(
80+
'Your site has content that doesn’t follow the rules. To see more details and resolve the violation, please visit Publisher Center.',
81+
'google-site-kit'
82+
),
83+
ctaLabel: __( 'View violations', 'google-site-kit' ),
84+
type: TYPES.WARNING,
85+
};
86+
}
87+
88+
// Pending moderate/high severity - grace period (default for valid violation states).
89+
return {
90+
title: __(
91+
'Action needed: fix a policy issue with Reader Revenue Manager',
92+
'google-site-kit'
93+
),
94+
description: __(
95+
'Your site has content that breaks the rules for Reader Revenue Manager. To keep your account active and CTAs public, you must resolve all policy violations.',
96+
'google-site-kit'
97+
),
98+
ctaLabel: __( 'View violations', 'google-site-kit' ),
99+
type: TYPES.WARNING,
100+
};
101+
}

0 commit comments

Comments
 (0)