permissions.ts 512 B

123456789101112131415161718
  1. import { config } from 'app/core/config';
  2. import { contextSrv } from 'app/core/services/context_srv';
  3. import { AccessControlAction } from 'app/types';
  4. export function isGrafanaAdmin(): boolean {
  5. return config.bootData.user.isGrafanaAdmin;
  6. }
  7. export function isOrgAdmin() {
  8. return contextSrv.hasRole('Admin');
  9. }
  10. export function isDataSourceEditor() {
  11. return (
  12. contextSrv.hasPermission(AccessControlAction.DataSourcesCreate) &&
  13. contextSrv.hasPermission(AccessControlAction.DataSourcesWrite)
  14. );
  15. }