grafana/public/app/features/plugins/admin/permissions.ts
Marcus Andersson fe11a31175
PluginsCatalog: disable post-installation steps if user does not have sufficient permissions (#40853)
* added missing permissions check

* moved the permission check to the datasource component.

* added test for checking permissions.

* added tests with different permissions.

* minor refactoring so the mockUserPermisson can be reused.
2021-10-26 15:18:12 +02:00

19 lines
512 B
TypeScript

import { config } from 'app/core/config';
import { contextSrv } from 'app/core/services/context_srv';
import { AccessControlAction } from 'app/types';
export function isGrafanaAdmin(): boolean {
return config.bootData.user.isGrafanaAdmin;
}
export function isOrgAdmin() {
return contextSrv.hasRole('Admin');
}
export function isDataSourceEditor() {
return (
contextSrv.hasPermission(AccessControlAction.DataSourcesCreate) &&
contextSrv.hasPermission(AccessControlAction.DataSourcesWrite)
);
}