Use new routing conventions for session routes (#902)

This commit is contained in:
Jon Koops 2021-07-23 12:52:08 +02:00 committed by GitHub
parent 74ac0110c6
commit d1d99f7ee0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 7 deletions

View file

@ -29,7 +29,7 @@ import {
RealmSettingsSection,
} from "./realm-settings/RealmSettingsSection";
import realmRoutes from "./realm/routes";
import { SessionsSection } from "./sessions/SessionsSection";
import sessionRoutes from "./sessions/routes";
import { LdapMapperDetails } from "./user-federation/ldap/mappers/LdapMapperDetails";
import { UserFederationKerberosSettings } from "./user-federation/UserFederationKerberosSettings";
import { UserFederationLdapSettings } from "./user-federation/UserFederationLdapSettings";
@ -50,13 +50,8 @@ export const routes: RouteDef[] = [
...clientScopesRoutes,
...realmRoleRoutes,
...realmRoutes,
...sessionRoutes,
...userRoutes,
{
path: "/:realm/sessions",
component: SessionsSection,
breadcrumb: (t) => t("sessions:title"),
access: "view-realm",
},
{
path: "/:realm/events/:tab?",
component: EventsSection,

6
src/sessions/routes.ts Normal file
View file

@ -0,0 +1,6 @@
import type { RouteDef } from "../route-config";
import { SessionsRoute } from "./routes/Sessions";
const routes: RouteDef[] = [SessionsRoute];
export default routes;

View file

@ -0,0 +1,19 @@
import type { LocationDescriptorObject } from "history";
import { generatePath } from "react-router-dom";
import type { RouteDef } from "../../route-config";
import { SessionsSection } from "../SessionsSection";
export type SessionsParams = { realm: string };
export const SessionsRoute: RouteDef = {
path: "/:realm/sessions",
component: SessionsSection,
breadcrumb: (t) => t("sessions:title"),
access: "view-realm",
};
export const toSessions = (
params: SessionsParams
): LocationDescriptorObject => ({
pathname: generatePath(SessionsRoute.path, params),
});