-
Notifications
You must be signed in to change notification settings - Fork 162
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
Measurements URL query params #1848
Conversation
Doing this in preparation for adding URL params for measurement controls. The initial control state is constructed then the URL params update the state. However, the measurements JSON is loaded after this, so it needs a way to differentiate the clean slate vs the added URL params.
Changes behavior to only use collection's display default on the initial load of the page when the control state is undefined. If measurements URL params are added, then the control state will no longer be undefined so the collection defaults will not overwrite the URL params.
Prevent errors from invalid collection defaults. Falls back to the app defaults if there are invalid collection defaults. Also pulls out access of collection's defaults into a separate function so that it can be used in subsequent changes to add URL params.
Lays the foundation for measurements URL query params, starting with the simplest `m_overallMean` to toggle the display of the overall mean. A series of decisions made in this commit: 1. Keeps conversion between query params and control states in the same file so that they are less likely to be out of sync. 2. Uses a single dispatch action to create both the new control state and query params to make sure they are in-sync. 3. If the new control state matches the defaults, then the query param is removed. This matches the behavior of other query params in Auspice.
Use `m_display` to toggle measurements display between "mean" and "raw"
Use `m_threshold` to toggle whether the thresholds are displayed in the measurements panel. The query param is ignored and removed if the collection displayed does not have thresholds.
Use query param `m_groupBy` to specify which group by field to use in the measurements panel. If it is not one of the collection's groupings, then the query param will be ignored and removed.
Use query param `mf_<field>=<value>` to specify active filters for the measurements panel. Invalid fields or values are ignored and removed. Multiple values for the same field are expected to give the query param multiple times with different values, e.g. `mf_reference_strain=A/Stockholm/18/2011&mf_reference_strain=A/Alabama/5/2010` This is slightly different than the behavior of the tree filter param, but I'm following this pattern to avoid the issue described in <#1846>
Doing this in preparation for adding URL query parameter for defining collection to display. We need to track the defaultCollectionKey in Redux state to be able to know when to remove the URL query parameter if the displayed collection is the default.
This comment was marked as resolved.
This comment was marked as resolved.
Use query param `m_collection=<collection_key>` to specify which collection to display in the measurements panel. The display will use the collection's display defaults unless there are other measurements query params included in the URL. If the collection key is the default collection, then the query param will be removed. If the collection key is invalid, then the query param will be removed and the default collection will be displayed.
7a1c4c5
to
e973271
Compare
This comment was marked as resolved.
This comment was marked as resolved.
Previously, existing control state carried over between narrative slides so the slide's URL query params were not respected. This commit resets the measurement's state to the default collection and the control states to the collection's default control states. In the special case where the narrative's URL query params define a different collection with `m_collection`, the measurement and control states are set to the new collections defaults before other query params are processed.
e973271
to
7924946
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This worked really well for me in the test build, @joverlee521! I love the new docs and the new query field option names, too. Thank you!
The choice to implement multiple filter values as separate query string entries makes those filters unambiguous. I can see myself forgetting how this works initially and trying to use comma-delimited filter values like the other Auspice filters. For example, the following link works as expected with comma-delimited filters on the tree strains and separate query string keys for the reference strain filters:
But this link does not work when I try to comma-delimit (probably not a real verb) the reference strain filters:
This is a pretty minor issue, though. Barring any JS-related comments other folks have on this PR, I'd be happy to see this merged and released, so I can start using it for real.
@jameshadfield and I walked through the Redux state changes in person.
I'm planning to merge this as-is tomorrow because it works and the new functionality would be immediately helpful for @huddlej. We can plan to revisit the internal workings on how the Redux state is initialized and managed later. |
@jameshadfield also requested two additional test cases in narratives:
|
Notes: Prior to this work, we load and parse the main JSON and read URL queries all in one redux step (largely This PR parses measurements panel URL queries within We discussed two alternative approaches:
|
Description of proposed changes
Add URL query params for the measurements panel, see docs for new query params.
Examples using community dataset
Also see new query params used in example narrative
Related issue(s)
Resolves #1815
Checklist