-
Notifications
You must be signed in to change notification settings - Fork 294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhancement/9889 Refactor RRM Setup CTA Banner #9938
Enhancement/9889 Refactor RRM Setup CTA Banner #9938
Conversation
Build files for c2172ee have been deleted. |
Size Change: -1.68 kB (-0.08%) Total Size: 1.99 MB
ℹ️ View Unchanged
|
…sing itto the action.
…fication registration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking pretty good @jimmymadon – I left a few comments according to what I see so far 👍
assets/js/googlesitekit/notifications/components/common/Dismiss.js
Outdated
Show resolved
Hide resolved
import { CORE_NOTIFICATIONS } from '../../../../googlesitekit/notifications/datastore/constants'; | ||
import NotificationWithSVG from '../../../../googlesitekit/notifications/components/layout/NotificationWithSVG'; | ||
import Description from '../../../../googlesitekit/notifications/components/common/Description'; | ||
import LearnMoreLink from '../../../../googlesitekit/notifications/components/common/LearnMoreLink'; | ||
import ActionsCTALinkDismiss from '../../../../googlesitekit/notifications/components/common/ActionsCTALinkDismiss'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be imported from googlesitekit-notifications
, no? We probably need to expose them but otherwise this will get duplicated in the various bundles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is interesting. Perhaps I'll create a separate issue as this applies to all refactored notifications and will end up being a larger code change!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have added #9993 for this. Thanks!
const rrmConnected = await resolveSelect( | ||
CORE_MODULES | ||
).isModuleConnected( READER_REVENUE_MANAGER_MODULE_SLUG ); | ||
if ( isFeatureEnabled( 'rrmModule' ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can just return early here rather than wrap everything since all of these notifications would not be registered, correct? If we did have any that should still be registered, we could add them above the return instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would keep this as is only to keep things consistent as this is the pattern we are (and have been) following for all notifications and widgets registration. The additional indentation and wrapper is clearer than the "order" (before/after the feature flag return) especially if the list gets biggers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we may want to consider putting the notification definitions in a separate file(s) similar to how we handle the datastore (you could make the case to do this for widgets too, which we probably should). That way the module index should largely mirror its entrypoint and simply provide exports rather than defining all this inline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be plugin-wide change again. I do sometimes like seeing the "requirements" for the module, its widgets and notifications all in one place. But if we think this is necessary, I can add this requirement to #9993 as an extra bit of refactoring/cleanup?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I wasn't suggesting we'd do it in this issue, but I do think it would be worth cleaning up the module indexes to be reduced to composition and exports only and organize the implementation into a more logical structure. This should be a separate issue from #9993, potentially multiple issues depending on the effort.
...js/modules/reader-revenue-manager/components/dashboard/ReaderRevenueManagerSetupCTABanner.js
Outdated
Show resolved
Hide resolved
assets/js/googlesitekit/notifications/datastore/notifications.js
Outdated
Show resolved
Hide resolved
import { CORE_USER } from '../../../../googlesitekit/datastore/user/constants'; | ||
import { | ||
READER_REVENUE_MANAGER_MODULE_SLUG, | ||
READER_REVENUE_MANAGER_SETUP_BANNER_DISMISSED_KEY, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Should I be creating a migration file to update the dismissed prompts key in the DB for users that may have already dismissed the banner? In the new code, the notification ID is used as the dismissal key.
- Or should we change the notification ID here to be the same as the original dismissal key - but this would be 'hacky' as the ID would have a funny name here. And the GA events will now be tracked to a different ID than the original ID used.
- Should we keep things as it is and have some of the users who have RRM enabled dismiss the banner again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think keeping as-is is the best option here but if the RRM setup prompt is retryable, then I'd be a bit concerned if folks already dismissed it multiple times and now they'd need to dismiss it multiple times again. Is that the case? It looks like yes.
In that case, I think we can simply check for the presence of the old dismissal in the RRM notification's checkRequirements
function. That way, everything else runs as usual but we still account for an existing dismissal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It sounds like a good easy hack which we can remove if we do any migration for dismissed-items or prompts in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't say it's a hack 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jimmymadon ! This is looking good, just a few things to address.
assets/js/googlesitekit/notifications/components/layout/NotificationWithSVG.js
Outdated
Show resolved
Hide resolved
assets/js/googlesitekit/notifications/datastore/notifications.js
Outdated
Show resolved
Hide resolved
import { CORE_USER } from '../../../../googlesitekit/datastore/user/constants'; | ||
import { | ||
READER_REVENUE_MANAGER_MODULE_SLUG, | ||
READER_REVENUE_MANAGER_SETUP_BANNER_DISMISSED_KEY, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think keeping as-is is the best option here but if the RRM setup prompt is retryable, then I'd be a bit concerned if folks already dismissed it multiple times and now they'd need to dismiss it multiple times again. Is that the case? It looks like yes.
In that case, I think we can simply check for the presence of the old dismissal in the RRM notification's checkRequirements
function. That way, everything else runs as usual but we still account for an existing dismissal.
// TODO Remove this hack | ||
// We "incorrectly" pass true to the `skipHidingFromQueue` option when dismissing this banner. | ||
// This is because we don't want the component removed from the DOM as we have to still render | ||
// the `AdminMenuTooltip` in this component. This means that we have to rely on manually | ||
// checking for the dismissal state here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have an issue for this? We should address this sooner than later and then remove the skipHidingFromQueue
option as it shouldn't be needed, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, I've added #10003 to tackle this. Thanks.
...js/modules/reader-revenue-manager/components/dashboard/ReaderRevenueManagerSetupCTABanner.js
Outdated
Show resolved
Hide resolved
...js/modules/reader-revenue-manager/components/dashboard/ReaderRevenueManagerSetupCTABanner.js
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jimmymadon – this looks great. I'm going to push a few little tweaks otherwise this is good to go 👍
@@ -81,10 +81,7 @@ export default function NotificationWithSVG( { | |||
</Cell> | |||
<Cell | |||
alignBottom | |||
className={ classNames( | |||
'googlesitekit-setup-cta-banner__svg-wrapper', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there are styles attached to this selector. Are we sure it's not needed?
I would actually keep the base class if we have a variant specific to the id
as well.
let isNotificationDismissalFinal; | ||
beforeEach( () => { | ||
( { isNotificationDismissed } = | ||
( { isNotificationDismissalFinal } = | ||
registry.select( CORE_NOTIFICATIONS ) ); | ||
} ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍 I think we should do this more, at least for the selector/action under test like you've done here. Generally, we should do more destructuring to avoid calling the store select
or dispatch
repeatedly as it's unnecessary and always makes the code get spread over many more lines.
import { CORE_USER } from '../../../../googlesitekit/datastore/user/constants'; | ||
import { | ||
READER_REVENUE_MANAGER_MODULE_SLUG, | ||
READER_REVENUE_MANAGER_SETUP_BANNER_DISMISSED_KEY, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't say it's a hack 😄
Known E2E instabilities causing failures. G2G! |
Summary
Addresses issue:
ReaderRevenueManagerSetupCTABanner
to not display simultaneously with other CTAs #9889Relevant technical choices
PR Author Checklist
Do not alter or remove anything below. The following sections will be managed by moderators only.
Code Reviewer Checklist
Merge Reviewer Checklist