Skip to content
Snippets Groups Projects
Unverified Commit f257598e authored by adam-james's avatar adam-james Committed by GitHub
Browse files

Embedding Parameter Values set in Tokens work properly when `nil` or empty list (#45771)

* Embedding Parameter Values set in Tokens work properly when `nil` or empty list

Fixes: #40292

If a locked parameter's value is set to `nil` or `[]` in the embedding JWT, we want to treat this as 'no value has
been set' on that filter, but we should still run the query as normal. Likewise, any linked filters should still
properly derive their values from the unfiltered values of the filter to which they are linked.

* when a parameter's value is nil or empty seq, don't include it

This is a partial solution as I still need to find the place that's still erroring on the empty list case in terms of
the linked parameter's values.

* Treat empty list like `nil` for the token param

When you're using a filter in the App, it makes intuitive sense that when you've not selected anything from a filter's
drop down list (or entered any text, etc.), then the filter is effectively not applied.

For token params, we should behave similarly; `nil` and `[]` can both be accepted, and signal that the user intends
for that filter to basically NOT apply.

This also means we should not pass the constraint to the linked filters, since it errors, but even if it worked, it
would return 0 results, making it impossible to properly apply the linked filter at all.

So, this change causes empty lists to be treated as nil, AND will remove any parameters with `nil` as a value before
being passed to the query processor, which results in the proper behaviour of not having constraints on the linked
filter, and having the 'parent' filter not filtering anything.

* Embed preview should always use params from the token

In making a screenshot, I discovered a slight bug in previews, where if the embed had been previously published, it
could pull embedding params from the db that don't match the settings on screen. So, always pull the settings from the
token, which updates as the user is making changes in the Preview Embed UI.

* for previews, merge the embedding params sources instead

* alter 'nil' behaviour to work just as if the key doesn't exist

* fix one spot where I was passing maps into set functions

* Adjust tests to check for consistent behaviour in dash/qstn embeds

* fix an e2e test

* fix up last 2 failing e2e tests

* add the test case of a locked param having no value set in token

* some further e2e changes
parent 50d0c35a
Branches
Tags
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment