mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
RBAC: Hide the root level dashboard creation button from users who can't create dashboards on root level (#92942)
hide the root level dashboard creation button from users who can't create dashboards on the root level
This commit is contained in:
parent
1f7ebde0de
commit
700636b3b9
@ -3,10 +3,7 @@ import { contextSrv } from 'app/core/core';
|
||||
import { AccessControlAction, FolderDTO } from 'app/types';
|
||||
|
||||
function checkFolderPermission(action: AccessControlAction, folderDTO?: FolderDTO) {
|
||||
// Only some permissions are assigned in the root folder (aka "general" folder), so we can ignore them in most cases
|
||||
return folderDTO && folderDTO.uid !== 'general'
|
||||
? contextSrv.hasPermissionInMetadata(action, folderDTO)
|
||||
: contextSrv.hasPermission(action);
|
||||
return folderDTO ? contextSrv.hasPermissionInMetadata(action, folderDTO) : contextSrv.hasPermission(action);
|
||||
}
|
||||
|
||||
function checkCanCreateFolders(folderDTO?: FolderDTO) {
|
||||
@ -25,9 +22,7 @@ function checkCanCreateFolders(folderDTO?: FolderDTO) {
|
||||
);
|
||||
}
|
||||
|
||||
return folderDTO
|
||||
? contextSrv.hasPermissionInMetadata(AccessControlAction.FoldersCreate, folderDTO)
|
||||
: contextSrv.hasPermission(AccessControlAction.FoldersCreate);
|
||||
return checkFolderPermission(AccessControlAction.FoldersCreate, folderDTO);
|
||||
}
|
||||
|
||||
export function getFolderPermissions(folderDTO?: FolderDTO) {
|
||||
|
Loading…
Reference in New Issue
Block a user