mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* 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.
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import { SafeDynamicImport } from 'app/core/components/DynamicImports/SafeDynamicImport';
|
|
import { config } from 'app/core/config';
|
|
import { RouteDescriptor } from 'app/core/navigation/types';
|
|
import { isGrafanaAdmin } from 'app/features/plugins/admin/permissions';
|
|
|
|
const liveRoutes = [
|
|
{
|
|
path: '/live',
|
|
component: SafeDynamicImport(
|
|
() => import(/* webpackChunkName: "LiveStatusPage" */ 'app/features/live/pages/LiveStatusPage')
|
|
),
|
|
},
|
|
{
|
|
path: '/live/pipeline',
|
|
component: SafeDynamicImport(
|
|
() => import(/* webpackChunkName: "PipelineAdminPage" */ 'app/features/live/pages/PipelineAdminPage')
|
|
),
|
|
},
|
|
{
|
|
path: '/live/cloud',
|
|
component: SafeDynamicImport(
|
|
() => import(/* webpackChunkName: "CloudAdminPage" */ 'app/features/live/pages/CloudAdminPage')
|
|
),
|
|
},
|
|
];
|
|
|
|
export function getLiveRoutes(cfg = config): RouteDescriptor[] {
|
|
if (!isGrafanaAdmin()) {
|
|
return [];
|
|
}
|
|
if (cfg.featureToggles['live-pipeline']) {
|
|
return liveRoutes;
|
|
}
|
|
return liveRoutes.map((v) => ({
|
|
...v,
|
|
component: SafeDynamicImport(
|
|
() => import(/* webpackChunkName: "FeatureTogglePage" */ 'app/features/live/pages/FeatureTogglePage')
|
|
),
|
|
}));
|
|
}
|