Add viewContext for all top-level React apps
See original GitHub issueFeature 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
viewContext
prop of theRoot
component 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
Root
missing this prop should be updated to provide it via the respective constant
Implementation Brief
- In
assets/js/components/Root
, add theisRequired
flag to the propType declaration of theviewContext
prop - 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
viewContext
prop to theRoot
component
- 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’; |
Test Coverage
- No new tests required.
Visual Regression Changes
- Unlikely that any images will need updating.
QA Brief
- Verify that the
Root
component’sviewContext
prop is now required. - Verify that wherever the
Root
component is used in the codebase, aviewContext
prop 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
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
@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.
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 👍