routes.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { SafeDynamicImport } from 'app/core/components/DynamicImports/SafeDynamicImport';
  2. import { RouteDescriptor } from 'app/core/navigation/types';
  3. import { isGrafanaAdmin } from './permissions';
  4. import { PluginAdminRoutes } from './types';
  5. const DEFAULT_ROUTES = [
  6. {
  7. path: '/plugins',
  8. routeName: PluginAdminRoutes.Home,
  9. component: SafeDynamicImport(() => import(/* webpackChunkName: "PluginListPage" */ './pages/Browse')),
  10. },
  11. {
  12. path: '/plugins/browse',
  13. routeName: PluginAdminRoutes.Browse,
  14. component: SafeDynamicImport(() => import(/* webpackChunkName: "PluginListPage" */ './pages/Browse')),
  15. },
  16. {
  17. path: '/plugins/:pluginId/',
  18. routeName: PluginAdminRoutes.Details,
  19. component: SafeDynamicImport(() => import(/* webpackChunkName: "PluginPage" */ './pages/PluginDetails')),
  20. },
  21. ];
  22. const ADMIN_ROUTES = [
  23. {
  24. path: '/admin/plugins',
  25. routeName: PluginAdminRoutes.HomeAdmin,
  26. component: SafeDynamicImport(() => import(/* webpackChunkName: "PluginListPage" */ './pages/Browse')),
  27. },
  28. {
  29. path: '/admin/plugins/browse',
  30. routeName: PluginAdminRoutes.BrowseAdmin,
  31. component: SafeDynamicImport(() => import(/* webpackChunkName: "PluginListPage" */ './pages/Browse')),
  32. },
  33. {
  34. path: '/admin/plugins/:pluginId/',
  35. routeName: PluginAdminRoutes.DetailsAdmin,
  36. component: SafeDynamicImport(() => import(/* webpackChunkName: "PluginPage" */ './pages/PluginDetails')),
  37. },
  38. ];
  39. export function getRoutes(): RouteDescriptor[] {
  40. if (isGrafanaAdmin()) {
  41. return [...DEFAULT_ROUTES, ...ADMIN_ROUTES];
  42. }
  43. return DEFAULT_ROUTES;
  44. }