mirror of
https://github.com/grafana/grafana.git
synced 2026-07-30 00:08:10 -05:00
Alerting: Implement correct RBAC checks for creating new notification templates (#83767)
This commit is contained in:
@@ -127,6 +127,11 @@ describe('contact points', () => {
|
||||
const deleteButton = await screen.queryByRole('menuitem', { name: 'delete' });
|
||||
expect(deleteButton).toBeDisabled();
|
||||
}
|
||||
|
||||
// check buttons in Notification Templates
|
||||
const notificationTemplatesTab = screen.getByRole('tab', { name: 'Tab Notification Templates' });
|
||||
await userEvent.click(notificationTemplatesTab);
|
||||
expect(screen.getByRole('link', { name: 'Add notification template' })).toHaveAttribute('aria-disabled', 'true');
|
||||
});
|
||||
|
||||
it('should call delete when clicked and not disabled', async () => {
|
||||
@@ -326,6 +331,11 @@ describe('contact points', () => {
|
||||
const viewProvisioned = screen.getByRole('link', { name: 'view-action' });
|
||||
expect(viewProvisioned).toBeInTheDocument();
|
||||
expect(viewProvisioned).not.toBeDisabled();
|
||||
|
||||
// check buttons in Notification Templates
|
||||
const notificationTemplatesTab = screen.getByRole('tab', { name: 'Tab Notification Templates' });
|
||||
await userEvent.click(notificationTemplatesTab);
|
||||
expect(screen.queryByRole('link', { name: 'Add notification template' })).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -81,6 +81,9 @@ const ContactPoints = () => {
|
||||
const [exportContactPointsSupported, exportContactPointsAllowed] = useAlertmanagerAbility(
|
||||
AlertmanagerAction.ExportContactPoint
|
||||
);
|
||||
const [createTemplateSupported, createTemplateAllowed] = useAlertmanagerAbility(
|
||||
AlertmanagerAction.CreateNotificationTemplate
|
||||
);
|
||||
|
||||
const [DeleteModal, showDeleteModal] = useDeleteContactPointModal(deleteTrigger, updateAlertmanagerState.isLoading);
|
||||
const [ExportDrawer, showExportDrawer] = useExportContactPoint();
|
||||
@@ -177,9 +180,16 @@ const ContactPoints = () => {
|
||||
Create notification templates to customize your notifications.
|
||||
</Text>
|
||||
<Spacer />
|
||||
<LinkButton icon="plus" variant="primary" href="/alerting/notifications/templates/new">
|
||||
Add notification template
|
||||
</LinkButton>
|
||||
{createTemplateSupported && (
|
||||
<LinkButton
|
||||
icon="plus"
|
||||
variant="primary"
|
||||
href="/alerting/notifications/templates/new"
|
||||
disabled={!createTemplateAllowed}
|
||||
>
|
||||
Add notification template
|
||||
</LinkButton>
|
||||
)}
|
||||
</Stack>
|
||||
<NotificationTemplates />
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user