File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ import Link from './Link';
4747 * @param {Object } props Component props.
4848 * @param {string } props.id Notification ID/slug.
4949 * @param {string } props.title Notification title/heading.
50- * @param {?ReactNode } props.content Decsription for notification.
50+ * @param {?ReactNode } props.content Description for notification.
5151 * @param {string } props.ctaLabel Label for the call-to-action button.
5252 * @param {?string } props.ctaTarget `target` for the call-to-action link, e.g. `_blank`. Optional.
5353 * @param {?string } props.ctaURL URL for the call-to-action link.
@@ -79,9 +79,11 @@ function NotificationFromServer( {
7979 description = {
8080 < Description
8181 learnMoreLink = {
82- < Link href = { learnMoreURL } external >
83- { learnMoreLabel }
84- </ Link >
82+ ! ! learnMoreURL && ! ! learnMoreLabel ? (
83+ < Link href = { learnMoreURL } external >
84+ { learnMoreLabel }
85+ </ Link >
86+ ) : undefined
8587 }
8688 text = { content }
8789 />
Original file line number Diff line number Diff line change 2020 * WordPress dependencies
2121 */
2222import { useEffect , useState } from '@wordpress/element' ;
23+ import { __ } from '@wordpress/i18n' ;
2324
2425/**
2526 * Internal dependencies
@@ -65,9 +66,33 @@ export default function useAdSenseNotifications() {
6566 return ;
6667 }
6768
69+ /**
70+ * Adjust the notification props to match the expected
71+ * `NotificationFromServer` component props, which vary
72+ * slightly from the attributes returned from the REST API.
73+ */
74+ const notificationProps = { ...notification } ;
75+
76+ // Some notifications do not include a `title` property, so supply
77+ // a default.
78+ if ( ! notificationProps . title ) {
79+ notificationProps . title = __ (
80+ 'Notice about your AdSense account' ,
81+ 'google-site-kit'
82+ ) ;
83+ }
84+
85+ if (
86+ ! notificationProps . content ?. length &&
87+ ! ! notificationProps . description ?. length
88+ ) {
89+ notificationProps . content = notificationProps . description ;
90+ delete notificationProps . description ;
91+ }
92+
6893 registerNotification ( notification . id , {
6994 Component ( ) {
70- return < NotificationFromServer { ...notification } /> ;
95+ return < NotificationFromServer { ...notificationProps } /> ;
7196 } ,
7297 priority : notification . priority ,
7398 areaSlug : NOTIFICATION_AREAS . HEADER ,
You can’t perform that action at this time.
0 commit comments