AccessControl: add permission to datasource permissions navigation selection (#38758)

This commit is contained in:
Gabriel MABILLE 2021-09-06 16:18:18 +02:00 committed by GitHub
parent d5956ce4b7
commit cf7034ee50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 7 deletions

View File

@ -1,5 +1,7 @@
import { DataSourceSettings, PluginType, PluginInclude, NavModel, NavModelItem } from '@grafana/data';
import config from 'app/core/config';
import { contextSrv } from 'app/core/core';
import { AccessControlAction } from 'app/types';
import { GenericDataSourcePlugin } from '../settings/PluginSettings';
export function buildNavModel(dataSource: DataSourceSettings, plugin: GenericDataSourcePlugin): NavModelItem {
@ -46,13 +48,15 @@ export function buildNavModel(dataSource: DataSourceSettings, plugin: GenericDat
}
if (config.licenseInfo.hasLicense) {
navModel.children!.push({
active: false,
icon: 'lock',
id: `datasource-permissions-${dataSource.id}`,
text: 'Permissions',
url: `datasources/edit/${dataSource.id}/permissions`,
});
if (contextSrv.hasPermission(AccessControlAction.DataSourcesPermissionsRead)) {
navModel.children!.push({
active: false,
icon: 'lock',
id: `datasource-permissions-${dataSource.id}`,
text: 'Permissions',
url: `datasources/edit/${dataSource.id}/permissions`,
});
}
navModel.children!.push({
active: false,

View File

@ -39,6 +39,7 @@ export enum AccessControlAction {
DataSourcesCreate = 'datasources:create',
DataSourcesWrite = 'datasources:write',
DataSourcesDelete = 'datasources:delete',
DataSourcesPermissionsRead = 'datasources.permissions:read',
ActionServerStatsRead = 'server.stats:read',
}