Fix default case for allowCustomValue flag in MultiValue variables (#96996)

* Fix default case for allowCustomValue flag in MultiValue variables

* fix test
pull/97140/head
Victor Marin 8 months ago committed by GitHub
parent 5f385632da
commit 61077f387e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 10
      public/app/features/dashboard-scene/serialization/__snapshots__/transformSceneToSaveModel.test.ts.snap
  2. 3
      public/app/features/dashboard-scene/utils/variables.test.ts
  3. 10
      public/app/features/dashboard-scene/utils/variables.ts

@ -288,7 +288,6 @@ exports[`transformSceneToSaveModel Given a scene with rows Should transform back
"templating": {
"list": [
{
"allowCustomValue": true,
"current": {
"text": [
"A",
@ -307,7 +306,6 @@ exports[`transformSceneToSaveModel Given a scene with rows Should transform back
"type": "custom",
},
{
"allowCustomValue": true,
"current": {
"text": [
"1",
@ -558,7 +556,6 @@ exports[`transformSceneToSaveModel Given a simple scene with custom settings Sho
"templating": {
"list": [
{
"allowCustomValue": true,
"baseFilters": [],
"datasource": {
"type": "prometheus",
@ -634,7 +631,6 @@ exports[`transformSceneToSaveModel Given a simple scene with custom settings Sho
"type": "interval",
},
{
"allowCustomValue": true,
"current": {
"text": [
"a",
@ -651,7 +647,6 @@ exports[`transformSceneToSaveModel Given a simple scene with custom settings Sho
"type": "custom",
},
{
"allowCustomValue": true,
"current": {
"text": "gdev-testdata",
"value": "PD8C576611E62080A",
@ -665,7 +660,6 @@ exports[`transformSceneToSaveModel Given a simple scene with custom settings Sho
"type": "datasource",
},
{
"allowCustomValue": true,
"current": {
"text": "A",
"value": "A",
@ -921,7 +915,6 @@ exports[`transformSceneToSaveModel Given a simple scene with variables Should tr
"templating": {
"list": [
{
"allowCustomValue": true,
"baseFilters": [],
"datasource": {
"type": "prometheus",
@ -997,7 +990,6 @@ exports[`transformSceneToSaveModel Given a simple scene with variables Should tr
"type": "interval",
},
{
"allowCustomValue": true,
"current": {
"text": [
"a",
@ -1014,7 +1006,6 @@ exports[`transformSceneToSaveModel Given a simple scene with variables Should tr
"type": "custom",
},
{
"allowCustomValue": true,
"current": {
"text": "gdev-testdata",
"value": "PD8C576611E62080A",
@ -1028,7 +1019,6 @@ exports[`transformSceneToSaveModel Given a simple scene with variables Should tr
"type": "datasource",
},
{
"allowCustomValue": true,
"current": {
"text": "A",
"value": "A",

@ -501,7 +501,6 @@ describe('when creating variables objects', () => {
expect(filterVarState).toEqual({
key: expect.any(String),
description: 'Adhoc Description',
allowCustomValue: true,
hide: 0,
label: 'Adhoc Label',
name: 'adhoc',
@ -674,7 +673,6 @@ describe('when creating variables objects', () => {
expect(migrated).toBeInstanceOf(DataSourceVariable);
expect(rest).toEqual({
allValue: 'Custom all',
allowCustomValue: true,
defaultToAll: true,
includeAll: true,
label: undefined,
@ -717,7 +715,6 @@ describe('when creating variables objects', () => {
expect(migrated).toBeInstanceOf(DataSourceVariable);
expect(rest).toEqual({
allValue: 'Custom all',
allowCustomValue: true,
defaultToAll: true,
includeAll: true,
label: undefined,

@ -138,7 +138,7 @@ export function createSceneVariableFromVariableModel(variable: TypedVariableMode
filters: variable.filters ?? [],
baseFilters: variable.baseFilters ?? [],
defaultKeys: variable.defaultKeys,
allowCustomValue: variable.allowCustomValue ?? true,
allowCustomValue: variable.allowCustomValue,
useQueriesAsFilterForOptions: true,
layout: config.featureToggles.newFiltersUI ? 'combobox' : undefined,
supportsMultiValueOperators: Boolean(
@ -159,7 +159,7 @@ export function createSceneVariableFromVariableModel(variable: TypedVariableMode
defaultToAll: Boolean(variable.includeAll),
skipUrlSync: variable.skipUrlSync,
hide: variable.hide,
allowCustomValue: variable.allowCustomValue ?? true,
allowCustomValue: variable.allowCustomValue,
});
} else if (variable.type === 'query') {
return new QueryVariable({
@ -179,7 +179,7 @@ export function createSceneVariableFromVariableModel(variable: TypedVariableMode
skipUrlSync: variable.skipUrlSync,
hide: variable.hide,
definition: variable.definition,
allowCustomValue: variable.allowCustomValue ?? true,
allowCustomValue: variable.allowCustomValue,
});
} else if (variable.type === 'datasource') {
return new DataSourceVariable({
@ -195,7 +195,7 @@ export function createSceneVariableFromVariableModel(variable: TypedVariableMode
isMulti: variable.multi,
hide: variable.hide,
defaultOptionEnabled: variable.current?.value === DEFAULT_DATASOURCE && variable.current?.text === 'default',
allowCustomValue: variable.allowCustomValue ?? true,
allowCustomValue: variable.allowCustomValue,
});
} else if (variable.type === 'interval') {
const intervals = getIntervalsFromQueryString(variable.query);
@ -246,7 +246,7 @@ export function createSceneVariableFromVariableModel(variable: TypedVariableMode
hide: variable.hide,
// @ts-expect-error
defaultOptions: variable.options,
allowCustomValue: variable.allowCustomValue ?? true,
allowCustomValue: variable.allowCustomValue,
});
} else {
throw new Error(`Scenes: Unsupported variable type ${variable.type}`);

Loading…
Cancel
Save