AdHocFiltersVariable: clear origin filters to =| All when multi-value operators are supported - #1603
Draft
samjewell wants to merge 4 commits into
Draft
AdHocFiltersVariable: clear origin filters to =| All when multi-value operators are supported#1603samjewell wants to merge 4 commits into
=| All when multi-value operators are supported#1603samjewell wants to merge 4 commits into
Conversation
Origin (default) filters with the 'one of' operator now offer an explicit All option in the multi-value dropdown, like query variables. Selecting it stores the special $__all value; such filters keep their pill (labelled All) but are excluded from query requests, the filter expression, and getTagKeys/getTagValues lookups, so they no longer restrict results. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… All label - isAllValueFilter now requires the one-of operator, so a literal $__all value on any other operator keeps filtering instead of being silently dropped from queries and lookups - getFilterValueByKey applies the same predicate, so per-key interpolation no longer returns the literal sentinel - The prepended All row now takes the initial highlight (and again when the input is cleared), keeping keyboard indices valid when the first fetched option is a group header - Pill labels are paired with values, so the sentinel always renders with the current All translation rather than a persisted label Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…n multi-value operators are supported
Clearing (X) a dashboard-origin filter rewrote it to the legacy regex
match-all ('=~' / '.*'), which is passed through to panel queries and is
only neutral for datasources with Prometheus-style regex semantics -
non-regex datasources (e.g. Cube, SQL-backed) misinterpret it and every
panel shows No data while the pill reads All.
When the variable supports multi-value operators, clear to the all-value
sentinel instead (operator '=|', value $__all) - the same state
selecting All in the combobox produces. It is stripped from queries
before any datasource sees it, so it is neutral by construction.
Variables without multi-value operator support (Prometheus, Loki - which
do not declare multiValueFilterOperators) keep the existing '=~ .*'
behaviour: the cleared state must be an operator the user could have
picked themselves.
Covers all clear paths: pill X, combobox backspace, and committing an
emptied multi-value selection, which all route through updateToMatchAll.
Fixes #1602
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1602. Stacked on #1591 (base branch is
sj/adhoc-default-filters-all-option) - the diff shows only the delta. Could equally be folded into #1591 as one more commit; draft until we decide.Problem
Clearing (X) a dashboard-origin filter rewrites it to the legacy regex match-all (
=~/.*), which is deliberately passed through to panel queries. That is neutral only for datasources with Prometheus-style regex semantics. Non-regex datasources misinterpret it - e.g. the Cube datasource maps=~to equals, so the cleared state becomesWHERE x = '.*'and every panel shows No data while the pill reads "All".Change
In
updateToMatchAll, when the variable hassupportsMultiValueOperators, clear to the all-value sentinel (operator: '=|', value$__all) introduced by #1591 - the exact state selecting "All" in the combobox produces. It is stripped from queries inDrilldownDependenciesManager.getFilters()before any datasource sees it: neutral by construction, regardless of the datasource's regex semantics.Gating rationale:
=| Allonly exists where=|is offered.multiValueFilterOperators, so their=~ .*behaviour is untouched exactly where it is load-bearing.supportsMultiValueOperatorsalready flows from the datasource's plugin meta - no new capability concept needed (the longer-term operator-capability design is AdHoc filters: let datasources declare operator capabilities (regex support, per-key operators) grafana#130279).All clear paths route through
updateToMatchAll(pill X, combobox backspace, committing an emptied multi-value selection), so one branch covers them all. Restore is unaffected:originalValueKeyis keyed onkey::origin, not operator - covered in the new test.Tests
supportsMultiValueOperators: trueyields=| $__all/valueLabels: ['All']/restorable: true, and restore returns the original values.