diff --git a/public/app/plugins/datasource/cloudwatch/components/QueryEditor/QueryHeader.test.tsx b/public/app/plugins/datasource/cloudwatch/components/QueryEditor/QueryHeader.test.tsx index 01af5b18121..5658dedf92f 100644 --- a/public/app/plugins/datasource/cloudwatch/components/QueryEditor/QueryHeader.test.tsx +++ b/public/app/plugins/datasource/cloudwatch/components/QueryEditor/QueryHeader.test.tsx @@ -26,14 +26,19 @@ describe('QueryHeader', () => { { value: 'us-east-2', label: 'us-east-2' }, { value: 'us-east-1', label: 'us-east-1' }, ]); - it('should reset account id if new region is not monitoring account', async () => { + it('should reset account id and log groups if new region is not monitoring account', async () => { config.featureToggles.cloudWatchCrossAccountQuerying = true; const onChange = jest.fn(); datasource.resources.isMonitoringAccount = jest.fn().mockResolvedValue(false); render( { ...validMetricSearchBuilderQuery, region: 'us-east-2', accountId: undefined, + logGroups: [], }); }); - it('should not reset account id if new region is a monitoring account', async () => { + it('should reset log groups but not account id if new region is a monitoring account', async () => { config.featureToggles.cloudWatchCrossAccountQuerying = true; const onChange = jest.fn(); datasource.resources.isMonitoringAccount = jest.fn().mockResolvedValue(true); @@ -56,7 +62,12 @@ describe('QueryHeader', () => { render( { ...validMetricSearchBuilderQuery, region: 'us-east-2', accountId: '123', + logGroups: [], }); }); diff --git a/public/app/plugins/datasource/cloudwatch/components/QueryEditor/QueryHeader.tsx b/public/app/plugins/datasource/cloudwatch/components/QueryEditor/QueryHeader.tsx index d252f1fa78d..57568a0666e 100644 --- a/public/app/plugins/datasource/cloudwatch/components/QueryEditor/QueryHeader.tsx +++ b/public/app/plugins/datasource/cloudwatch/components/QueryEditor/QueryHeader.tsx @@ -47,9 +47,9 @@ const QueryHeader = ({ const onRegionChange = async (region: string) => { if (config.featureToggles.cloudWatchCrossAccountQuerying && isCloudWatchMetricsQuery(query)) { const isMonitoringAccount = await datasource.resources.isMonitoringAccount(region); - onChange({ ...query, region, accountId: isMonitoringAccount ? query.accountId : undefined }); + onChange({ ...query, logGroups: [], region, accountId: isMonitoringAccount ? query.accountId : undefined }); } else { - onChange({ ...query, region }); + onChange({ ...query, logGroups: [], region }); } };