-
- Downloads
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
Showing
- e2e/test/scenarios/embedding/embedding-dashboard.cy.spec.js 42 additions, 5 deletionse2e/test/scenarios/embedding/embedding-dashboard.cy.spec.js
- e2e/test/scenarios/embedding/embedding-native.cy.spec.js 35 additions, 4 deletionse2e/test/scenarios/embedding/embedding-native.cy.spec.js
- src/metabase/api/embed/common.clj 35 additions, 26 deletionssrc/metabase/api/embed/common.clj
- test/metabase/api/embed_test.clj 76 additions, 6 deletionstest/metabase/api/embed_test.clj
- test/metabase/api/preview_embed_test.clj 7 additions, 7 deletionstest/metabase/api/preview_embed_test.clj
Loading
Please register or sign in to comment