keycloak-scim/js/apps/admin-ui/src/realm-settings/routes/RealmSettings.tsx
Erik Jan de Wit 13207aabac
Encode parameters for React Router links in URL-safe manner (#23667)
Closes #22600

Co-authored-by: Jon Koops <jonkoops@gmail.com>
2023-10-17 07:36:26 +00:00

50 lines
1.2 KiB
TypeScript

import { lazy } from "react";
import type { Path } from "react-router-dom";
import { generateEncodedPath } from "../../utils/generateEncodedPath";
import type { AppRouteObject } from "../../routes";
export type RealmSettingsTab =
| "general"
| "login"
| "email"
| "themes"
| "keys"
| "events"
| "localization"
| "security-defenses"
| "sessions"
| "tokens"
| "client-policies"
| "user-profile"
| "user-registration";
export type RealmSettingsParams = {
realm: string;
tab?: RealmSettingsTab;
};
const RealmSettingsSection = lazy(() => import("../RealmSettingsSection"));
export const RealmSettingsRoute: AppRouteObject = {
path: "/:realm/realm-settings",
element: <RealmSettingsSection />,
breadcrumb: (t) => t("realmSettings"),
handle: {
access: "view-realm",
},
};
export const RealmSettingsRouteWithTab: AppRouteObject = {
...RealmSettingsRoute,
path: "/:realm/realm-settings/:tab",
};
export const toRealmSettings = (params: RealmSettingsParams): Partial<Path> => {
const path = params.tab
? RealmSettingsRouteWithTab.path
: RealmSettingsRoute.path;
return {
pathname: generateEncodedPath(path, params),
};
};