Skip to content

Commit 7940052

Browse files
committed
Register policy violation notifications for moderate/high and extreme severity in the reader revenue manager module.
1 parent 345b9d4 commit 7940052

1 file changed

Lines changed: 61 additions & 0 deletions

File tree

  • assets/js/modules/reader-revenue-manager

assets/js/modules/reader-revenue-manager/index.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
ERROR_CODE_NON_HTTPS_SITE,
3232
LEGACY_RRM_SETUP_BANNER_DISMISSED_KEY,
3333
PUBLICATION_ONBOARDING_STATES,
34+
CONTENT_POLICY_STATES,
3435
} from './datastore/constants';
3536
import { SetupMain } from './components/setup';
3637
import { SettingsEdit, SettingsView } from './components/settings';
@@ -39,12 +40,15 @@ import { isURLUsingHTTPS } from '@/js/util/is-url-using-https';
3940
import {
4041
ReaderRevenueManagerSetupCTABanner,
4142
RRMSetupSuccessSubtleNotification,
43+
PolicyViolationNotification,
4244
} from './components/dashboard';
4345
import {
4446
NOTIFICATION_GROUPS,
4547
NOTIFICATION_AREAS,
4648
PRIORITY,
4749
} from '@/js/googlesitekit/notifications/constants';
50+
import { asyncRequireAll } from '@/js/util/async';
51+
import { requireModuleConnected } from '@/js/googlesitekit/data-requirements';
4852
import { VIEW_CONTEXT_MAIN_DASHBOARD } from '@/js/googlesitekit/constants';
4953
import { CORE_MODULES } from '@/js/googlesitekit/modules/datastore/constants';
5054
import { CORE_USER } from '@/js/googlesitekit/datastore/user/constants';
@@ -54,6 +58,8 @@ import {
5458
RRM_PRODUCT_ID_SUBSCRIPTIONS_NOTIFICATION_ID,
5559
RRM_SETUP_NOTIFICATION_ID,
5660
RRM_SETUP_SUCCESS_NOTIFICATION_ID,
61+
RRM_POLICY_VIOLATION_MODERATE_HIGH_NOTIFICATION_ID,
62+
RRM_POLICY_VIOLATION_EXTREME_NOTIFICATION_ID,
5763
MODULE_SLUG_READER_REVENUE_MANAGER,
5864
} from './constants';
5965
import ProductIDSubscriptionsNotification from './components/dashboard/ProductIDSubscriptionsNotification';
@@ -347,6 +353,61 @@ export const NOTIFICATIONS = {
347353
return false;
348354
},
349355
},
356+
[ RRM_POLICY_VIOLATION_MODERATE_HIGH_NOTIFICATION_ID ]: {
357+
Component: PolicyViolationNotification,
358+
priority: PRIORITY.ERROR_LOW,
359+
areaSlug: NOTIFICATION_AREAS.DASHBOARD_TOP,
360+
viewContexts: [ VIEW_CONTEXT_MAIN_DASHBOARD ],
361+
featureFlag: 'rrmPolicyViolations',
362+
isDismissible: true,
363+
checkRequirements: asyncRequireAll(
364+
requireModuleConnected( MODULE_SLUG_READER_REVENUE_MANAGER ),
365+
async ( { select, resolveSelect } ) => {
366+
await resolveSelect(
367+
MODULES_READER_REVENUE_MANAGER
368+
).getSettings();
369+
370+
const contentPolicyState = select(
371+
MODULES_READER_REVENUE_MANAGER
372+
).getContentPolicyState();
373+
374+
// Show for any violation state except OK and EXTREME (which has its own notification).
375+
return (
376+
contentPolicyState &&
377+
contentPolicyState !==
378+
CONTENT_POLICY_STATES.CONTENT_POLICY_STATE_OK &&
379+
contentPolicyState !==
380+
CONTENT_POLICY_STATES.CONTENT_POLICY_ORGANIZATION_VIOLATION_IMMEDIATE
381+
);
382+
}
383+
),
384+
},
385+
[ RRM_POLICY_VIOLATION_EXTREME_NOTIFICATION_ID ]: {
386+
Component: PolicyViolationNotification,
387+
priority: PRIORITY.ERROR_HIGH,
388+
areaSlug: NOTIFICATION_AREAS.DASHBOARD_TOP,
389+
viewContexts: [ VIEW_CONTEXT_MAIN_DASHBOARD ],
390+
featureFlag: 'rrmPolicyViolations',
391+
isDismissible: true,
392+
checkRequirements: asyncRequireAll(
393+
requireModuleConnected( MODULE_SLUG_READER_REVENUE_MANAGER ),
394+
async ( { select, resolveSelect } ) => {
395+
await resolveSelect(
396+
MODULES_READER_REVENUE_MANAGER
397+
).getSettings();
398+
399+
const contentPolicyState = select(
400+
MODULES_READER_REVENUE_MANAGER
401+
).getContentPolicyState();
402+
403+
// Show only for EXTREME severity.
404+
return (
405+
contentPolicyState ===
406+
CONTENT_POLICY_STATES.CONTENT_POLICY_ORGANIZATION_VIOLATION_IMMEDIATE
407+
);
408+
}
409+
),
410+
},
350411
};
351412

352413
export function registerNotifications( notificationsAPI ) {

0 commit comments

Comments
 (0)