diff --git a/src/identity-providers/routes.ts b/src/identity-providers/routes.ts new file mode 100644 index 0000000000..8ffd52a3cc --- /dev/null +++ b/src/identity-providers/routes.ts @@ -0,0 +1,16 @@ +import type { RouteDef } from "../route-config"; +import { IdentityProviderRoute } from "./routes/IdentityProvider"; +import { IdentityProviderKeycloakOidcRoute } from "./routes/IdentityProviderKeycloakOidc"; +import { IdentityProviderOidcRoute } from "./routes/IdentityProviderOidc"; +import { IdentityProvidersRoute } from "./routes/IdentityProviders"; +import { IdentityProviderTabRoute } from "./routes/IdentityProviderTab"; + +const routes: RouteDef[] = [ + IdentityProvidersRoute, + IdentityProviderOidcRoute, + IdentityProviderKeycloakOidcRoute, + IdentityProviderRoute, + IdentityProviderTabRoute, +]; + +export default routes; diff --git a/src/identity-providers/routes/IdentityProvider.ts b/src/identity-providers/routes/IdentityProvider.ts new file mode 100644 index 0000000000..2983ac04aa --- /dev/null +++ b/src/identity-providers/routes/IdentityProvider.ts @@ -0,0 +1,25 @@ +import type { LocationDescriptorObject } from "history"; +import { generatePath } from "react-router-dom"; +import type { RouteDef } from "../../route-config"; +import { + AddIdentityProvider, + IdentityProviderCrumb, +} from "../add/AddIdentityProvider"; + +export type IdentityProviderParams = { + realm: string; + id: string; +}; + +export const IdentityProviderRoute: RouteDef = { + path: "/:realm/identity-providers/:id", + component: AddIdentityProvider, + breadcrumb: () => IdentityProviderCrumb, + access: "manage-identity-providers", +}; + +export const toIdentityProvider = ( + params: IdentityProviderParams +): LocationDescriptorObject => ({ + pathname: generatePath(IdentityProviderRoute.path, params), +}); diff --git a/src/identity-providers/routes/IdentityProviderKeycloakOidc.ts b/src/identity-providers/routes/IdentityProviderKeycloakOidc.ts new file mode 100644 index 0000000000..e76edac8f7 --- /dev/null +++ b/src/identity-providers/routes/IdentityProviderKeycloakOidc.ts @@ -0,0 +1,19 @@ +import type { LocationDescriptorObject } from "history"; +import { generatePath } from "react-router-dom"; +import type { RouteDef } from "../../route-config"; +import { AddOpenIdConnect } from "../add/AddOpenIdConnect"; + +export type IdentityProviderKeycloakOidcParams = { realm: string }; + +export const IdentityProviderKeycloakOidcRoute: RouteDef = { + path: "/:realm/identity-providers/keycloak-oidc", + component: AddOpenIdConnect, + breadcrumb: (t) => t("identity-providers:addKeycloakOpenIdProvider"), + access: "manage-identity-providers", +}; + +export const toIdentityProviderKeycloakOidc = ( + params: IdentityProviderKeycloakOidcParams +): LocationDescriptorObject => ({ + pathname: generatePath(IdentityProviderKeycloakOidcRoute.path, params), +}); diff --git a/src/identity-providers/routes/IdentityProviderOidc.ts b/src/identity-providers/routes/IdentityProviderOidc.ts new file mode 100644 index 0000000000..a5f6d5888b --- /dev/null +++ b/src/identity-providers/routes/IdentityProviderOidc.ts @@ -0,0 +1,19 @@ +import type { LocationDescriptorObject } from "history"; +import { generatePath } from "react-router-dom"; +import type { RouteDef } from "../../route-config"; +import { AddOpenIdConnect } from "../add/AddOpenIdConnect"; + +export type IdentityProviderOidcParams = { realm: string }; + +export const IdentityProviderOidcRoute: RouteDef = { + path: "/:realm/identity-providers/oidc", + component: AddOpenIdConnect, + breadcrumb: (t) => t("identity-providers:addOpenIdProvider"), + access: "manage-identity-providers", +}; + +export const toIdentityProviderOidc = ( + params: IdentityProviderOidcParams +): LocationDescriptorObject => ({ + pathname: generatePath(IdentityProviderOidcRoute.path, params), +}); diff --git a/src/identity-providers/routes/IdentityProviderTab.ts b/src/identity-providers/routes/IdentityProviderTab.ts new file mode 100644 index 0000000000..d8b614f1cb --- /dev/null +++ b/src/identity-providers/routes/IdentityProviderTab.ts @@ -0,0 +1,24 @@ +import type { LocationDescriptorObject } from "history"; +import { generatePath } from "react-router-dom"; +import type { RouteDef } from "../../route-config"; +import { DetailSettings } from "../add/DetailSettings"; + +export type IdentityProviderTab = "settings"; + +export type IdentityProviderTabParams = { + realm: string; + id: string; + tab?: IdentityProviderTab; +}; + +export const IdentityProviderTabRoute: RouteDef = { + path: "/:realm/identity-providers/:id/:tab?", + component: DetailSettings, + access: "manage-identity-providers", +}; + +export const toIdentityProviderTab = ( + params: IdentityProviderTabParams +): LocationDescriptorObject => ({ + pathname: generatePath(IdentityProviderTabRoute.path, params), +}); diff --git a/src/identity-providers/routes/IdentityProviders.ts b/src/identity-providers/routes/IdentityProviders.ts new file mode 100644 index 0000000000..433e6ce5f8 --- /dev/null +++ b/src/identity-providers/routes/IdentityProviders.ts @@ -0,0 +1,19 @@ +import type { LocationDescriptorObject } from "history"; +import { generatePath } from "react-router-dom"; +import type { RouteDef } from "../../route-config"; +import { IdentityProvidersSection } from "../IdentityProvidersSection"; + +export type IdentityProvidersParams = { realm: string }; + +export const IdentityProvidersRoute: RouteDef = { + path: "/:realm/identity-providers", + component: IdentityProvidersSection, + breadcrumb: (t) => t("identityProviders"), + access: "view-identity-providers", +}; + +export const toIdentityProviders = ( + params: IdentityProvidersParams +): LocationDescriptorObject => ({ + pathname: generatePath(IdentityProvidersRoute.path, params), +}); diff --git a/src/route-config.ts b/src/route-config.ts index b377424416..af02540cf7 100644 --- a/src/route-config.ts +++ b/src/route-config.ts @@ -9,13 +9,7 @@ import { DashboardSection } from "./dashboard/Dashboard"; import eventRoutes from "./events/routes"; import { GroupsSection } from "./groups/GroupsSection"; import { SearchGroups } from "./groups/SearchGroups"; -import { - AddIdentityProvider, - IdentityProviderCrumb, -} from "./identity-providers/add/AddIdentityProvider"; -import { AddOpenIdConnect } from "./identity-providers/add/AddOpenIdConnect"; -import { DetailSettings } from "./identity-providers/add/DetailSettings"; -import { IdentityProvidersSection } from "./identity-providers/IdentityProvidersSection"; +import identityProviders from "./identity-providers/routes"; import { PageNotFoundSection } from "./PageNotFoundSection"; import realmRoleRoutes from "./realm-roles/routes"; import realmSettingRoutes from "./realm-settings/routes"; @@ -40,40 +34,12 @@ export const routes: RouteDef[] = [ ...clientRoutes, ...clientScopesRoutes, ...eventRoutes, + ...identityProviders, ...realmRoleRoutes, ...realmRoutes, ...realmSettingRoutes, ...sessionRoutes, ...userRoutes, - { - path: "/:realm/identity-providers", - component: IdentityProvidersSection, - breadcrumb: (t) => t("identityProviders"), - access: "view-identity-providers", - }, - { - path: "/:realm/identity-providers/oidc", - component: AddOpenIdConnect, - breadcrumb: (t) => t("identity-providers:addOpenIdProvider"), - access: "manage-identity-providers", - }, - { - path: "/:realm/identity-providers/keycloak-oidc", - component: AddOpenIdConnect, - breadcrumb: (t) => t("identity-providers:addKeycloakOpenIdProvider"), - access: "manage-identity-providers", - }, - { - path: "/:realm/identity-providers/:id", - component: AddIdentityProvider, - breadcrumb: () => IdentityProviderCrumb, - access: "manage-identity-providers", - }, - { - path: "/:realm/identity-providers/:id/:tab?", - component: DetailSettings, - access: "manage-identity-providers", - }, { path: "/:realm/user-federation", component: UserFederationSection,