QueryVariable: Add static options input (#107514)

* static options for query variable

* add toggle

* fix and add tests

* run the hack codegen thing

* more test fixes

* make betterer happier

* also make typecheck happy

* make betterer happier

* fix i18n key

* tranalte static variables sort label

* gen translations

* update snapshot
This commit is contained in:
Domas
2025-07-14 16:05:56 +03:00
committed by GitHub
parent baa89f3eac
commit 8eef17cb37
26 changed files with 680 additions and 28 deletions
+12
View File
@@ -725,6 +725,10 @@ type VariableModel struct {
// Optional field, if you want to extract part of a series name or metric node segment.
// Named capture groups can be used to separate the display text and value.
Regex *string `json:"regex,omitempty"`
// Additional static options for query variable
StaticOptions []VariableOption `json:"staticOptions,omitempty"`
// Ordering of static options in relation to options returned from data source for query variable
StaticOptionsOrder *VariableModelStaticOptionsOrder `json:"staticOptionsOrder,omitempty"`
}
// NewVariableModel creates a new VariableModel object.
@@ -1045,6 +1049,14 @@ const (
DataTransformerConfigTopicAlertStates DataTransformerConfigTopic = "alertStates"
)
type VariableModelStaticOptionsOrder string
const (
VariableModelStaticOptionsOrderBefore VariableModelStaticOptionsOrder = "before"
VariableModelStaticOptionsOrderAfter VariableModelStaticOptionsOrder = "after"
VariableModelStaticOptionsOrderSorted VariableModelStaticOptionsOrder = "sorted"
)
type ValueMapOrRangeMapOrRegexMapOrSpecialValueMap struct {
ValueMap *ValueMap `json:"ValueMap,omitempty"`
RangeMap *RangeMap `json:"RangeMap,omitempty"`
@@ -3058,6 +3058,20 @@
"sort": {
"type": "string",
"default": ""
},
"staticOptions": {
"type": "array",
"items": {
"default": {},
"allOf": [
{
"$ref": "#/components/schemas/com.github.grafana.grafana.apps.dashboard.pkg.apis.dashboard.v2alpha1.DashboardVariableOption"
}
]
}
},
"staticOptionsOrder": {
"type": "string"
}
}
},