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

Improve front-end state management #40

Closed
7 tasks done
AlanGreene opened this issue Apr 12, 2019 · 2 comments
Closed
7 tasks done

Improve front-end state management #40

AlanGreene opened this issue Apr 12, 2019 · 2 comments
Assignees

Comments

@AlanGreene
Copy link
Member

AlanGreene commented Apr 12, 2019

The front end currently presents data from a number of APIs in most of its views. The logic required to correlate the pieces from different sources is subtly different between e.g. Pipeline and PipelineRun vs Task and TaskRun. This leads to unwanted complexity, additional maintenance overhead, and increases the risk of bugs.

So far we have used a small number of top-level container components which are responsible for making API calls and manipulating the responses into a form suitable for consumption by the presentation components. This approach will not scale long-term, especially as the data needs to be combined / presented in new and subtly different ways for other features / views.

Introducing a consistent state management layer which normalises the data received from the APIs and is isolated from the presentational layer will allow for greater flexibility, improved consistency, and easier testing.

Plan:

  • redux (with react-redux + redux-thunk for async actions) as a single source of truth
    • container components bound to store via react-redux's connect, and provide relevant view of state as props to pure presentational components
  • normalizr to ensure consistent and efficient storage of the data according to a simple schema
    • shelving this for now
  • Pipeline, Task, PipelineResource, etc., indexed by name/id as appropriate
  • action creators responsible for API calls (thunks that make API calls and dispatch actions)
    • view triggers action creators (use mapDispatchToProps to bind to store)
  • selectors (using reselect or similar) to retrieve content from the store, containers/components shouldn't know the shape of the store
    • use mapStateToProps to provide appropriate inputs to the containers
  • utilities for generating common reducer + action creator patterns
    • shelving this for now
@AlanGreene
Copy link
Member Author

/assign

@AlanGreene
Copy link
Member Author

Core work complete, any additional work will be tracked separately.

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

No branches or pull requests

1 participant