mirror of
https://github.com/grafana/grafana.git
synced 2026-07-30 00:08:10 -05:00
Add permission checking to alert rules in the folders view (#47686)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { NavModel, NavModelItem } from '@grafana/data';
|
||||
import { contextSrv } from 'app/core/services/context_srv';
|
||||
|
||||
import { FolderDTO } from 'app/types';
|
||||
import { AccessControlAction, FolderDTO } from 'app/types';
|
||||
|
||||
export function buildNavModel(folder: FolderDTO): NavModelItem {
|
||||
const model = {
|
||||
@@ -29,13 +30,15 @@ export function buildNavModel(folder: FolderDTO): NavModelItem {
|
||||
url: `${folder.url}/library-panels`,
|
||||
});
|
||||
|
||||
model.children.push({
|
||||
active: false,
|
||||
icon: 'bell',
|
||||
id: `folder-alerting-${folder.uid}`,
|
||||
text: 'Alert rules',
|
||||
url: `${folder.url}/alerting`,
|
||||
});
|
||||
if (contextSrv.hasPermission(AccessControlAction.AlertingRuleRead)) {
|
||||
model.children.push({
|
||||
active: false,
|
||||
icon: 'bell',
|
||||
id: `folder-alerting-${folder.uid}`,
|
||||
text: 'Alert rules',
|
||||
url: `${folder.url}/alerting`,
|
||||
});
|
||||
}
|
||||
|
||||
if (folder.canAdmin) {
|
||||
model.children.push({
|
||||
|
||||
@@ -406,6 +406,8 @@ export function getAppRoutes(): RouteDescriptor[] {
|
||||
},
|
||||
{
|
||||
path: '/dashboards/f/:uid/:slug/alerting',
|
||||
roles: () =>
|
||||
contextSrv.evaluatePermission(() => ['Viewer', 'Editor', 'Admin'], [AccessControlAction.AlertingRuleRead]),
|
||||
component: SafeDynamicImport(
|
||||
() => import(/* webpackChunkName: "FolderAlerting"*/ 'app/features/folders/FolderAlerting')
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user