Add viewContext for all top-level React apps
Feature Description
The Root component that we use for all top-level React apps has a viewContext prop that was introduced initially for providing view/screen context for feature tours. It was later also integrated with our ErrorHandler (boundary) to provide more contextual error codes for tracking React errors.
However, the prop was initially optional because we only needed feature tours in a few select places so it didn't make sense at the time to define this in all instances. For errors however, we do see these raised on all screens (for one reason or another) and this results in less contextual error codes because it has null where there would otherwise be a named view context.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- The
viewContextprop of theRootcomponent should be promoted to be a required prop - View context constants should be added for all missing contexts (please list in IB)
- All instances of
Rootmissing this prop should be updated to provide it via the respective constant
Implementation Brief
- In
assets/js/components/Root, add theisRequiredflag to the propType declaration of theviewContextprop - Go through the following list, and for each item:
- Add the constant name to
assets/js/googlesitekit/constants.js - Import the constant to the file and pass it as the
viewContextprop to theRootcomponent
- Add the constant name to
| File | Constant |
|---|---|
| assets/js/googlesitekit-user-input.js | VIEW_CONTEXT_USER_INPUT = 'userInput'; |
| assets/js/googlesitekit-activation.js | VIEW_CONTEXT_ACTIVATION = 'activation'; |
| assets/js/googlesitekit-dashboard-splash.js | VIEW_CONTEXT_DASHBOARD_SPLASH = 'splash'; |
| assets/js/googlesitekit-adminbar.js | VIEW_CONTEXT_ADMIN_BAR = 'adminBar'; |
| assets/js/googlesitekit-settings.js | VIEW_CONTEXT_SETTINGS = 'settings'; |
| assets/js/googlesitekit-module.js | VIEW_CONTEXT_MODULE = 'module'; |
| assets/js/googlesitekit-wp-dashboard.js | VIEW_CONTEXT_WP_DASHBOARD = 'WPDashboard'; |
- Merge https://github.com/google/site-kit-wp/pull/3751
Test Coverage
- No new tests required.
Visual Regression Changes
- Unlikely that any images will need updating.
QA Brief
- Verify that the
Rootcomponent'sviewContextprop is now required. - Verify that wherever the
Rootcomponent is used in the codebase, aviewContextprop is provided. - Verify that the correct constant is passed in each case, and that the respective constant is in
assets/js/googlesitekit/constants.js.
Changelog entry
- N/A
IB :heavy_check_mark:
@johnPhillips, please, do not work on the ticket before we haven't approved IB yet. I know this is a big temptation to implement it straight away but sometimes might be a case that something new comes up during IB review and we need to change the approach or even adjust AC. In this case, your PR might become useless and will require changes thus spending more time than it could take if you haven't started your PR too early.
No problem @eugene-manuilov I often end up sketching in a solution in order to understand the issue / generate the IB, so in this case I just committed what I'd done as it was fairly trivial in the end. I'll hold off next time unless I've run it past one of the senior devs first 👍
@felixarntz – I realize this is may be temporary with the generic dashboard coming, but perhaps in the future the context could be based on the selected tab. Tagging you here for visibility as well.
@aaemnnosttv That's a good idea for the future. We also already decided that a widget context will be used per tab, so it could be similar for the view context.
QA: ✅