Skip to content
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

Open
wants to merge 25 commits into
base: develop
Choose a base branch
from

Conversation

jimmymadon
Copy link
Collaborator

Summary

Addresses issue:

Relevant technical choices

PR Author Checklist

  • My code is tested and passes existing unit tests.
  • My code has an appropriate set of unit tests which all pass.
  • My code is backward-compatible with WordPress 5.2 and PHP 7.4.
  • My code follows the WordPress coding standards.
  • My code has proper inline documentation.
  • I have added a QA Brief on the issue linked above.
  • I have signed the Contributor License Agreement (see https://cla.developers.google.com/).

Do not alter or remove anything below. The following sections will be managed by moderators only.

Code Reviewer Checklist

  • Run the code.
  • Ensure the acceptance criteria are satisfied.
  • Reassess the implementation with the IB.
  • Ensure no unrelated changes are included.
  • Ensure CI checks pass.
  • Check Storybook where applicable.
  • Ensure there is a QA Brief.
  • Ensure there are no unexpected significant changes to file sizes.

Merge Reviewer Checklist

  • Ensure the PR has the correct target branch.
  • Double-check that the PR is okay to be merged.
  • Ensure the corresponding issue has a ZenHub release assigned.
  • Add a changelog message to the issue.

Copy link

github-actions bot commented Dec 23, 2024

Build files for e4c4f28 are ready:

Copy link

github-actions bot commented Dec 23, 2024

Size Change: -1.99 kB (-0.1%)

Total Size: 1.98 MB

Filename Size Change
./dist/assets/css/googlesitekit-admin-css-********************.min.css 62.1 kB +2 B (0%)
./dist/assets/js/googlesitekit-activation-********************.js 24 kB +79 B (+0.33%)
./dist/assets/js/googlesitekit-ad-blocking-recovery-********************.js 54.1 kB +30 B (+0.06%)
./dist/assets/js/googlesitekit-adminbar-********************.js 34.7 kB -3 B (-0.01%)
./dist/assets/js/googlesitekit-api-********************.js 10.1 kB -39 B (-0.39%)
./dist/assets/js/googlesitekit-components-gm2-********************.js 6.17 kB -10 B (-0.16%)
./dist/assets/js/googlesitekit-components-gm3-********************.js 10.1 kB +1 B (+0.01%)
./dist/assets/js/googlesitekit-data-********************.js 2.37 kB +3 B (+0.13%)
./dist/assets/js/googlesitekit-datastore-forms-********************.js 8.94 kB -26 B (-0.29%)
./dist/assets/js/googlesitekit-datastore-location-********************.js 2.08 kB +1 B (+0.05%)
./dist/assets/js/googlesitekit-datastore-site-********************.js 20.2 kB -18 B (-0.09%)
./dist/assets/js/googlesitekit-datastore-ui-********************.js 10 kB -34 B (-0.34%)
./dist/assets/js/googlesitekit-datastore-user-********************.js 27.8 kB -43 B (-0.15%)
./dist/assets/js/googlesitekit-entity-dashboard-********************.js 82.3 kB +887 B (+1.09%)
./dist/assets/js/googlesitekit-main-dashboard-********************.js 167 kB +606 B (+0.37%)
./dist/assets/js/googlesitekit-metric-selection-********************.js 51.9 kB -72 B (-0.14%)
./dist/assets/js/googlesitekit-modules-ads-********************.js 35.3 kB +17 B (+0.05%)
./dist/assets/js/googlesitekit-modules-adsense-********************.js 119 kB +46 B (+0.04%)
./dist/assets/js/googlesitekit-modules-analytics-4-********************.js 191 kB -17 B (-0.01%)
./dist/assets/js/googlesitekit-modules-********************.js 22.2 kB -57 B (-0.26%)
./dist/assets/js/googlesitekit-modules-pagespeed-insights-********************.js 22.6 kB +28 B (+0.12%)
./dist/assets/js/googlesitekit-modules-reader-revenue-manager-********************.js 39.7 kB -3.56 kB (-8.25%)
./dist/assets/js/googlesitekit-modules-search-console-********************.js 69 kB +37 B (+0.05%)
./dist/assets/js/googlesitekit-modules-sign-in-with-google-********************.js 31.1 kB +116 B (+0.37%)
./dist/assets/js/googlesitekit-modules-tagmanager-********************.js 32.2 kB -36 B (-0.11%)
./dist/assets/js/googlesitekit-notifications-********************.js 36.9 kB +29 B (+0.08%)
./dist/assets/js/googlesitekit-polyfills-********************.js 378 B +1 B (+0.27%)
./dist/assets/js/googlesitekit-settings-********************.js 127 kB +52 B (+0.04%)
./dist/assets/js/googlesitekit-splash-********************.js 68.7 kB +53 B (+0.08%)
./dist/assets/js/googlesitekit-user-input-********************.js 43.8 kB -18 B (-0.04%)
./dist/assets/js/googlesitekit-vendor-********************.js 322 kB +4 B (0%)
./dist/assets/js/googlesitekit-widgets-********************.js 102 kB -39 B (-0.04%)
./dist/assets/js/googlesitekit-wp-dashboard-********************.js 63.1 kB -6 B (-0.01%)
ℹ️ View Unchanged
Filename Size
./dist/assets/css/googlesitekit-adminbar-css-********************.min.css 11.8 kB
./dist/assets/css/googlesitekit-authorize-application-css-********************.min.css 846 B
./dist/assets/css/googlesitekit-wp-dashboard-css-********************.min.css 8.23 kB
./dist/assets/js/33-********************.js 2.76 kB
./dist/assets/js/34-********************.js 2.25 kB
./dist/assets/js/35-********************.js 3.64 kB
./dist/assets/js/36-********************.js 936 B
./dist/assets/js/37-********************.js 892 B
./dist/assets/js/38-********************.js 1.61 kB
./dist/assets/js/39-********************.js 1.57 kB
./dist/assets/js/40-********************.js 1.61 kB
./dist/assets/js/41-********************.js 1.59 kB
./dist/assets/js/42-********************.js 1.83 kB
./dist/assets/js/43-********************.js 3.12 kB
./dist/assets/js/analytics-advanced-tracking-********************.js 901 B
./dist/assets/js/googlesitekit-consent-mode-********************.js 25.6 kB
./dist/assets/js/googlesitekit-events-provider-contact-form-7-********************.js 646 B
./dist/assets/js/googlesitekit-events-provider-easy-digital-downloads-********************.js 624 B
./dist/assets/js/googlesitekit-events-provider-mailchimp-********************.js 630 B
./dist/assets/js/googlesitekit-events-provider-ninja-forms-********************.js 712 B
./dist/assets/js/googlesitekit-events-provider-optin-monster-********************.js 675 B
./dist/assets/js/googlesitekit-events-provider-popup-maker-********************.js 634 B
./dist/assets/js/googlesitekit-events-provider-woocommerce-********************.js 657 B
./dist/assets/js/googlesitekit-events-provider-wpforms-********************.js 633 B
./dist/assets/js/googlesitekit-i18n-********************.js 3.93 kB
./dist/assets/js/runtime-********************.js 1.4 kB

compressed-size-action

Copy link
Collaborator

@aaemnnosttv aaemnnosttv left a 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 👍

@@ -67,7 +72,7 @@ export default function Dismiss( {
onClick={ handleDismiss }
disabled={ disabled }
>
{ dismissLabel }
{ isDismissalFinal ? dismissLabel : dismissLabelInitial }
Copy link
Collaborator

@aaemnnosttv aaemnnosttv Dec 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we maybe do this in the individual notifications instead? That way we only need to pass through a dismissLabel and this common component remains simple. This isn't a common case, so I don't feel like it really belongs in the common component.

Comment on lines +53 to +57
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';
Copy link
Collaborator

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.

Copy link
Collaborator Author

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!

const rrmConnected = await resolveSelect(
CORE_MODULES
).isModuleConnected( READER_REVENUE_MANAGER_MODULE_SLUG );
if ( isFeatureEnabled( 'rrmModule' ) ) {
Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

Comment on lines +121 to +128
const getBannerSVG = () => {
if ( breakpoint === BREAKPOINT_SMALL ) {
return SetupMobileSVG;
}

if ( breakpoint === BREAKPOINT_TABLET ) {
return SetupTabletSVG;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't really need to be a function, but a map which could be defined outside of the component.

e.g.

const breakpointSVGMap = {
	[ BREAKPOINT_SMALL ]: SetupMobileSVG,
	// ...
}
// In component...
SVG={ breakpointSVGMap[ breakpoint ] || SetupSVG };

Comment on lines 463 to 471
isNotificationRetryFinal: createRegistrySelector(
( select ) => ( state, id ) => {
const notification =
select( CORE_NOTIFICATIONS ).getNotification( id );

// If a notification does not have retries, it always will be on its final render.
if ( notification.dismissRetries === 0 ) {
return true;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about considering dismissible here as well? What if the notification isn't dismissible? Maybe it should trigger an invariant violation? I feel like true or false would both be incorrect 🤔

Also, maybe Retry should be Dismiss?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Originally, the idea here was for the selector to be used in the common <Dismiss> component that would've been used by all notifications. Added an invariant now like you suggest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants