Use new routing conventions for user routes (#898)
This commit is contained in:
parent
f8658adb90
commit
74ac0110c6
5 changed files with 67 additions and 27 deletions
|
@ -34,9 +34,7 @@ import { LdapMapperDetails } from "./user-federation/ldap/mappers/LdapMapperDeta
|
||||||
import { UserFederationKerberosSettings } from "./user-federation/UserFederationKerberosSettings";
|
import { UserFederationKerberosSettings } from "./user-federation/UserFederationKerberosSettings";
|
||||||
import { UserFederationLdapSettings } from "./user-federation/UserFederationLdapSettings";
|
import { UserFederationLdapSettings } from "./user-federation/UserFederationLdapSettings";
|
||||||
import { UserFederationSection } from "./user-federation/UserFederationSection";
|
import { UserFederationSection } from "./user-federation/UserFederationSection";
|
||||||
import { UserGroups } from "./user/UserGroups";
|
import userRoutes from "./user/routes";
|
||||||
import { UsersSection } from "./user/UsersSection";
|
|
||||||
import { UsersTabs } from "./user/UsersTabs";
|
|
||||||
|
|
||||||
export type RouteDef = {
|
export type RouteDef = {
|
||||||
path: string;
|
path: string;
|
||||||
|
@ -52,30 +50,7 @@ export const routes: RouteDef[] = [
|
||||||
...clientScopesRoutes,
|
...clientScopesRoutes,
|
||||||
...realmRoleRoutes,
|
...realmRoleRoutes,
|
||||||
...realmRoutes,
|
...realmRoutes,
|
||||||
{
|
...userRoutes,
|
||||||
path: "/:realm/users",
|
|
||||||
component: UsersSection,
|
|
||||||
breadcrumb: (t) => t("users:title"),
|
|
||||||
access: "query-users",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/:realm/users/add-user",
|
|
||||||
component: UsersTabs,
|
|
||||||
breadcrumb: (t) => t("users:createUser"),
|
|
||||||
access: "manage-users",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/:realm/users/:id",
|
|
||||||
component: UserGroups,
|
|
||||||
breadcrumb: (t) => t("users:userDetails"),
|
|
||||||
access: "manage-users",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/:realm/users/:id/:tab",
|
|
||||||
component: UsersTabs,
|
|
||||||
breadcrumb: (t) => t("users:userDetails"),
|
|
||||||
access: "manage-users",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
path: "/:realm/sessions",
|
path: "/:realm/sessions",
|
||||||
component: SessionsSection,
|
component: SessionsSection,
|
||||||
|
|
8
src/user/routes.ts
Normal file
8
src/user/routes.ts
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
import type { RouteDef } from "../route-config";
|
||||||
|
import { AddUserRoute } from "./routes/AddUser";
|
||||||
|
import { UserRoute } from "./routes/User";
|
||||||
|
import { UsersRoute } from "./routes/Users";
|
||||||
|
|
||||||
|
const routes: RouteDef[] = [UsersRoute, AddUserRoute, UserRoute];
|
||||||
|
|
||||||
|
export default routes;
|
17
src/user/routes/AddUser.ts
Normal file
17
src/user/routes/AddUser.ts
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
import type { LocationDescriptorObject } from "history";
|
||||||
|
import { generatePath } from "react-router-dom";
|
||||||
|
import type { RouteDef } from "../../route-config";
|
||||||
|
import { UsersTabs } from "../UsersTabs";
|
||||||
|
|
||||||
|
export type AddUserParams = { realm: string };
|
||||||
|
|
||||||
|
export const AddUserRoute: RouteDef = {
|
||||||
|
path: "/:realm/users/add-user",
|
||||||
|
component: UsersTabs,
|
||||||
|
breadcrumb: (t) => t("users:createUser"),
|
||||||
|
access: "manage-users",
|
||||||
|
};
|
||||||
|
|
||||||
|
export const toAddUser = (params: AddUserParams): LocationDescriptorObject => ({
|
||||||
|
pathname: generatePath(AddUserRoute.path, params),
|
||||||
|
});
|
23
src/user/routes/User.ts
Normal file
23
src/user/routes/User.ts
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
import type { LocationDescriptorObject } from "history";
|
||||||
|
import { generatePath } from "react-router-dom";
|
||||||
|
import type { RouteDef } from "../../route-config";
|
||||||
|
import { UsersTabs } from "../UsersTabs";
|
||||||
|
|
||||||
|
export type UserTab = "settings" | "groups" | "consents";
|
||||||
|
|
||||||
|
export type UserParams = {
|
||||||
|
realm: string;
|
||||||
|
id: string;
|
||||||
|
tab: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const UserRoute: RouteDef = {
|
||||||
|
path: "/:realm/users/:id/:tab",
|
||||||
|
component: UsersTabs,
|
||||||
|
breadcrumb: (t) => t("users:userDetails"),
|
||||||
|
access: "manage-users",
|
||||||
|
};
|
||||||
|
|
||||||
|
export const toUser = (params: UserParams): LocationDescriptorObject => ({
|
||||||
|
pathname: generatePath(UserRoute.path, params),
|
||||||
|
});
|
17
src/user/routes/Users.ts
Normal file
17
src/user/routes/Users.ts
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
import type { LocationDescriptorObject } from "history";
|
||||||
|
import { generatePath } from "react-router-dom";
|
||||||
|
import type { RouteDef } from "../../route-config";
|
||||||
|
import { UsersSection } from "../UsersSection";
|
||||||
|
|
||||||
|
export type UsersParams = { realm: string };
|
||||||
|
|
||||||
|
export const UsersRoute: RouteDef = {
|
||||||
|
path: "/:realm/users",
|
||||||
|
component: UsersSection,
|
||||||
|
breadcrumb: (t) => t("users:title"),
|
||||||
|
access: "query-users",
|
||||||
|
};
|
||||||
|
|
||||||
|
export const toUsers = (params: UsersParams): LocationDescriptorObject => ({
|
||||||
|
pathname: generatePath(UsersRoute.path, params),
|
||||||
|
});
|
Loading…
Reference in a new issue