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

* Fix default case for allowCustomValue flag in MultiValue variables

* fix test
This commit is contained in:
Victor Marin
2024-11-29 10:38:19 +02:00
committed by GitHub
parent 5f385632da
commit 61077f387e
3 changed files with 5 additions and 18 deletions
@@ -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}`);