routes.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { uniq } from 'lodash';
  2. import { SafeDynamicImport } from 'app/core/components/DynamicImports/SafeDynamicImport';
  3. import { config } from 'app/core/config';
  4. import { RouteDescriptor } from 'app/core/navigation/types';
  5. const profileRoutes: RouteDescriptor[] = [
  6. {
  7. path: '/profile',
  8. component: SafeDynamicImport(
  9. () => import(/* webpackChunkName: "UserProfileEditPage" */ 'app/features/profile/UserProfileEditPage')
  10. ),
  11. },
  12. {
  13. path: '/profile/password',
  14. component: SafeDynamicImport(
  15. () => import(/* webPackChunkName: "ChangePasswordPage" */ 'app/features/profile/ChangePasswordPage')
  16. ),
  17. },
  18. {
  19. path: '/profile/select-org',
  20. component: SafeDynamicImport(
  21. () => import(/* webpackChunkName: "SelectOrgPage" */ 'app/features/org/SelectOrgPage')
  22. ),
  23. },
  24. ];
  25. export function getProfileRoutes(cfg = config): RouteDescriptor[] {
  26. if (cfg.profileEnabled) {
  27. return profileRoutes;
  28. }
  29. const uniquePaths = uniq(profileRoutes.map((route) => route.path));
  30. return uniquePaths.map((path) => ({
  31. path,
  32. component: SafeDynamicImport(
  33. () => import(/* webpackChunkName: "ProfileFeatureTogglePage"*/ 'app/features/profile/FeatureTogglePage')
  34. ),
  35. }));
  36. }