From 21e082447c56cc7dd3c693fa276bf80658904dec Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Fri, 5 May 2023 16:59:21 +0100 Subject: [PATCH] [v10.0.x] AzureMonitor: Clear queries if header value changes (#67930) AzureMonitor: Clear queries if header value changes (#67916) Clear queries if header value changes (cherry picked from commit 765ae6cd90c341804b5df1763725bf9d2b6fdce1) Co-authored-by: Andreas Christou --- .../components/QueryEditor/QueryEditor.test.tsx | 3 ++- .../datasource/azuremonitor/components/QueryHeader.tsx | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/public/app/plugins/datasource/azuremonitor/components/QueryEditor/QueryEditor.test.tsx b/public/app/plugins/datasource/azuremonitor/components/QueryEditor/QueryEditor.test.tsx index 74ec7c498d9..18621f8bbf4 100644 --- a/public/app/plugins/datasource/azuremonitor/components/QueryEditor/QueryEditor.test.tsx +++ b/public/app/plugins/datasource/azuremonitor/components/QueryEditor/QueryEditor.test.tsx @@ -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, }); }); diff --git a/public/app/plugins/datasource/azuremonitor/components/QueryHeader.tsx b/public/app/plugins/datasource/azuremonitor/components/QueryHeader.tsx index 3a3c77c81ea..fd2f60578bf 100644 --- a/public/app/plugins/datasource/azuremonitor/components/QueryHeader.tsx +++ b/public/app/plugins/datasource/azuremonitor/components/QueryHeader.tsx @@ -21,11 +21,13 @@ export const QueryHeader = ({ query, onQueryChange }: QueryTypeFieldProps) => { const handleChange = useCallback( (change: SelectableValue) => { - change.value && + if (change.value && change.value !== query.queryType) { onQueryChange({ - ...query, + refId: query.refId, + datasource: query.datasource, queryType: change.value, }); + } }, [onQueryChange, query] );