Use new routing conventions for groups routes (#913)
This commit is contained in:
parent
eb382b5fa7
commit
9410b89ed4
4 changed files with 54 additions and 21 deletions
7
src/groups/routes.ts
Normal file
7
src/groups/routes.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
import type { RouteDef } from "../route-config";
|
||||
import { GroupsRoute } from "./routes/Groups";
|
||||
import { GroupsSearchRoute } from "./routes/GroupsSearch";
|
||||
|
||||
const routes: RouteDef[] = [GroupsSearchRoute, GroupsRoute];
|
||||
|
||||
export default routes;
|
19
src/groups/routes/Groups.tsx
Normal file
19
src/groups/routes/Groups.tsx
Normal file
|
@ -0,0 +1,19 @@
|
|||
import type { LocationDescriptorObject } from "history";
|
||||
import { generatePath } from "react-router-dom";
|
||||
import type { RouteDef } from "../../route-config";
|
||||
import { GroupsSection } from "../GroupsSection";
|
||||
|
||||
export type GroupsParams = { realm: string };
|
||||
|
||||
export const GroupsRoute: RouteDef = {
|
||||
path: "/:realm/groups",
|
||||
component: GroupsSection,
|
||||
access: "query-groups",
|
||||
matchOptions: {
|
||||
exact: false,
|
||||
},
|
||||
};
|
||||
|
||||
export const toGroups = (params: GroupsParams): LocationDescriptorObject => ({
|
||||
pathname: generatePath(GroupsRoute.path, params),
|
||||
});
|
19
src/groups/routes/GroupsSearch.tsx
Normal file
19
src/groups/routes/GroupsSearch.tsx
Normal file
|
@ -0,0 +1,19 @@
|
|||
import type { LocationDescriptorObject } from "history";
|
||||
import { generatePath } from "react-router-dom";
|
||||
import type { RouteDef } from "../../route-config";
|
||||
import { SearchGroups } from "../SearchGroups";
|
||||
|
||||
export type GroupsSearchParams = { realm: string };
|
||||
|
||||
export const GroupsSearchRoute: RouteDef = {
|
||||
path: "/:realm/groups/search",
|
||||
component: SearchGroups,
|
||||
breadcrumb: (t) => t("groups:searchGroups"),
|
||||
access: "query-groups",
|
||||
};
|
||||
|
||||
export const toGroupsSearch = (
|
||||
params: GroupsSearchParams
|
||||
): LocationDescriptorObject => ({
|
||||
pathname: generatePath(GroupsSearchRoute.path, params),
|
||||
});
|
|
@ -7,8 +7,7 @@ import clientScopesRoutes from "./client-scopes/routes";
|
|||
import clientRoutes from "./clients/routes";
|
||||
import dashboardRoutes from "./dashboard/routes";
|
||||
import eventRoutes from "./events/routes";
|
||||
import { GroupsSection } from "./groups/GroupsSection";
|
||||
import { SearchGroups } from "./groups/SearchGroups";
|
||||
import groupsRoutes from "./groups/routes";
|
||||
import identityProviders from "./identity-providers/routes";
|
||||
import { PageNotFoundSection } from "./PageNotFoundSection";
|
||||
import realmRoleRoutes from "./realm-roles/routes";
|
||||
|
@ -26,6 +25,12 @@ export type RouteDef = {
|
|||
matchOptions?: MatchOptions;
|
||||
};
|
||||
|
||||
const NotFoundRoute: RouteDef = {
|
||||
path: "*",
|
||||
component: PageNotFoundSection,
|
||||
access: "anyone",
|
||||
};
|
||||
|
||||
export const routes: RouteDef[] = [
|
||||
...authenticationRoutes,
|
||||
...clientRoutes,
|
||||
|
@ -39,23 +44,6 @@ export const routes: RouteDef[] = [
|
|||
...userFederationRoutes,
|
||||
...userRoutes,
|
||||
...dashboardRoutes,
|
||||
{
|
||||
path: "/:realm/groups/search",
|
||||
component: SearchGroups,
|
||||
breadcrumb: (t) => t("groups:searchGroups"),
|
||||
access: "query-groups",
|
||||
},
|
||||
{
|
||||
path: "/:realm/groups",
|
||||
component: GroupsSection,
|
||||
access: "query-groups",
|
||||
matchOptions: {
|
||||
exact: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "*",
|
||||
component: PageNotFoundSection,
|
||||
access: "anyone",
|
||||
},
|
||||
...groupsRoutes,
|
||||
NotFoundRoute,
|
||||
];
|
||||
|
|
Loading…
Reference in a new issue