AzureMonitor: Clear queries if header value changes (#67916)

Clear queries if header value changes
This commit is contained in:
Andreas Christou
2023-05-05 16:46:58 +01:00
committed by GitHub
parent 6f4d4a6750
commit 765ae6cd90
2 changed files with 6 additions and 3 deletions

View File

@@ -88,7 +88,8 @@ describe('Azure Monitor QueryEditor', () => {
await selectOptionInTest(metrics, 'Logs');
expect(onChange).toHaveBeenCalledWith({
...mockQuery,
refId: mockQuery.refId,
datasource: mockQuery.datasource,
queryType: AzureQueryType.LogAnalytics,
});
});

View File

@@ -21,11 +21,13 @@ export const QueryHeader = ({ query, onQueryChange }: QueryTypeFieldProps) => {
const handleChange = useCallback(
(change: SelectableValue<AzureQueryType>) => {
change.value &&
if (change.value && change.value !== query.queryType) {
onQueryChange({
...query,
refId: query.refId,
datasource: query.datasource,
queryType: change.value,
});
}
},
[onQueryChange, query]
);