[v10.4.x] Templating: Fix issue where updated custom var options weren't persisted (#87557)
Templating: Fix issue where updated custom var options weren't persisted (#86804)
* Templating: Fix issue where updated custom var options weren't persisted
(cherry picked from commit d5c781b9c5)
Co-authored-by: kay delaney <45561153+kaydelaney@users.noreply.github.com>
This commit is contained in:
co-authored by
kay delaney
parent
654db2500a
commit
cbbd6b1f7f
+2
-3
@@ -4570,11 +4570,10 @@ exports[`better eslint`] = {
|
|||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
|
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
|
||||||
[0, 0, 0, "Do not use any type assertions.", "3"],
|
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
|
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
|
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
|
[0, 0, 0, "Do not use any type assertions.", "6"]
|
||||||
[0, 0, 0, "Do not use any type assertions.", "7"]
|
|
||||||
],
|
],
|
||||||
"public/app/features/visualization/data-hover/DataHoverRows.tsx:5381": [
|
"public/app/features/visualization/data-hover/DataHoverRows.tsx:5381": [
|
||||||
[0, 0, 0, "Styles should be written using objects.", "0"]
|
[0, 0, 0, "Styles should be written using objects.", "0"]
|
||||||
|
|||||||
@@ -152,6 +152,21 @@ describe('processVariable', () => {
|
|||||||
.whenAsyncActionIsDispatched(processVariable(toKeyedVariableIdentifier(custom), queryParams), true);
|
.whenAsyncActionIsDispatched(processVariable(toKeyedVariableIdentifier(custom), queryParams), true);
|
||||||
|
|
||||||
await tester.thenDispatchedActionsShouldEqual(
|
await tester.thenDispatchedActionsShouldEqual(
|
||||||
|
toKeyedAction(key, variableStateFetching(toVariablePayload({ type: 'custom', id: 'custom' }))),
|
||||||
|
toKeyedAction(
|
||||||
|
key,
|
||||||
|
createCustomOptionsFromQuery(toVariablePayload({ type: 'custom', id: 'custom' }, 'A,B,C'))
|
||||||
|
),
|
||||||
|
toKeyedAction(
|
||||||
|
key,
|
||||||
|
setCurrentVariableValue(
|
||||||
|
toVariablePayload(
|
||||||
|
{ type: 'custom', id: 'custom' },
|
||||||
|
{ option: { text: 'A', value: 'A', selected: false } }
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
toKeyedAction(key, variableStateCompleted(toVariablePayload(custom))),
|
||||||
toKeyedAction(
|
toKeyedAction(
|
||||||
key,
|
key,
|
||||||
setCurrentVariableValue(
|
setCurrentVariableValue(
|
||||||
@@ -160,8 +175,7 @@ describe('processVariable', () => {
|
|||||||
{ option: { text: 'B', value: 'B', selected: false } }
|
{ option: { text: 'B', value: 'B', selected: false } }
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
),
|
)
|
||||||
toKeyedAction(key, variableStateCompleted(toVariablePayload(custom)))
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -156,21 +156,19 @@ export function getLegacyQueryOptions(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getVariableRefresh(variable: VariableModel): VariableRefresh {
|
export function getVariableRefresh(variable: VariableModel): VariableRefresh {
|
||||||
if (!variable || !variable.hasOwnProperty('refresh')) {
|
if (variable?.type === 'custom') {
|
||||||
return VariableRefresh.never;
|
return VariableRefresh.onDashboardLoad;
|
||||||
}
|
}
|
||||||
|
|
||||||
const queryVariable = variable as QueryVariableModel;
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
queryVariable.refresh !== VariableRefresh.onTimeRangeChanged &&
|
!variable ||
|
||||||
queryVariable.refresh !== VariableRefresh.onDashboardLoad &&
|
!('refresh' in variable) ||
|
||||||
queryVariable.refresh !== VariableRefresh.never
|
(variable.refresh !== VariableRefresh.onTimeRangeChanged && variable.refresh !== VariableRefresh.onDashboardLoad)
|
||||||
) {
|
) {
|
||||||
return VariableRefresh.never;
|
return VariableRefresh.never;
|
||||||
}
|
}
|
||||||
|
|
||||||
return queryVariable.refresh;
|
return variable.refresh;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getVariableTypes(): Array<{ label: string; value: VariableType }> {
|
export function getVariableTypes(): Array<{ label: string; value: VariableType }> {
|
||||||
|
|||||||
Reference in New Issue
Block a user