From 03f1bb950bfb06236ca32880dcf398ad926778ba Mon Sep 17 00:00:00 2001 From: Sergej-Vlasov <37613182+Sergej-Vlasov@users.noreply.github.com> Date: Tue, 20 May 2025 11:50:46 +0100 Subject: [PATCH] DashboardSchemaV2: add missing allowCustomValue property in variables (#105416) * add missing allowCustomValue property to variables in schema V2 * fix K8s Codegen Check * updade snapshots for backend tests --- .../kinds/v2alpha1/dashboard_spec.cue | 4 + .../dashboard/v2alpha1/dashboard_spec.cue | 4 + .../dashboard/v2alpha1/dashboard_spec_gen.go | 150 +++++++++--------- .../v2alpha1/zz_generated.openapi.go | 36 ++++- .../src/schema/dashboard/v2_examples.ts | 4 + .../dashboard/v2alpha1/types.spec.gen.ts | 8 + .../dashboard.grafana.app-v2alpha1.json | 28 +++- .../DashboardSceneSerializer.test.ts | 3 + ...sformSceneToSaveModelSchemaV2.test.ts.snap | 4 + .../sceneVariablesSetToVariables.test.ts | 5 + .../sceneVariablesSetToVariables.ts | 4 + .../v2schema/ImportDashboardFormV2.tsx | 2 +- .../v2schema/ImportDashboardOverviewV2.tsx | 6 +- .../dashboard/api/ResponseTransformers.ts | 4 + 14 files changed, 180 insertions(+), 82 deletions(-) diff --git a/apps/dashboard/kinds/v2alpha1/dashboard_spec.cue b/apps/dashboard/kinds/v2alpha1/dashboard_spec.cue index f2da39df16c..9f23a8e5b81 100644 --- a/apps/dashboard/kinds/v2alpha1/dashboard_spec.cue +++ b/apps/dashboard/kinds/v2alpha1/dashboard_spec.cue @@ -747,6 +747,7 @@ QueryVariableSpec: { includeAll: bool | *false allValue?: string placeholder?: string + allowCustomValue: bool | *true } // Query variable kind @@ -813,6 +814,7 @@ DatasourceVariableSpec: { hide: VariableHide skipUrlSync: bool | *false description?: string + allowCustomValue: bool | *true } // Datasource variable kind @@ -859,6 +861,7 @@ CustomVariableSpec: { hide: VariableHide skipUrlSync: bool | *false description?: string + allowCustomValue: bool | *true } // Custom variable kind @@ -900,6 +903,7 @@ AdhocVariableSpec: { hide: VariableHide skipUrlSync: bool | *false description?: string + allowCustomValue: bool | *true } // Define the MetricFindValue type diff --git a/apps/dashboard/pkg/apis/dashboard/v2alpha1/dashboard_spec.cue b/apps/dashboard/pkg/apis/dashboard/v2alpha1/dashboard_spec.cue index 85641129095..ba2bd0990de 100644 --- a/apps/dashboard/pkg/apis/dashboard/v2alpha1/dashboard_spec.cue +++ b/apps/dashboard/pkg/apis/dashboard/v2alpha1/dashboard_spec.cue @@ -751,6 +751,7 @@ QueryVariableSpec: { includeAll: bool | *false allValue?: string placeholder?: string + allowCustomValue: bool | *true } // Query variable kind @@ -817,6 +818,7 @@ DatasourceVariableSpec: { hide: VariableHide skipUrlSync: bool | *false description?: string + allowCustomValue: bool | *true } // Datasource variable kind @@ -863,6 +865,7 @@ CustomVariableSpec: { hide: VariableHide skipUrlSync: bool | *false description?: string + allowCustomValue: bool | *true } // Custom variable kind @@ -904,6 +907,7 @@ AdhocVariableSpec: { hide: VariableHide skipUrlSync: bool | *false description?: string + allowCustomValue: bool | *true } // Define the MetricFindValue type diff --git a/apps/dashboard/pkg/apis/dashboard/v2alpha1/dashboard_spec_gen.go b/apps/dashboard/pkg/apis/dashboard/v2alpha1/dashboard_spec_gen.go index 877c2acc44e..58e4396e8f6 100644 --- a/apps/dashboard/pkg/apis/dashboard/v2alpha1/dashboard_spec_gen.go +++ b/apps/dashboard/pkg/apis/dashboard/v2alpha1/dashboard_spec_gen.go @@ -1223,23 +1223,24 @@ func NewDashboardQueryVariableKind() *DashboardQueryVariableKind { // Query variable specification // +k8s:openapi-gen=true type DashboardQueryVariableSpec struct { - Name string `json:"name"` - Current DashboardVariableOption `json:"current"` - Label *string `json:"label,omitempty"` - Hide DashboardVariableHide `json:"hide"` - Refresh DashboardVariableRefresh `json:"refresh"` - SkipUrlSync bool `json:"skipUrlSync"` - Description *string `json:"description,omitempty"` - Datasource *DashboardDataSourceRef `json:"datasource,omitempty"` - Query DashboardDataQueryKind `json:"query"` - Regex string `json:"regex"` - Sort DashboardVariableSort `json:"sort"` - Definition *string `json:"definition,omitempty"` - Options []DashboardVariableOption `json:"options"` - Multi bool `json:"multi"` - IncludeAll bool `json:"includeAll"` - AllValue *string `json:"allValue,omitempty"` - Placeholder *string `json:"placeholder,omitempty"` + Name string `json:"name"` + Current DashboardVariableOption `json:"current"` + Label *string `json:"label,omitempty"` + Hide DashboardVariableHide `json:"hide"` + Refresh DashboardVariableRefresh `json:"refresh"` + SkipUrlSync bool `json:"skipUrlSync"` + Description *string `json:"description,omitempty"` + Datasource *DashboardDataSourceRef `json:"datasource,omitempty"` + Query DashboardDataQueryKind `json:"query"` + Regex string `json:"regex"` + Sort DashboardVariableSort `json:"sort"` + Definition *string `json:"definition,omitempty"` + Options []DashboardVariableOption `json:"options"` + Multi bool `json:"multi"` + IncludeAll bool `json:"includeAll"` + AllValue *string `json:"allValue,omitempty"` + Placeholder *string `json:"placeholder,omitempty"` + AllowCustomValue bool `json:"allowCustomValue"` } // NewDashboardQueryVariableSpec creates a new DashboardQueryVariableSpec object. @@ -1254,13 +1255,14 @@ func NewDashboardQueryVariableSpec() *DashboardQueryVariableSpec { String: (func(input string) *string { return &input })(""), }, }, - Hide: DashboardVariableHideDontHide, - Refresh: DashboardVariableRefreshNever, - SkipUrlSync: false, - Query: *NewDashboardDataQueryKind(), - Regex: "", - Multi: false, - IncludeAll: false, + Hide: DashboardVariableHideDontHide, + Refresh: DashboardVariableRefreshNever, + SkipUrlSync: false, + Query: *NewDashboardDataQueryKind(), + Regex: "", + Multi: false, + IncludeAll: false, + AllowCustomValue: true, } } @@ -1442,19 +1444,20 @@ func NewDashboardDatasourceVariableKind() *DashboardDatasourceVariableKind { // Datasource variable specification // +k8s:openapi-gen=true type DashboardDatasourceVariableSpec struct { - Name string `json:"name"` - PluginId string `json:"pluginId"` - Refresh DashboardVariableRefresh `json:"refresh"` - Regex string `json:"regex"` - Current DashboardVariableOption `json:"current"` - Options []DashboardVariableOption `json:"options"` - Multi bool `json:"multi"` - IncludeAll bool `json:"includeAll"` - AllValue *string `json:"allValue,omitempty"` - Label *string `json:"label,omitempty"` - Hide DashboardVariableHide `json:"hide"` - SkipUrlSync bool `json:"skipUrlSync"` - Description *string `json:"description,omitempty"` + Name string `json:"name"` + PluginId string `json:"pluginId"` + Refresh DashboardVariableRefresh `json:"refresh"` + Regex string `json:"regex"` + Current DashboardVariableOption `json:"current"` + Options []DashboardVariableOption `json:"options"` + Multi bool `json:"multi"` + IncludeAll bool `json:"includeAll"` + AllValue *string `json:"allValue,omitempty"` + Label *string `json:"label,omitempty"` + Hide DashboardVariableHide `json:"hide"` + SkipUrlSync bool `json:"skipUrlSync"` + Description *string `json:"description,omitempty"` + AllowCustomValue bool `json:"allowCustomValue"` } // NewDashboardDatasourceVariableSpec creates a new DashboardDatasourceVariableSpec object. @@ -1472,10 +1475,11 @@ func NewDashboardDatasourceVariableSpec() *DashboardDatasourceVariableSpec { String: (func(input string) *string { return &input })(""), }, }, - Multi: false, - IncludeAll: false, - Hide: DashboardVariableHideDontHide, - SkipUrlSync: false, + Multi: false, + IncludeAll: false, + Hide: DashboardVariableHideDontHide, + SkipUrlSync: false, + AllowCustomValue: true, } } @@ -1551,29 +1555,31 @@ func NewDashboardCustomVariableKind() *DashboardCustomVariableKind { // Custom variable specification // +k8s:openapi-gen=true type DashboardCustomVariableSpec struct { - Name string `json:"name"` - Query string `json:"query"` - Current DashboardVariableOption `json:"current"` - Options []DashboardVariableOption `json:"options"` - Multi bool `json:"multi"` - IncludeAll bool `json:"includeAll"` - AllValue *string `json:"allValue,omitempty"` - Label *string `json:"label,omitempty"` - Hide DashboardVariableHide `json:"hide"` - SkipUrlSync bool `json:"skipUrlSync"` - Description *string `json:"description,omitempty"` + Name string `json:"name"` + Query string `json:"query"` + Current DashboardVariableOption `json:"current"` + Options []DashboardVariableOption `json:"options"` + Multi bool `json:"multi"` + IncludeAll bool `json:"includeAll"` + AllValue *string `json:"allValue,omitempty"` + Label *string `json:"label,omitempty"` + Hide DashboardVariableHide `json:"hide"` + SkipUrlSync bool `json:"skipUrlSync"` + Description *string `json:"description,omitempty"` + AllowCustomValue bool `json:"allowCustomValue"` } // NewDashboardCustomVariableSpec creates a new DashboardCustomVariableSpec object. func NewDashboardCustomVariableSpec() *DashboardCustomVariableSpec { return &DashboardCustomVariableSpec{ - Name: "", - Query: "", - Current: *NewDashboardVariableOption(), - Multi: false, - IncludeAll: false, - Hide: DashboardVariableHideDontHide, - SkipUrlSync: false, + Name: "", + Query: "", + Current: *NewDashboardVariableOption(), + Multi: false, + IncludeAll: false, + Hide: DashboardVariableHideDontHide, + SkipUrlSync: false, + AllowCustomValue: true, } } @@ -1642,23 +1648,25 @@ func NewDashboardAdhocVariableKind() *DashboardAdhocVariableKind { // Adhoc variable specification // +k8s:openapi-gen=true type DashboardAdhocVariableSpec struct { - Name string `json:"name"` - Datasource *DashboardDataSourceRef `json:"datasource,omitempty"` - BaseFilters []DashboardAdHocFilterWithLabels `json:"baseFilters"` - Filters []DashboardAdHocFilterWithLabels `json:"filters"` - DefaultKeys []DashboardMetricFindValue `json:"defaultKeys"` - 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"` + BaseFilters []DashboardAdHocFilterWithLabels `json:"baseFilters"` + Filters []DashboardAdHocFilterWithLabels `json:"filters"` + DefaultKeys []DashboardMetricFindValue `json:"defaultKeys"` + Label *string `json:"label,omitempty"` + Hide DashboardVariableHide `json:"hide"` + SkipUrlSync bool `json:"skipUrlSync"` + Description *string `json:"description,omitempty"` + AllowCustomValue bool `json:"allowCustomValue"` } // NewDashboardAdhocVariableSpec creates a new DashboardAdhocVariableSpec object. func NewDashboardAdhocVariableSpec() *DashboardAdhocVariableSpec { return &DashboardAdhocVariableSpec{ - Name: "", - Hide: DashboardVariableHideDontHide, - SkipUrlSync: false, + Name: "", + Hide: DashboardVariableHideDontHide, + SkipUrlSync: false, + AllowCustomValue: true, } } diff --git a/apps/dashboard/pkg/apis/dashboard/v2alpha1/zz_generated.openapi.go b/apps/dashboard/pkg/apis/dashboard/v2alpha1/zz_generated.openapi.go index f20dea39d2b..a206d843e59 100644 --- a/apps/dashboard/pkg/apis/dashboard/v2alpha1/zz_generated.openapi.go +++ b/apps/dashboard/pkg/apis/dashboard/v2alpha1/zz_generated.openapi.go @@ -513,8 +513,15 @@ func schema_pkg_apis_dashboard_v2alpha1_DashboardAdhocVariableSpec(ref common.Re Format: "", }, }, + "allowCustomValue": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, }, - Required: []string{"name", "baseFilters", "filters", "defaultKeys", "hide", "skipUrlSync"}, + Required: []string{"name", "baseFilters", "filters", "defaultKeys", "hide", "skipUrlSync", "allowCustomValue"}, }, }, Dependencies: []string{ @@ -1344,8 +1351,15 @@ func schema_pkg_apis_dashboard_v2alpha1_DashboardCustomVariableSpec(ref common.R Format: "", }, }, + "allowCustomValue": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, }, - Required: []string{"name", "query", "current", "options", "multi", "includeAll", "hide", "skipUrlSync"}, + Required: []string{"name", "query", "current", "options", "multi", "includeAll", "hide", "skipUrlSync", "allowCustomValue"}, }, }, Dependencies: []string{ @@ -1727,8 +1741,15 @@ func schema_pkg_apis_dashboard_v2alpha1_DashboardDatasourceVariableSpec(ref comm Format: "", }, }, + "allowCustomValue": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, }, - Required: []string{"name", "pluginId", "refresh", "regex", "current", "options", "multi", "includeAll", "hide", "skipUrlSync"}, + Required: []string{"name", "pluginId", "refresh", "regex", "current", "options", "multi", "includeAll", "hide", "skipUrlSync", "allowCustomValue"}, }, }, Dependencies: []string{ @@ -3403,8 +3424,15 @@ func schema_pkg_apis_dashboard_v2alpha1_DashboardQueryVariableSpec(ref common.Re Format: "", }, }, + "allowCustomValue": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, }, - Required: []string{"name", "current", "hide", "refresh", "skipUrlSync", "query", "regex", "sort", "options", "multi", "includeAll"}, + Required: []string{"name", "current", "hide", "refresh", "skipUrlSync", "query", "regex", "sort", "options", "multi", "includeAll", "allowCustomValue"}, }, }, Dependencies: []string{ diff --git a/packages/grafana-schema/src/schema/dashboard/v2_examples.ts b/packages/grafana-schema/src/schema/dashboard/v2_examples.ts index ce7bf8565de..446936890db 100644 --- a/packages/grafana-schema/src/schema/dashboard/v2_examples.ts +++ b/packages/grafana-schema/src/schema/dashboard/v2_examples.ts @@ -366,6 +366,7 @@ export const handyTestingSchema: Spec = { regex: 'regex1', skipUrlSync: false, sort: 'disabled', + allowCustomValue: true, }, }, { @@ -396,6 +397,7 @@ export const handyTestingSchema: Spec = { ], query: 'option1, option2', skipUrlSync: false, + allowCustomValue: true, }, }, { @@ -416,6 +418,7 @@ export const handyTestingSchema: Spec = { refresh: 'onDashboardLoad', regex: 'regex1', skipUrlSync: false, + allowCustomValue: true, }, }, { @@ -555,6 +558,7 @@ export const handyTestingSchema: Spec = { label: 'Adhoc Variable', name: 'adhocVar', skipUrlSync: false, + allowCustomValue: true, }, }, ], diff --git a/packages/grafana-schema/src/schema/dashboard/v2alpha1/types.spec.gen.ts b/packages/grafana-schema/src/schema/dashboard/v2alpha1/types.spec.gen.ts index cee005bb943..5956f2b61a8 100644 --- a/packages/grafana-schema/src/schema/dashboard/v2alpha1/types.spec.gen.ts +++ b/packages/grafana-schema/src/schema/dashboard/v2alpha1/types.spec.gen.ts @@ -1030,6 +1030,7 @@ export interface QueryVariableSpec { includeAll: boolean; allValue?: string; placeholder?: string; + allowCustomValue: boolean; } export const defaultQueryVariableSpec = (): QueryVariableSpec => ({ @@ -1044,6 +1045,7 @@ export const defaultQueryVariableSpec = (): QueryVariableSpec => ({ options: [], multi: false, includeAll: false, + allowCustomValue: true, }); // Variable option specification @@ -1177,6 +1179,7 @@ export interface DatasourceVariableSpec { hide: VariableHide; skipUrlSync: boolean; description?: string; + allowCustomValue: boolean; } export const defaultDatasourceVariableSpec = (): DatasourceVariableSpec => ({ @@ -1190,6 +1193,7 @@ export const defaultDatasourceVariableSpec = (): DatasourceVariableSpec => ({ includeAll: false, hide: "dontHide", skipUrlSync: false, + allowCustomValue: true, }); // Interval variable kind @@ -1256,6 +1260,7 @@ export interface CustomVariableSpec { hide: VariableHide; skipUrlSync: boolean; description?: string; + allowCustomValue: boolean; } export const defaultCustomVariableSpec = (): CustomVariableSpec => ({ @@ -1267,6 +1272,7 @@ export const defaultCustomVariableSpec = (): CustomVariableSpec => ({ includeAll: false, hide: "dontHide", skipUrlSync: false, + allowCustomValue: true, }); // Group variable kind @@ -1324,6 +1330,7 @@ export interface AdhocVariableSpec { hide: VariableHide; skipUrlSync: boolean; description?: string; + allowCustomValue: boolean; } export const defaultAdhocVariableSpec = (): AdhocVariableSpec => ({ @@ -1333,6 +1340,7 @@ export const defaultAdhocVariableSpec = (): AdhocVariableSpec => ({ defaultKeys: [], hide: "dontHide", skipUrlSync: false, + allowCustomValue: true, }); // Define the AdHocFilterWithLabels type diff --git a/pkg/tests/apis/openapi_snapshots/dashboard.grafana.app-v2alpha1.json b/pkg/tests/apis/openapi_snapshots/dashboard.grafana.app-v2alpha1.json index 296e6a4e6bf..bde9543fc20 100644 --- a/pkg/tests/apis/openapi_snapshots/dashboard.grafana.app-v2alpha1.json +++ b/pkg/tests/apis/openapi_snapshots/dashboard.grafana.app-v2alpha1.json @@ -1141,9 +1141,14 @@ "filters", "defaultKeys", "hide", - "skipUrlSync" + "skipUrlSync", + "allowCustomValue" ], "properties": { + "allowCustomValue": { + "type": "boolean", + "default": false + }, "baseFilters": { "type": "array", "items": { @@ -1705,12 +1710,17 @@ "multi", "includeAll", "hide", - "skipUrlSync" + "skipUrlSync", + "allowCustomValue" ], "properties": { "allValue": { "type": "string" }, + "allowCustomValue": { + "type": "boolean", + "default": false + }, "current": { "default": {}, "allOf": [ @@ -1954,12 +1964,17 @@ "multi", "includeAll", "hide", - "skipUrlSync" + "skipUrlSync", + "allowCustomValue" ], "properties": { "allValue": { "type": "string" }, + "allowCustomValue": { + "type": "boolean", + "default": false + }, "current": { "default": {}, "allOf": [ @@ -3022,12 +3037,17 @@ "sort", "options", "multi", - "includeAll" + "includeAll", + "allowCustomValue" ], "properties": { "allValue": { "type": "string" }, + "allowCustomValue": { + "type": "boolean", + "default": false + }, "current": { "default": {}, "allOf": [ diff --git a/public/app/features/dashboard-scene/serialization/DashboardSceneSerializer.test.ts b/public/app/features/dashboard-scene/serialization/DashboardSceneSerializer.test.ts index 20f42a76150..0e39748c270 100644 --- a/public/app/features/dashboard-scene/serialization/DashboardSceneSerializer.test.ts +++ b/public/app/features/dashboard-scene/serialization/DashboardSceneSerializer.test.ts @@ -624,6 +624,7 @@ describe('DashboardSceneSerializer', () => { value: 'region', }, ], + allowCustomValue: true, }, }, ], @@ -822,6 +823,7 @@ describe('DashboardSceneSerializer', () => { options: [], query: 'app1', skipUrlSync: false, + allowCustomValue: true, }, }, ]); @@ -1293,6 +1295,7 @@ function setupV2(spec?: Partial) { query: 'app1', allValue: '', includeAll: false, + allowCustomValue: true, }, }, ], diff --git a/public/app/features/dashboard-scene/serialization/__snapshots__/transformSceneToSaveModelSchemaV2.test.ts.snap b/public/app/features/dashboard-scene/serialization/__snapshots__/transformSceneToSaveModelSchemaV2.test.ts.snap index c630c36d2e6..8933d1adde3 100644 --- a/public/app/features/dashboard-scene/serialization/__snapshots__/transformSceneToSaveModelSchemaV2.test.ts.snap +++ b/public/app/features/dashboard-scene/serialization/__snapshots__/transformSceneToSaveModelSchemaV2.test.ts.snap @@ -212,6 +212,7 @@ exports[`transformSceneToSaveModelSchemaV2 should transform scene to save model "kind": "QueryVariable", "spec": { "allValue": "*", + "allowCustomValue": true, "current": { "text": "text1", "value": "value1", @@ -245,6 +246,7 @@ exports[`transformSceneToSaveModelSchemaV2 should transform scene to save model "kind": "CustomVariable", "spec": { "allValue": "All", + "allowCustomValue": true, "current": { "text": "option1", "value": "option1", @@ -274,6 +276,7 @@ exports[`transformSceneToSaveModelSchemaV2 should transform scene to save model { "kind": "DatasourceVariable", "spec": { + "allowCustomValue": true, "current": { "text": "text1", "value": "value1", @@ -389,6 +392,7 @@ exports[`transformSceneToSaveModelSchemaV2 should transform scene to save model { "kind": "AdhocVariable", "spec": { + "allowCustomValue": true, "baseFilters": [ { "condition": "AND", diff --git a/public/app/features/dashboard-scene/serialization/sceneVariablesSetToVariables.test.ts b/public/app/features/dashboard-scene/serialization/sceneVariablesSetToVariables.test.ts index 5be471f6617..b3ad17b6d0c 100644 --- a/public/app/features/dashboard-scene/serialization/sceneVariablesSetToVariables.test.ts +++ b/public/app/features/dashboard-scene/serialization/sceneVariablesSetToVariables.test.ts @@ -881,6 +881,7 @@ describe('sceneVariablesSetToVariables', () => { "kind": "QueryVariable", "spec": { "allValue": "test-all", + "allowCustomValue": true, "current": { "text": [ "selected-value-text", @@ -945,6 +946,7 @@ describe('sceneVariablesSetToVariables', () => { "kind": "CustomVariable", "spec": { "allValue": "test-all", + "allowCustomValue": true, "current": { "text": [ "test", @@ -1009,6 +1011,7 @@ describe('sceneVariablesSetToVariables', () => { "kind": "DatasourceVariable", "spec": { "allValue": "test-all", + "allowCustomValue": true, "current": { "text": [ "selected-ds-1-text", @@ -1197,6 +1200,7 @@ describe('sceneVariablesSetToVariables', () => { { "kind": "AdhocVariable", "spec": { + "allowCustomValue": true, "baseFilters": [ { "key": "baseFilterTest", @@ -1272,6 +1276,7 @@ describe('sceneVariablesSetToVariables', () => { { "kind": "AdhocVariable", "spec": { + "allowCustomValue": true, "baseFilters": [ { "key": "baseFilterTest", diff --git a/public/app/features/dashboard-scene/serialization/sceneVariablesSetToVariables.ts b/public/app/features/dashboard-scene/serialization/sceneVariablesSetToVariables.ts index 9747eb8600d..0fb26ec87cc 100644 --- a/public/app/features/dashboard-scene/serialization/sceneVariablesSetToVariables.ts +++ b/public/app/features/dashboard-scene/serialization/sceneVariablesSetToVariables.ts @@ -314,6 +314,7 @@ export function sceneVariablesSetToSchemaV2Variables( includeAll: variable.state.includeAll || false, multi: variable.state.isMulti || false, skipUrlSync: variable.state.skipUrlSync || false, + allowCustomValue: variable.state.allowCustomValue ?? true, }, }; variables.push(queryVariable); @@ -329,6 +330,7 @@ export function sceneVariablesSetToSchemaV2Variables( multi: variable.state.isMulti || false, allValue: variable.state.allValue, includeAll: variable.state.includeAll ?? false, + allowCustomValue: variable.state.allowCustomValue ?? true, }, }; variables.push(customVariable); @@ -344,6 +346,7 @@ export function sceneVariablesSetToSchemaV2Variables( pluginId: variable.state.pluginId, multi: variable.state.isMulti || false, includeAll: variable.state.includeAll || false, + allowCustomValue: variable.state.allowCustomValue ?? true, }, }; @@ -436,6 +439,7 @@ export function sceneVariablesSetToSchemaV2Variables( baseFilters: validateFiltersOrigin(variable.state.baseFilters), filters: validateFiltersOrigin(variable.state.filters), defaultKeys: variable.state.defaultKeys || [], //FIXME what is the default value? + allowCustomValue: variable.state.allowCustomValue ?? true, }, }; variables.push(adhocVariable); diff --git a/public/app/features/dashboard-scene/v2schema/ImportDashboardFormV2.tsx b/public/app/features/dashboard-scene/v2schema/ImportDashboardFormV2.tsx index 09307cd9f21..c2726533a9b 100644 --- a/public/app/features/dashboard-scene/v2schema/ImportDashboardFormV2.tsx +++ b/public/app/features/dashboard-scene/v2schema/ImportDashboardFormV2.tsx @@ -4,7 +4,7 @@ import { Controller, FieldErrors, UseFormReturn } from 'react-hook-form'; import { selectors } from '@grafana/e2e-selectors'; import { Trans, useTranslate } from '@grafana/i18n'; import { ExpressionDatasourceRef } from '@grafana/runtime/internal'; -import { DashboardV2Spec } from '@grafana/schema/dist/esm/schema/dashboard/v2alpha0'; +import { Spec as DashboardV2Spec } from '@grafana/schema/dist/esm/schema/dashboard/v2alpha1/types.spec.gen'; import { Button, Field, FormFieldErrors, FormsOnSubmit, Stack, Input } from '@grafana/ui'; import { FolderPicker } from 'app/core/components/Select/FolderPicker'; import { SaveDashboardCommand } from 'app/features/dashboard/components/SaveDashboard/types'; diff --git a/public/app/features/dashboard-scene/v2schema/ImportDashboardOverviewV2.tsx b/public/app/features/dashboard-scene/v2schema/ImportDashboardOverviewV2.tsx index 0452e0c7907..0d7ccaea603 100644 --- a/public/app/features/dashboard-scene/v2schema/ImportDashboardOverviewV2.tsx +++ b/public/app/features/dashboard-scene/v2schema/ImportDashboardOverviewV2.tsx @@ -2,8 +2,10 @@ import { useState } from 'react'; import { locationUtil } from '@grafana/data'; import { locationService, reportInteraction } from '@grafana/runtime'; -import { DashboardV2Spec } from '@grafana/schema/dist/esm/schema/dashboard/v2alpha0'; -import { AnnotationQueryKind } from '@grafana/schema/dist/esm/schema/dashboard/v2alpha1/types.spec.gen'; +import { + AnnotationQueryKind, + Spec as DashboardV2Spec, +} from '@grafana/schema/dist/esm/schema/dashboard/v2alpha1/types.spec.gen'; import { Form } from 'app/core/components/Form/Form'; import { getDashboardAPI } from 'app/features/dashboard/api/dashboard_api'; import { SaveDashboardCommand } from 'app/features/dashboard/components/SaveDashboard/types'; diff --git a/public/app/features/dashboard/api/ResponseTransformers.ts b/public/app/features/dashboard/api/ResponseTransformers.ts index 8164206d708..0d358d1a890 100644 --- a/public/app/features/dashboard/api/ResponseTransformers.ts +++ b/public/app/features/dashboard/api/ResponseTransformers.ts @@ -515,6 +515,7 @@ function getVariables(vars: TypedVariableModel[]): DashboardV2Spec['variables'] kind: v.datasource?.type || getDefaultDatasourceType(), spec: query, }, + allowCustomValue: v.allowCustomValue ?? true, }, }; variables.push(qv); @@ -541,6 +542,7 @@ function getVariables(vars: TypedVariableModel[]): DashboardV2Spec['variables'] refresh: transformVariableRefreshToEnum(v.refresh), pluginId, regex: v.regex || '', + allowCustomValue: v.allowCustomValue ?? true, }, }; variables.push(dv); @@ -559,6 +561,7 @@ function getVariables(vars: TypedVariableModel[]): DashboardV2Spec['variables'] multi: v.multi, includeAll: v.includeAll, ...(v.allValue && { allValue: v.allValue }), + allowCustomValue: v.allowCustomValue ?? true, }, }; variables.push(cv); @@ -572,6 +575,7 @@ function getVariables(vars: TypedVariableModel[]): DashboardV2Spec['variables'] baseFilters: v.baseFilters || [], filters: v.filters || [], defaultKeys: v.defaultKeys || [], + allowCustomValue: v.allowCustomValue ?? true, }, }; variables.push(av);