Dashboards: Cover the Switch variable in schema transformations - part 2. (#114549)

* feat: add v2alpha_1 conversion for the switch variable

* chore: gofmt fixes

* chore: update comments in tests

* chore: fix gofmt

* Update specs

* tests: update the v2alpha1 openapi snapshot

---------

Co-authored-by: Ivan Ortega <ivanortegaalba@gmail.com>
This commit is contained in:
Levente Balogh
2025-11-28 14:21:33 +01:00
committed by GitHub
co-authored by Ivan Ortega
parent c75137b2d3
commit 930f7ce489
16 changed files with 809 additions and 148 deletions
@@ -1050,7 +1050,7 @@ export const defaultTimeRangeOption = (): TimeRangeOption => ({
to: "now",
});
export type VariableKind = QueryVariableKind | TextVariableKind | ConstantVariableKind | DatasourceVariableKind | IntervalVariableKind | CustomVariableKind | GroupByVariableKind | AdhocVariableKind;
export type VariableKind = QueryVariableKind | TextVariableKind | ConstantVariableKind | DatasourceVariableKind | IntervalVariableKind | CustomVariableKind | GroupByVariableKind | AdhocVariableKind | SwitchVariableKind;
export const defaultVariableKind = (): VariableKind => (defaultQueryVariableKind());
@@ -1436,6 +1436,37 @@ export const defaultMetricFindValue = (): MetricFindValue => ({
text: "",
});
export interface SwitchVariableKind {
kind: "SwitchVariable";
spec: SwitchVariableSpec;
}
export const defaultSwitchVariableKind = (): SwitchVariableKind => ({
kind: "SwitchVariable",
spec: defaultSwitchVariableSpec(),
});
// Switch variable specification
export interface SwitchVariableSpec {
name: string;
current: string;
enabledValue: string;
disabledValue: string;
label?: string;
hide: VariableHide;
skipUrlSync: boolean;
description?: string;
}
export const defaultSwitchVariableSpec = (): SwitchVariableSpec => ({
name: "",
current: "false",
enabledValue: "true",
disabledValue: "false",
hide: "dontHide",
skipUrlSync: false,
});
export interface Spec {
annotations: AnnotationQueryKind[];
// Configuration of dashboard cursor sync behavior.