1import { SafeDynamicImport } from 'app/core/components/DynamicImports/SafeDynamicImport';
2import { config } from 'app/core/config';
3import { RouteDescriptor } from 'app/core/navigation/types';
4import { isGrafanaAdmin } from 'app/features/plugins/admin/permissions';
5
6const liveRoutes = [
7  {
8    path: '/live',
9    component: SafeDynamicImport(
10      () => import(/* webpackChunkName: "LiveStatusPage" */ 'app/features/live/pages/LiveStatusPage')
11    ),
12  },
13  {
14    path: '/live/pipeline',
15    component: SafeDynamicImport(
16      () => import(/* webpackChunkName: "PipelineAdminPage" */ 'app/features/live/pages/PipelineAdminPage')
17    ),
18  },
19  {
20    path: '/live/cloud',
21    component: SafeDynamicImport(
22      () => import(/* webpackChunkName: "CloudAdminPage" */ 'app/features/live/pages/CloudAdminPage')
23    ),
24  },
25];
26
27export function getLiveRoutes(cfg = config): RouteDescriptor[] {
28  if (!isGrafanaAdmin()) {
29    return [];
30  }
31  if (cfg.featureToggles['live-pipeline']) {
32    return liveRoutes;
33  }
34  return liveRoutes.map((v) => ({
35    ...v,
36    component: SafeDynamicImport(
37      () => import(/* webpackChunkName: "FeatureTogglePage" */ 'app/features/live/pages/FeatureTogglePage')
38    ),
39  }));
40}
41