From eedb613a5ee60d4aae68202f616ed464aaab20e9 Mon Sep 17 00:00:00 2001 From: "Marc M." <146180665+grafakus@users.noreply.github.com> Date: Thu, 27 Nov 2025 15:41:38 +0100 Subject: [PATCH] Dashboards: Don't store options when saving a dashboard with Query/Custom variables (#114540) --- .../src/schema/dashboard/v2_examples.ts | 13 +------ ...sformSceneToSaveModelSchemaV2.test.ts.snap | 13 +------ .../sceneVariablesSetToVariables.test.ts | 36 ++----------------- .../sceneVariablesSetToVariables.ts | 13 +++---- 4 files changed, 8 insertions(+), 67 deletions(-) diff --git a/packages/grafana-schema/src/schema/dashboard/v2_examples.ts b/packages/grafana-schema/src/schema/dashboard/v2_examples.ts index 649546e17e1..7c542121a7b 100644 --- a/packages/grafana-schema/src/schema/dashboard/v2_examples.ts +++ b/packages/grafana-schema/src/schema/dashboard/v2_examples.ts @@ -312,18 +312,7 @@ export const handyTestingSchema: Spec = { label: 'Custom Variable', multi: true, name: 'customVar', - options: [ - { - selected: true, - text: 'option1', - value: 'option1', - }, - { - selected: false, - text: 'option2', - value: 'option2', - }, - ], + options: [], query: 'option1, option2', skipUrlSync: 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 6bddc68fb09..add2123cdad 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 @@ -194,18 +194,7 @@ exports[`transformSceneToSaveModelSchemaV2 should transform scene to save model "label": "Custom Variable", "multi": true, "name": "customVar", - "options": [ - { - "selected": true, - "text": "option1", - "value": "option1", - }, - { - "selected": false, - "text": "option2", - "value": "option2", - }, - ], + "options": [], "query": "option1, option2", "skipUrlSync": false, }, diff --git a/public/app/features/dashboard-scene/serialization/sceneVariablesSetToVariables.test.ts b/public/app/features/dashboard-scene/serialization/sceneVariablesSetToVariables.test.ts index 8772646b496..cc49cfadc77 100644 --- a/public/app/features/dashboard-scene/serialization/sceneVariablesSetToVariables.test.ts +++ b/public/app/features/dashboard-scene/serialization/sceneVariablesSetToVariables.test.ts @@ -371,23 +371,7 @@ describe('sceneVariablesSetToVariables', () => { "label": "test-label", "multi": true, "name": "test", - "options": [ - { - "selected": true, - "text": "test", - "value": "test", - }, - { - "selected": false, - "text": "test1", - "value": "test1", - }, - { - "selected": true, - "text": "test2", - "value": "test2", - }, - ], + "options": [], "query": "test,test1,test2", "type": "custom", } @@ -1161,23 +1145,7 @@ describe('sceneVariablesSetToVariables', () => { "label": "test-label", "multi": true, "name": "test", - "options": [ - { - "selected": true, - "text": "test", - "value": "test", - }, - { - "selected": false, - "text": "test1", - "value": "test1", - }, - { - "selected": true, - "text": "test2", - "value": "test2", - }, - ], + "options": [], "query": "test,test1,test2", "skipUrlSync": false, }, diff --git a/public/app/features/dashboard-scene/serialization/sceneVariablesSetToVariables.ts b/public/app/features/dashboard-scene/serialization/sceneVariablesSetToVariables.ts index 49b84626f97..fa7c2cc3855 100644 --- a/public/app/features/dashboard-scene/serialization/sceneVariablesSetToVariables.ts +++ b/public/app/features/dashboard-scene/serialization/sceneVariablesSetToVariables.ts @@ -66,9 +66,7 @@ export function sceneVariablesSetToVariables(set: SceneVariables, keepQueryOptio if (sceneUtils.isQueryVariable(variable)) { let options: VariableOption[] = []; - // Not sure if we actually have to still support this option given - // that it's not exposed in the UI - if (transformVariableRefreshToEnum(variable.state.refresh) === 'never' || keepQueryOptions) { + if (keepQueryOptions) { options = variableValueOptionsToVariableOptions(variable.state); } variables.push({ @@ -106,7 +104,7 @@ export function sceneVariablesSetToVariables(set: SceneVariables, keepQueryOptio // @ts-expect-error value: variable.state.value, }, - options: variableValueOptionsToVariableOptions(variable.state), + options: [], query: variable.state.query, multi: variable.state.isMulti, allValue: variable.state.allValue, @@ -319,9 +317,7 @@ export function sceneVariablesSetToSchemaV2Variables( // Query variable if (sceneUtils.isQueryVariable(variable)) { - // Not sure if we actually have to still support this option given - // that it's not exposed in the UI - if (transformVariableRefreshToEnum(variable.state.refresh) === 'never' || keepQueryOptions) { + if (keepQueryOptions) { options = variableValueOptionsToVariableOptions(variable.state); } const query = variable.state.query; @@ -385,13 +381,12 @@ export function sceneVariablesSetToSchemaV2Variables( // Custom variable } else if (sceneUtils.isCustomVariable(variable)) { - options = variableValueOptionsToVariableOptions(variable.state); const customVariable: CustomVariableKind = { kind: 'CustomVariable', spec: { ...commonProperties, current: currentVariableOption, - options, + options: [], query: variable.state.query, multi: variable.state.isMulti || false, allValue: variable.state.allValue,