diff --git a/public/app/plugins/datasource/azuremonitor/components/ResourcePicker/NestedRow.test.tsx b/public/app/plugins/datasource/azuremonitor/components/ResourcePicker/NestedRow.test.tsx index 541bd7a4b04..f7c2d2e96ad 100644 --- a/public/app/plugins/datasource/azuremonitor/components/ResourcePicker/NestedRow.test.tsx +++ b/public/app/plugins/datasource/azuremonitor/components/ResourcePicker/NestedRow.test.tsx @@ -84,4 +84,75 @@ describe('NestedRow', () => { const box = screen.queryByRole('checkbox'); expect(box).toBeChecked(); }); + + it('should display the resource group if available', () => { + render( + + + + +
+ ); + + expect(screen.getByText('test-rg')).toBeInTheDocument(); + }); + + it('should not display the resource group if row is a subscription', () => { + render( + + + + +
+ ); + + const rg = screen.queryByText('test-rg'); + expect(rg).not.toBeInTheDocument(); + }); + + it('should not display the resource group if row is a resource group', () => { + render( + + + + +
+ ); + + const rg = screen.queryByText('test-rg'); + expect(rg).not.toBeInTheDocument(); + }); }); diff --git a/public/app/plugins/datasource/azuremonitor/components/ResourcePicker/NestedRow.tsx b/public/app/plugins/datasource/azuremonitor/components/ResourcePicker/NestedRow.tsx index 9b38c782dec..763e8f5f96b 100644 --- a/public/app/plugins/datasource/azuremonitor/components/ResourcePicker/NestedRow.tsx +++ b/public/app/plugins/datasource/azuremonitor/components/ResourcePicker/NestedRow.tsx @@ -7,7 +7,7 @@ import { FadeTransition, LoadingPlaceholder, useStyles2 } from '@grafana/ui'; import { NestedEntry } from './NestedEntry'; import getStyles from './styles'; import { ResourceRow, ResourceRowGroup, ResourceRowType } from './types'; -import { findRow } from './utils'; +import { findRow, parseResourceURI } from './utils'; interface NestedRowProps { row: ResourceRow; @@ -36,6 +36,7 @@ const NestedRow = ({ const isSelected = !!selectedRows.find((v) => v.uri.toLowerCase() === row.uri.toLowerCase()); const isDisabled = !isSelected && disableRow(row, selectedRows); const isOpen = rowStatus === 'open'; + const parsedURI = parseResourceURI(row.uri); const onRowToggleCollapse = async () => { if (rowStatus === 'open') { @@ -63,7 +64,7 @@ const NestedRow = ({ return ( <> - + - {row.typeLabel} + + { + // eslint-disable-next-line @grafana/i18n/no-untranslated-strings + parsedURI.resourceGroup && row.type === ResourceRowType.Resource ? parsedURI.resourceGroup : '-' + } + + + {row.typeLabel} + - {row.location ?? '-'} + + {row.location ?? '-'} + {isOpen && diff --git a/public/app/plugins/datasource/azuremonitor/components/ResourcePicker/ResourcePicker.tsx b/public/app/plugins/datasource/azuremonitor/components/ResourcePicker/ResourcePicker.tsx index 6ff5bc11137..3bacbdc2a81 100644 --- a/public/app/plugins/datasource/azuremonitor/components/ResourcePicker/ResourcePicker.tsx +++ b/public/app/plugins/datasource/azuremonitor/components/ResourcePicker/ResourcePicker.tsx @@ -310,6 +310,9 @@ const ResourcePicker = ({ Scope + + Resource Group + Type diff --git a/public/app/plugins/datasource/azuremonitor/locales/en-US/grafana-azure-monitor-datasource.json b/public/app/plugins/datasource/azuremonitor/locales/en-US/grafana-azure-monitor-datasource.json index 8edff81b97c..46adc53413c 100644 --- a/public/app/plugins/datasource/azuremonitor/locales/en-US/grafana-azure-monitor-datasource.json +++ b/public/app/plugins/datasource/azuremonitor/locales/en-US/grafana-azure-monitor-datasource.json @@ -231,6 +231,7 @@ "button-apply": "Apply", "button-cancel": "Cancel", "header-location": "Location", + "header-resource-group": "Resource Group", "header-scope": "Scope", "header-type": "Type", "heading-selection": "Selection",