routes.ts 1.2 KB

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