grafana/public/app/features/live/pages/routes.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

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')
),
}));
}