Allow for Optional Clauses in Click Behavior custom URL
Nobody has claimed this yet.
- Dominant language
- Clojure
- Stars
- 49.3k
- Forks
- 6.8k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 653
Description
**Is your feature request related to a problem? Please describe.**
Currently the Click Behavior for custom URLs will always send parameters even if the value is null, since the replacement happens on the reference variable, so Metabase has no context of what the parameter is or how it's connected.
But this causes problems in some situations like when linking to a Public question because of #17578
**Describe the solution you'd like**
Similar to SQL variables, allow something like `http://metabase.test/[[?param={{dash_filter}}]]`
Would then redirect to `http://metabase.test/` if the dash_filter reference was not defined.
And if dash_filter was defined as ex. `Testing`, then the redirect would be `http://metabase.test/?param=Testing`
**Describe alternatives you've considered**
Using a reverse-proxy to rewrite the URL by removing the empty parameters.
This is example code for Nginx - have not been tested if it has unintended consequences throughout Metabase, so it only applies to Public Sharing in this example:
```
location ~ ^/public/ {
if ($request_uri ~ "^([^\?]*\?)(.*[^=]&|)([^=]+=)(&.*|$)$") {
set $args $2$4;
rewrite "^" $scheme://$host$uri;
}
}
```
**Additional context**
Related to #17160
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the Click Behavior custom URL handling and the existing SQL variable optional-clause behavior. Trace how undefined dash_filter references are replaced, then verify that an omitted reference removes its surrounding clause while a defined value preserves the parameter. Check the Public Sharing flow using the examples in this issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure
- Domain
- frontend, web-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100