diff --git a/.betterer.results b/.betterer.results index 1b1be082a78..e0902c91260 100644 --- a/.betterer.results +++ b/.betterer.results @@ -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"] diff --git a/public/app/features/variables/state/processVariable.test.ts b/public/app/features/variables/state/processVariable.test.ts index 92867f02116..6448f202eb4 100644 --- a/public/app/features/variables/state/processVariable.test.ts +++ b/public/app/features/variables/state/processVariable.test.ts @@ -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))) + ) ); }); }); diff --git a/public/app/features/variables/utils.ts b/public/app/features/variables/utils.ts index aa6d033bd6f..b3bd198f570 100644 --- a/public/app/features/variables/utils.ts +++ b/public/app/features/variables/utils.ts @@ -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 }> {