Uploaded image for project: 'Compass '
  1. Compass
  2. COMPASS-4935

Make plugin stores have initial states when rendering with StoreConnector

    • Type: Icon: Task Task
    • Resolution: Won't Do
    • Priority: Icon: Major - P3 Major - P3
    • No version
    • Affects Version/s: None
    • Component/s: Tech debt
    • Labels:
      None
    • Not Needed

      A few plugins (`compass-connect`, `compass-collection-stats`, etc) have their stores set up as reflux store with react state mixins. These stores are connected to the plugins using a `StoreConnector` component in `hadron-react-components`.
      When these components/plugins are initially mounted, currently react prop validation isn't receiving the proper initial state, so all of their props are invalid. As a result, all of these plugins have their top level props not marked as `required`. This is something that would be good to fix, so that we can know if a prop is actually not present and possibly indicating a bug.
      There's a few things we could do to fix this:

      • Update the `reflux-state-mixin` package we use for helping reflux/react work nicely together to initialize or call `getInitialState` and setting the state before mounting the component.
      • Update the `StoreConnector` in `hadron-react-components` to avoid mounting components until the store has its initial state.
      • Remove reflux and reflux-state-mixin and use redux everywhere (lots of work but ideal end result).

      This ticket involves making it so that we can make top level props in plugins required and receive errors/warnings when things aren't as expected.

      Reference:
      Store connector in `hadron-react-components`: https://github.com/mongodb-js/compass/blob/main/packages/hadron-react-components/src/store-connector.jsx
      Example `compass-collection-stats` store which exhibits this behavior: https://github.com/mongodb-js/compass/blob/main/packages/compass-collection-stats/src/stores/store.js#L92

            Assignee:
            Unassigned Unassigned
            Reporter:
            rhys.howell@mongodb.com Rhys Howell
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: