diff --git a/public/app/features/alerting/unified/components/receivers/ReceiversTable.test.tsx b/public/app/features/alerting/unified/components/receivers/ReceiversTable.test.tsx index 7195e2b70fb..e54f69bda8e 100644 --- a/public/app/features/alerting/unified/components/receivers/ReceiversTable.test.tsx +++ b/public/app/features/alerting/unified/components/receivers/ReceiversTable.test.tsx @@ -183,29 +183,13 @@ describe('ReceiversTable', () => { const notifiers: NotifierDTO[] = [mockNotifier('googlechat', 'Google Chat'), mockNotifier('sensugo', 'Sensu Go')]; - it('should be visible when user has permissions to read provisioning', async () => { - grantUserPermissions([AccessControlAction.AlertingProvisioningRead]); - - await renderReceieversTable(receivers, notifiers, GRAFANA_RULES_SOURCE_NAME); - - const buttons = within(screen.getByTestId('dynamic-table')).getAllByTestId('export'); - expect(buttons).toHaveLength(2); - }); - it('should be visible when user has permissions to read provisioning with secrets', async () => { - grantUserPermissions([AccessControlAction.AlertingProvisioningReadSecrets]); - - await renderReceieversTable(receivers, notifiers, GRAFANA_RULES_SOURCE_NAME); - - const buttons = within(screen.getByTestId('dynamic-table')).getAllByTestId('export'); - expect(buttons).toHaveLength(2); - }); - it('should not be visible when user has no provisioning permissions', async () => { + it('should be visible when user has permissions to read notifications', async () => { grantUserPermissions([AccessControlAction.AlertingNotificationsRead]); - await renderReceieversTable(receivers, [], GRAFANA_RULES_SOURCE_NAME); + await renderReceieversTable(receivers, notifiers, GRAFANA_RULES_SOURCE_NAME); - const buttons = within(screen.getByTestId('dynamic-table')).queryAllByTestId('export'); - expect(buttons).toHaveLength(0); + const buttons = within(screen.getByTestId('dynamic-table')).getAllByTestId('export'); + expect(buttons).toHaveLength(2); }); }); }); @@ -232,7 +216,7 @@ describe('ReceiversTable', () => { const notifiers: NotifierDTO[] = [mockNotifier('googlechat', 'Google Chat'), mockNotifier('sensugo', 'Sensu Go')]; - grantUserPermissions([AccessControlAction.AlertingProvisioningRead]); + grantUserPermissions([AccessControlAction.AlertingNotificationsRead]); // Act await renderReceieversTable(receivers, notifiers, GRAFANA_RULES_SOURCE_NAME); diff --git a/public/app/features/alerting/unified/hooks/__snapshots__/useAbilities.test.tsx.snap b/public/app/features/alerting/unified/hooks/__snapshots__/useAbilities.test.tsx.snap index 752ef4150f2..6b710d02d41 100644 --- a/public/app/features/alerting/unified/hooks/__snapshots__/useAbilities.test.tsx.snap +++ b/public/app/features/alerting/unified/hooks/__snapshots__/useAbilities.test.tsx.snap @@ -153,11 +153,11 @@ exports[`alertmanager abilities should report everything except exporting for Mi ], "export-contact-point": [ false, - false, + true, ], "export-notification-policies": [ false, - false, + true, ], "update-external-configuration": [ true, @@ -254,11 +254,11 @@ exports[`alertmanager abilities should report everything is supported for builti ], "export-contact-point": [ true, - false, + true, ], "export-notification-policies": [ true, - false, + true, ], "update-external-configuration": [ true, diff --git a/public/app/features/alerting/unified/hooks/useAbilities.test.tsx b/public/app/features/alerting/unified/hooks/useAbilities.test.tsx index f434d260f25..0354f4b500d 100644 --- a/public/app/features/alerting/unified/hooks/useAbilities.test.tsx +++ b/public/app/features/alerting/unified/hooks/useAbilities.test.tsx @@ -128,7 +128,7 @@ describe('alertmanager abilities', () => { expect(abilities.result.current).toHaveLength(3); expect(abilities.result.current[0]).toStrictEqual([true, true]); expect(abilities.result.current[1]).toStrictEqual([true, false]); - expect(abilities.result.current[2]).toStrictEqual([true, false]); + expect(abilities.result.current[2]).toStrictEqual([true, true]); }); }); diff --git a/public/app/features/alerting/unified/hooks/useAbilities.ts b/public/app/features/alerting/unified/hooks/useAbilities.ts index eb520364b6e..a23ed8c5666 100644 --- a/public/app/features/alerting/unified/hooks/useAbilities.ts +++ b/public/app/features/alerting/unified/hooks/useAbilities.ts @@ -131,8 +131,7 @@ export function useAllAlertmanagerAbilities(): Abilities { // only Grafana flavored alertmanager supports exporting [AlertmanagerAction.ExportContactPoint]: [ isGrafanaFlavoredAlertmanager, - ctx.hasPermission(notificationsPermissions.provisioning.read) || - ctx.hasPermission(notificationsPermissions.provisioning.readSecrets), + ctx.hasPermission(notificationsPermissions.read), ], // -- notification templates -- [AlertmanagerAction.CreateNotificationTemplate]: [ @@ -167,8 +166,7 @@ export function useAllAlertmanagerAbilities(): Abilities { ], [AlertmanagerAction.ExportNotificationPolicies]: [ isGrafanaFlavoredAlertmanager, - ctx.hasPermission(notificationsPermissions.provisioning.read) || - ctx.hasPermission(notificationsPermissions.provisioning.readSecrets), + ctx.hasPermission(notificationsPermissions.read), ], [AlertmanagerAction.DecryptSecrets]: [ isGrafanaFlavoredAlertmanager, diff --git a/public/app/features/alerting/unified/utils/access-control.ts b/public/app/features/alerting/unified/utils/access-control.ts index d71134a4659..af89606b4fd 100644 --- a/public/app/features/alerting/unified/utils/access-control.ts +++ b/public/app/features/alerting/unified/utils/access-control.ts @@ -123,8 +123,5 @@ export function getRulesAccess() { canEditRules: (rulesSourceName: string) => { return contextSrv.hasPermission(getRulesPermissions(rulesSourceName).update); }, - canReadProvisioning: - contextSrv.hasPermission(provisioningPermissions.read) || - contextSrv.hasPermission(provisioningPermissions.readSecrets), }; }