mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Azure Monitor: Add validation for namespace field in AdvancedResourcePicker when entering a forward slash (#89288)
* Add validation for namespace field in AdvancedResourcePicker when entering a forward slash * Add test * Fix formatting * Remove unused import
This commit is contained in:
parent
92233350f8
commit
0bdd613f3b
@ -101,4 +101,17 @@ describe('AdvancedResourcePicker', () => {
|
||||
expect(screen.getByDisplayValue('rg2')).toBeInTheDocument();
|
||||
expect(screen.getByDisplayValue('res2')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should display an error when the namespace field ends in a /', async () => {
|
||||
const onChange = jest.fn();
|
||||
|
||||
render(
|
||||
<AdvancedResourcePicker
|
||||
onChange={onChange}
|
||||
resources={[{ metricNamespace: 'Microsoft.OperationalInsights/workspaces/' }]}
|
||||
/>
|
||||
);
|
||||
|
||||
expect(screen.getByText('Namespace cannot end with a "/"')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
@ -81,6 +81,8 @@ const AdvancedResourcePicker = ({ resources, onChange }: ResourcePickerProps<Azu
|
||||
htmlFor={`input-advanced-resource-picker-metricNamespace`}
|
||||
labelWidth={15}
|
||||
data-testid={selectors.components.queryEditor.resourcePicker.advanced.namespace.input}
|
||||
invalid={resources[0]?.metricNamespace?.endsWith('/')}
|
||||
error={'Namespace cannot end with a "/"'}
|
||||
>
|
||||
<Input
|
||||
id={`input-advanced-resource-picker-metricNamespace`}
|
||||
|
Loading…
Reference in New Issue
Block a user