Skip to content
This repository has been archived by the owner on Mar 5, 2019. It is now read-only.

ui: dynamically display lists of entities #167

Open
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

aspiers
Copy link
Member

@aspiers aspiers commented Mar 26, 2017

This is the final part of the work on #143. It's based on top of #162, but since that hasn't been merged yet, and GitHub is too dumb to allow PRs that depend on other PRs, this PR also contains the commits from #162. (Once #162 is merged, I can rebase to fix that.)

Issues to close

Fixes #143.

Notes

Quite a lot of code cleanup included here. Still need to introduce selectors to fix the horrible performance.

entities-list

To correctly support both thunk middleware and Redux Devtools, we use
the convenient redux-devtools-extension library to compose thunk with
the middleware enhancer, and then use that as the final argument to
createStore().
This will allow us to see lists of people, organisations, and government
offices, and eventually click on each one to examine it.
We'll use this for asynchronous fetching of data from the Rails API
into the Redux store.
This lets us group request-related functions together.
This dispatches the FETCH_ENTITIES action whose payload is an axios
request object.  redux-promise-middleware will handle this by executing
the request's promise, and then magically dispatching
FETCH_ENTITIES_{PENDING,FULFILLED,REJECTED} actions according to the 3
possible stages of the conversation with the API endpoint.

Currently these 3 actions are not handled by any reducer; that will come
in subsequent commits.
This will fail if for some reason targetType is missing.
I forgot to rename them when renaming the component in
9ba199a.
Also make the previously existing reducer for the ADD_ENTITY action
use the same new tree structure in the store, and fix bugs where
parts of the state tree were not immutable.
This provides the entity data to the container.  It isn't used yet -
that will be handled in the next commit.
Display the entity data provided by the store, as a simple
list of entities, sorted lexically case-insensitive.
In the old ADD_ENTITY action used by ChartTitle, we had some nice
validation for the action's entity type.  Extend this to all actions
which specify an entity type (which is currently all 4 in
dataReducer), by unifying the actions' structures so that entityType
is always under action.meta.
This seems to be some strange race condition where state.data is not
always initialized by the time mapStateToProps is invoked, causing an
exception when attempting to call getIn() on it.  Maybe it only
happens when auto-reloading the app whilst a git rebase is running,
but I'm not really sure.  Either way, we should watch out for this by
logging a warning.
This can be reused by EntityList.
This was broken by the restructuring of the state tree when introducing
combineReducers via 22cdf44 in HackBrexit#159.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ui: dynamically generate lists of entities
1 participant