site-kit-wp icon indicating copy to clipboard operation
site-kit-wp copied to clipboard

Add viewContext for all top-level React apps

Open aaemnnosttv opened this issue 5 years ago • 5 comments

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 viewContext prop of the Root 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 the isRequired flag to the propType declaration of the viewContext 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 the Root component
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 Root component's viewContext prop is now required.
  • Verify that wherever the Root component is used in the codebase, a viewContext 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

aaemnnosttv avatar Jul 16 '21 11:07 aaemnnosttv

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.

eugene-manuilov avatar Jul 27 '21 15:07 eugene-manuilov

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 👍

johnPhillips avatar Jul 27 '21 16:07 johnPhillips

@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 avatar Jul 28 '21 08:07 aaemnnosttv

@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.

felixarntz avatar Jul 28 '21 17:07 felixarntz

QA: ✅

ivankruchkoff avatar Aug 25 '21 18:08 ivankruchkoff