Use new routing conventions for realm role routes (#893)

This commit is contained in:
Jon Koops 2021-07-22 16:18:59 +02:00 committed by GitHub
parent f3b7e22898
commit bed671d8be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 123 additions and 32 deletions

16
src/realm-roles/routes.ts Normal file
View file

@ -0,0 +1,16 @@
import type { RouteDef } from "../route-config";
import { AddRoleRoute } from "./routes/AddRole";
import { AddRoleToClientRoute } from "./routes/AddRoleToClient";
import { ClientRoleRoute } from "./routes/ClientRole";
import { RealmRoleRoute } from "./routes/RealmRole";
import { RealmRolesRoute } from "./routes/RealmRoles";
const routes: RouteDef[] = [
AddRoleToClientRoute,
ClientRoleRoute,
RealmRolesRoute,
AddRoleRoute,
RealmRoleRoute,
];
export default routes;

View file

@ -0,0 +1,17 @@
import type { LocationDescriptorObject } from "history";
import { generatePath } from "react-router-dom";
import type { RouteDef } from "../../route-config";
import { RealmRoleTabs } from "../RealmRoleTabs";
export type AddRoleParams = { realm: string };
export const AddRoleRoute: RouteDef = {
path: "/:realm/roles/add-role",
component: RealmRoleTabs,
breadcrumb: (t) => t("roles:createRole"),
access: "manage-realm",
};
export const toAddRole = (params: AddRoleParams): LocationDescriptorObject => ({
pathname: generatePath(AddRoleRoute.path, params),
});

View file

@ -0,0 +1,22 @@
import type { LocationDescriptorObject } from "history";
import { generatePath } from "react-router-dom";
import type { RouteDef } from "../../route-config";
import { RealmRoleTabs } from "../RealmRoleTabs";
export type AddRoleToClientParams = {
realm: string;
clientId: string;
};
export const AddRoleToClientRoute: RouteDef = {
path: "/:realm/clients/:clientId/roles/add-role",
component: RealmRoleTabs,
breadcrumb: (t) => t("roles:createRole"),
access: "manage-realm",
};
export const toAddRoleToClient = (
params: AddRoleToClientParams
): LocationDescriptorObject => ({
pathname: generatePath(AddRoleToClientRoute.path, params),
});

View file

@ -0,0 +1,24 @@
import type { LocationDescriptorObject } from "history";
import { generatePath } from "react-router-dom";
import type { RouteDef } from "../../route-config";
import { RealmRoleTabs } from "../RealmRoleTabs";
export type ClientRoleParams = {
realm: string;
clientId: string;
id: string;
tab?: string;
};
export const ClientRoleRoute: RouteDef = {
path: "/:realm/clients/:clientId/roles/:id/:tab?",
component: RealmRoleTabs,
breadcrumb: (t) => t("roles:roleDetails"),
access: "view-realm",
};
export const toClientRole = (
params: ClientRoleParams
): LocationDescriptorObject => ({
pathname: generatePath(ClientRoleRoute.path, params),
});

View file

@ -0,0 +1,23 @@
import type { LocationDescriptorObject } from "history";
import { generatePath } from "react-router-dom";
import type { RouteDef } from "../../route-config";
import { RealmRoleTabs } from "../RealmRoleTabs";
export type RealmRoleParams = {
realm: string;
id: string;
tab?: string;
};
export const RealmRoleRoute: RouteDef = {
path: "/:realm/roles/:id/:tab?",
component: RealmRoleTabs,
breadcrumb: (t) => t("roles:roleDetails"),
access: "view-realm",
};
export const toRealmRole = (
params: RealmRoleParams
): LocationDescriptorObject => ({
pathname: generatePath(RealmRoleRoute.path, params),
});

View file

@ -0,0 +1,19 @@
import type { LocationDescriptorObject } from "history";
import { generatePath } from "react-router-dom";
import type { RouteDef } from "../../route-config";
import { RealmRolesSection } from "../RealmRolesSection";
export type RealmRolesParams = { realm: string };
export const RealmRolesRoute: RouteDef = {
path: "/:realm/roles",
component: RealmRolesSection,
breadcrumb: (t) => t("roles:roleList"),
access: "view-realm",
};
export const toRealmRoles = (
params: RealmRolesParams
): LocationDescriptorObject => ({
pathname: generatePath(RealmRolesRoute.path, params),
});

View file

@ -17,8 +17,7 @@ import { AddOpenIdConnect } from "./identity-providers/add/AddOpenIdConnect";
import { DetailSettings } from "./identity-providers/add/DetailSettings"; import { DetailSettings } from "./identity-providers/add/DetailSettings";
import { IdentityProvidersSection } from "./identity-providers/IdentityProvidersSection"; import { IdentityProvidersSection } from "./identity-providers/IdentityProvidersSection";
import { PageNotFoundSection } from "./PageNotFoundSection"; import { PageNotFoundSection } from "./PageNotFoundSection";
import { RealmRolesSection } from "./realm-roles/RealmRolesSection"; import realmRoleRoutes from "./realm-roles/routes";
import { RealmRoleTabs } from "./realm-roles/RealmRoleTabs";
import { AESGeneratedSettings } from "./realm-settings/key-providers/aes-generated/AESGeneratedForm"; import { AESGeneratedSettings } from "./realm-settings/key-providers/aes-generated/AESGeneratedForm";
import { ECDSAGeneratedSettings } from "./realm-settings/key-providers/ecdsa-generated/ECDSAGeneratedForm"; import { ECDSAGeneratedSettings } from "./realm-settings/key-providers/ecdsa-generated/ECDSAGeneratedForm";
import { HMACGeneratedSettings } from "./realm-settings/key-providers/hmac-generated/HMACGeneratedForm"; import { HMACGeneratedSettings } from "./realm-settings/key-providers/hmac-generated/HMACGeneratedForm";
@ -51,37 +50,8 @@ export const routes: RouteDef[] = [
...authenticationRoutes, ...authenticationRoutes,
...clientRoutes, ...clientRoutes,
...clientScopesRoutes, ...clientScopesRoutes,
...realmRoleRoutes,
...realmRoutes, ...realmRoutes,
{
path: "/:realm/clients/:clientId/roles/add-role",
component: RealmRoleTabs,
breadcrumb: (t) => t("roles:createRole"),
access: "manage-realm",
},
{
path: "/:realm/clients/:clientId/roles/:id/:tab?",
component: RealmRoleTabs,
breadcrumb: (t) => t("roles:roleDetails"),
access: "view-realm",
},
{
path: "/:realm/roles",
component: RealmRolesSection,
breadcrumb: (t) => t("roles:roleList"),
access: "view-realm",
},
{
path: "/:realm/roles/add-role",
component: RealmRoleTabs,
breadcrumb: (t) => t("roles:createRole"),
access: "manage-realm",
},
{
path: "/:realm/roles/:id/:tab?",
component: RealmRoleTabs,
breadcrumb: (t) => t("roles:roleDetails"),
access: "view-realm",
},
{ {
path: "/:realm/users", path: "/:realm/users",
component: UsersSection, component: UsersSection,