Use new routing conventions for event routes (#903)

This commit is contained in:
Jon Koops 2021-07-23 16:41:42 +02:00 committed by GitHub
parent 5dde8ee523
commit 88ae607148
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 7 deletions

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

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

View file

@ -0,0 +1,22 @@
import type { LocationDescriptorObject } from "history";
import { generatePath } from "react-router-dom";
import type { RouteDef } from "../../route-config";
import { EventsSection } from "../EventsSection";
export type EventsTab = "userEvents" | "adminEvents";
export type EventsParams = {
realm: string;
tab?: EventsTab;
};
export const EventsRoute: RouteDef = {
path: "/:realm/events/:tab?",
component: EventsSection,
breadcrumb: (t) => t("events:title"),
access: "view-events",
};
export const toEvents = (params: EventsParams): LocationDescriptorObject => ({
pathname: generatePath(EventsRoute.path, params),
});

View file

@ -6,7 +6,7 @@ import authenticationRoutes from "./authentication/routes";
import clientScopesRoutes from "./client-scopes/routes"; import clientScopesRoutes from "./client-scopes/routes";
import clientRoutes from "./clients/routes"; import clientRoutes from "./clients/routes";
import { DashboardSection } from "./dashboard/Dashboard"; import { DashboardSection } from "./dashboard/Dashboard";
import { EventsSection } from "./events/EventsSection"; import eventRoutes from "./events/routes";
import { GroupsSection } from "./groups/GroupsSection"; import { GroupsSection } from "./groups/GroupsSection";
import { SearchGroups } from "./groups/SearchGroups"; import { SearchGroups } from "./groups/SearchGroups";
import { import {
@ -48,16 +48,11 @@ export const routes: RouteDef[] = [
...authenticationRoutes, ...authenticationRoutes,
...clientRoutes, ...clientRoutes,
...clientScopesRoutes, ...clientScopesRoutes,
...eventRoutes,
...realmRoleRoutes, ...realmRoleRoutes,
...realmRoutes, ...realmRoutes,
...sessionRoutes, ...sessionRoutes,
...userRoutes, ...userRoutes,
{
path: "/:realm/events/:tab?",
component: EventsSection,
breadcrumb: (t) => t("events:title"),
access: "view-events",
},
{ {
path: "/:realm/realm-settings/:tab?", path: "/:realm/realm-settings/:tab?",
component: RealmSettingsSection, component: RealmSettingsSection,