grafana/public/app/features/profile/routes.tsx
Cameron Waterman 8426cfe400
Profile/Help: Expose option to disable profile section and help menu (#46308)
* Expose option to disable help menu

* Expose option to disable profile menu

* Add Profile FeatureTogglePage

* Update public/app/features/profile/FeatureTogglePage.tsx

Uptake PR wording suggestion.

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>

* Fix front end lint issue

* Fix back end lint issue

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
2022-03-29 16:27:53 +01:00

40 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 { uniq } from 'lodash';
const profileRoutes: RouteDescriptor[] = [
{
path: '/profile',
component: SafeDynamicImport(
() => import(/* webpackChunkName: "UserProfileEditPage" */ 'app/features/profile/UserProfileEditPage')
),
},
{
path: '/profile/password',
component: SafeDynamicImport(
() => import(/* webPackChunkName: "ChangePasswordPage" */ 'app/features/profile/ChangePasswordPage')
),
},
{
path: '/profile/select-org',
component: SafeDynamicImport(
() => import(/* webpackChunkName: "SelectOrgPage" */ 'app/features/org/SelectOrgPage')
),
},
];
export function getProfileRoutes(cfg = config): RouteDescriptor[] {
if (cfg.profileEnabled) {
return profileRoutes;
}
const uniquePaths = uniq(profileRoutes.map((route) => route.path));
return uniquePaths.map((path) => ({
path,
component: SafeDynamicImport(
() => import(/* webpackChunkName: "Profile feature toggle page"*/ 'app/features/profile/FeatureTogglePage')
),
}));
}