Fix missing Kapacitor on Source index page #748
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Connect #702
When visiting the Sources page, any InfluxDB sources that had a
configured Kapacitor would not show them. This turned out to be racey
logic. Kapacitors for a particular source are fetched from the API. The
update to the component state happened outside of the promise chained
onto the API call, so the state update was racing against the fetch from
the API (and would always win, pushing the empty object).
Instead, the chained promises for each API fetch are collected, and each
promise updates a single kapacitors object. The final promise that
updates the state is then blocked on all those promises by Promise.all.
Performing updates like this saves some allocations, since we aren't
allocating an object for each source<->kapacitor pairing to send to
setState. It also reduces setState's work, since it doesn't have to
coalesce state updates.