-
Notifications
You must be signed in to change notification settings - Fork 12.1k
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
Templating: Fixes so texts show in picker not the values #27002
Templating: Fixes so texts show in picker not the values #27002
Conversation
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.
Looks good, tested this with an already saved dashboard with many multi-variables and saved in specific multi selection state to make sure there was no problem loading an old dashboard
Thank you @torkelo, before we merge I just want to discuss this change with @mckn because I might miss some of his insights on this. |
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.
Thank you @mckn |
(cherry picked from commit bd75adf)
(cherry picked from commit bd75adf)
This caused a very critical bug, causing the All variable not to work (both for normal cases and repeated panels). For repeated panels is due to current.text being an array so a comparison with 'All' no longer works: That explains why repeat no longer works. Not sure yet why All is not working in a normal query (not rendering to all the values) but probably a similar issue |
What this PR does / why we need it:
The templating system has gotten less complex when we migrated it to React but there is still at least one big complexity left that still causes us some issues. The complexity I'm talking about is how we for some VariableTypes have support for both
single value
andmulti value
. This causes a lot of if statement in our code that tries to handle this andprops
that can be bothstring
andstring[]
.This PR does not attempt to solve this complexity, but I think it pushes our code onto a better path. With this PR the
current
prop will always keep the same type as defined inalignCurrentWithMulti
below:grafana/public/app/features/variables/shared/multiOptions.ts
Line 3 in 1915d10
This means that
OptionsPicker
is the only component/class/object/function that transforms thecurrent.text
to the correct value which seems a lot clearer to me.grafana/public/app/features/variables/pickers/OptionsPicker/OptionsPicker.tsx
Line 107 in 1915d10
I also did some refactoring of the tests because they weren't using "valid" data.
Which issue(s) this PR fixes:
Fixes #25711
Fixes #25959
Special notes for your reviewer:
There are probably other cases that are messed up with this, but I couldn't find any :)