mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Templating: Fix issue where updated custom var options weren't persisted (#86804)
* Templating: Fix issue where updated custom var options weren't persisted
This commit is contained in:
@@ -3559,11 +3559,10 @@ exports[`better eslint`] = {
|
||||
[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.", "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.", "5"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "7"]
|
||||
[0, 0, 0, "Do not use any type assertions.", "6"]
|
||||
],
|
||||
"public/app/features/visualization/data-hover/DataHoverRows.tsx:5381": [
|
||||
[0, 0, 0, "Styles should be written using objects.", "0"]
|
||||
|
||||
@@ -152,6 +152,21 @@ describe('processVariable', () => {
|
||||
.whenAsyncActionIsDispatched(processVariable(toKeyedVariableIdentifier(custom), queryParams), true);
|
||||
|
||||
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(
|
||||
key,
|
||||
setCurrentVariableValue(
|
||||
@@ -160,8 +175,7 @@ describe('processVariable', () => {
|
||||
{ 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 {
|
||||
if (!variable || !variable.hasOwnProperty('refresh')) {
|
||||
return VariableRefresh.never;
|
||||
if (variable?.type === 'custom') {
|
||||
return VariableRefresh.onDashboardLoad;
|
||||
}
|
||||
|
||||
const queryVariable = variable as QueryVariableModel;
|
||||
|
||||
if (
|
||||
queryVariable.refresh !== VariableRefresh.onTimeRangeChanged &&
|
||||
queryVariable.refresh !== VariableRefresh.onDashboardLoad &&
|
||||
queryVariable.refresh !== VariableRefresh.never
|
||||
!variable ||
|
||||
!('refresh' in variable) ||
|
||||
(variable.refresh !== VariableRefresh.onTimeRangeChanged && variable.refresh !== VariableRefresh.onDashboardLoad)
|
||||
) {
|
||||
return VariableRefresh.never;
|
||||
}
|
||||
|
||||
return queryVariable.refresh;
|
||||
return variable.refresh;
|
||||
}
|
||||
|
||||
export function getVariableTypes(): Array<{ label: string; value: VariableType }> {
|
||||
|
||||
Reference in New Issue
Block a user