mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Templating: Json interpolation of single-value default selection does not create valid json (#79137)
This commit is contained in:
parent
5192150191
commit
31d79c0502
@ -305,7 +305,7 @@ describe('shared actions', () => {
|
|||||||
key,
|
key,
|
||||||
setCurrentVariableValue(
|
setCurrentVariableValue(
|
||||||
toVariablePayload(stats, {
|
toVariablePayload(stats, {
|
||||||
option: { text: ALL_VARIABLE_TEXT, value: ALL_VARIABLE_VALUE, selected: false },
|
option: { text: [ALL_VARIABLE_TEXT], value: [ALL_VARIABLE_VALUE], selected: true },
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
@ -473,8 +473,8 @@ describe('shared actions', () => {
|
|||||||
${['A', 'B', 'C']} | ${['B']} | ${'C'} | ${['B']} | ${true}
|
${['A', 'B', 'C']} | ${['B']} | ${'C'} | ${['B']} | ${true}
|
||||||
${['A', 'B', 'C']} | ${['B', 'C']} | ${undefined} | ${['B', 'C']} | ${true}
|
${['A', 'B', 'C']} | ${['B', 'C']} | ${undefined} | ${['B', 'C']} | ${true}
|
||||||
${['A', 'B', 'C']} | ${['B', 'C']} | ${'C'} | ${['B', 'C']} | ${true}
|
${['A', 'B', 'C']} | ${['B', 'C']} | ${'C'} | ${['B', 'C']} | ${true}
|
||||||
${['A', 'B', 'C']} | ${['X']} | ${undefined} | ${'A'} | ${false}
|
${['A', 'B', 'C']} | ${['X']} | ${undefined} | ${['A']} | ${true}
|
||||||
${['A', 'B', 'C']} | ${['X']} | ${'C'} | ${'A'} | ${false}
|
${['A', 'B', 'C']} | ${['X']} | ${'C'} | ${['A']} | ${true}
|
||||||
`(
|
`(
|
||||||
'then correct actions are dispatched',
|
'then correct actions are dispatched',
|
||||||
async ({ withOptions, withCurrent, defaultValue, expectedText, expectedSelected }) => {
|
async ({ withOptions, withCurrent, defaultValue, expectedText, expectedSelected }) => {
|
||||||
|
@ -506,7 +506,11 @@ export const validateVariableSelectionState = (
|
|||||||
// if none pick first
|
// if none pick first
|
||||||
if (selected.length === 0) {
|
if (selected.length === 0) {
|
||||||
const option = variableInState.options[0];
|
const option = variableInState.options[0];
|
||||||
return setValue(variableInState, option);
|
return setValue(variableInState, {
|
||||||
|
value: typeof option.value === 'string' ? [option.value] : option.value,
|
||||||
|
text: typeof option.text === 'string' ? [option.text] : option.text,
|
||||||
|
selected: true,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const option: VariableOption = {
|
const option: VariableOption = {
|
||||||
|
Loading…
Reference in New Issue
Block a user