GroupByVariable: Add support for default values in schema (#105518)

* update schema

* update schema

* refactor property to singular naming

* bump scenes

* leave scenes to caret version

* add defaultValue to groupBy model

* typo
This commit is contained in:
Victor Marin
2025-05-23 01:13:52 +03:00
committed by GitHub
parent 7e1c5a37e5
commit 5cee301e75
7 changed files with 23 additions and 17 deletions
@@ -874,6 +874,7 @@ CustomVariableKind: {
GroupByVariableSpec: {
name: string | *""
datasource?: DataSourceRef
defaultValue?: VariableOption
current: VariableOption | *{
text: ""
value: ""
@@ -878,6 +878,7 @@ CustomVariableKind: {
GroupByVariableSpec: {
name: string | *""
datasource?: DataSourceRef
defaultValue?: VariableOption
current: VariableOption | *{
text: ""
value: ""
@@ -1601,15 +1601,16 @@ func NewDashboardGroupByVariableKind() *DashboardGroupByVariableKind {
// GroupBy variable specification
// +k8s:openapi-gen=true
type DashboardGroupByVariableSpec struct {
Name string `json:"name"`
Datasource *DashboardDataSourceRef `json:"datasource,omitempty"`
Current DashboardVariableOption `json:"current"`
Options []DashboardVariableOption `json:"options"`
Multi bool `json:"multi"`
Label *string `json:"label,omitempty"`
Hide DashboardVariableHide `json:"hide"`
SkipUrlSync bool `json:"skipUrlSync"`
Description *string `json:"description,omitempty"`
Name string `json:"name"`
Datasource *DashboardDataSourceRef `json:"datasource,omitempty"`
DefaultValue *DashboardVariableOption `json:"defaultValue,omitempty"`
Current DashboardVariableOption `json:"current"`
Options []DashboardVariableOption `json:"options"`
Multi bool `json:"multi"`
Label *string `json:"label,omitempty"`
Hide DashboardVariableHide `json:"hide"`
SkipUrlSync bool `json:"skipUrlSync"`
Description *string `json:"description,omitempty"`
}
// NewDashboardGroupByVariableSpec creates a new DashboardGroupByVariableSpec object.
@@ -78,6 +78,7 @@ export interface GroupByVariableModel extends VariableWithOptions {
datasource: DataSourceRef | null;
multi: true;
allowCustomValue?: boolean;
defaultValue?: VariableOption;
}
export interface VariableOption {
@@ -1290,6 +1290,7 @@ export const defaultGroupByVariableKind = (): GroupByVariableKind => ({
export interface GroupByVariableSpec {
name: string;
datasource?: DataSourceRef;
defaultValue?: VariableOption;
current: VariableOption;
options: VariableOption[];
multi: boolean;
@@ -251,6 +251,7 @@ export function createSceneVariableFromVariableModel(variable: TypedVariableMode
hide: variable.hide,
// @ts-expect-error
defaultOptions: variable.options,
defaultValue: variable.defaultValue,
allowCustomValue: variable.allowCustomValue,
});
} else {
+8 -8
View File
@@ -3490,10 +3490,10 @@ __metadata:
linkType: soft
"@grafana/scenes-react@npm:^6.12.0":
version: 6.12.0
resolution: "@grafana/scenes-react@npm:6.12.0"
version: 6.13.0
resolution: "@grafana/scenes-react@npm:6.13.0"
dependencies:
"@grafana/scenes": "npm:6.12.0"
"@grafana/scenes": "npm:6.13.0"
lru-cache: "npm:^10.2.2"
react-use: "npm:^17.4.0"
peerDependencies:
@@ -3505,13 +3505,13 @@ __metadata:
react: ^18.0.0
react-dom: ^18.0.0
react-router-dom: ^6.28.0
checksum: 10/56113394d169c96537a46ca5dc4c62eda54c6addd348c9e3321a122a6d01c19a14c57b04945ee3d836638f3dc1c1941f7647fa649495226432664e0ff8bd0af0
checksum: 10/8bbb098770d3b24fd60f4caa88579cd2e2327131061c7f54c25aa86688b4f4b7326d112515fe8ff3d62134af37af757d12d023c76dfaa68836f034e38f02da6d
languageName: node
linkType: hard
"@grafana/scenes@npm:6.12.0, @grafana/scenes@npm:^6.12.0":
version: 6.12.0
resolution: "@grafana/scenes@npm:6.12.0"
"@grafana/scenes@npm:6.13.0, @grafana/scenes@npm:^6.12.0":
version: 6.13.0
resolution: "@grafana/scenes@npm:6.13.0"
dependencies:
"@floating-ui/react": "npm:^0.26.16"
"@leeoniya/ufuzzy": "npm:^1.0.16"
@@ -3529,7 +3529,7 @@ __metadata:
react: ^18.0.0
react-dom: ^18.0.0
react-router-dom: ^6.28.0
checksum: 10/1bcddada8bf626d552aaa29ae4f916a50968bb36761285b0517500f50d8f52314148a8ed73419f381f8e5b901308cdf2450f0b82754691af512a2cff9f52b6bb
checksum: 10/62247045c095ac951c83059816214407e2fcf3736a61b536323616cdce08cd77a99b6a3532a1dbbe4f50ca26c94094a82e1713df84c37b0a7c0bebcf164b0b26
languageName: node
linkType: hard