Use new routing conventions for dashboard routes (#912)
This commit is contained in:
parent
477fa6180c
commit
eb382b5fa7
3 changed files with 27 additions and 13 deletions
6
src/dashboard/routes.ts
Normal file
6
src/dashboard/routes.ts
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
import type { RouteDef } from "../route-config";
|
||||||
|
import { DashboardRoute } from "./routes/Dashboard";
|
||||||
|
|
||||||
|
const routes: RouteDef[] = [DashboardRoute];
|
||||||
|
|
||||||
|
export default routes;
|
19
src/dashboard/routes/Dashboard.ts
Normal file
19
src/dashboard/routes/Dashboard.ts
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
import type { LocationDescriptorObject } from "history";
|
||||||
|
import { generatePath } from "react-router-dom";
|
||||||
|
import type { RouteDef } from "../../route-config";
|
||||||
|
import { DashboardSection } from "../Dashboard";
|
||||||
|
|
||||||
|
export type DashboardParams = { realm?: string };
|
||||||
|
|
||||||
|
export const DashboardRoute: RouteDef = {
|
||||||
|
path: "/:realm?",
|
||||||
|
component: DashboardSection,
|
||||||
|
breadcrumb: (t) => t("common:home"),
|
||||||
|
access: "anyone",
|
||||||
|
};
|
||||||
|
|
||||||
|
export const toDashboard = (
|
||||||
|
params: DashboardParams
|
||||||
|
): LocationDescriptorObject => ({
|
||||||
|
pathname: generatePath(DashboardRoute.path, params),
|
||||||
|
});
|
|
@ -5,7 +5,7 @@ import type { MatchOptions } from "use-react-router-breadcrumbs";
|
||||||
import authenticationRoutes from "./authentication/routes";
|
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 dashboardRoutes from "./dashboard/routes";
|
||||||
import eventRoutes from "./events/routes";
|
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";
|
||||||
|
@ -38,12 +38,7 @@ export const routes: RouteDef[] = [
|
||||||
...sessionRoutes,
|
...sessionRoutes,
|
||||||
...userFederationRoutes,
|
...userFederationRoutes,
|
||||||
...userRoutes,
|
...userRoutes,
|
||||||
{
|
...dashboardRoutes,
|
||||||
path: "/:realm/",
|
|
||||||
component: DashboardSection,
|
|
||||||
breadcrumb: (t) => t("common:home"),
|
|
||||||
access: "anyone",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
path: "/:realm/groups/search",
|
path: "/:realm/groups/search",
|
||||||
component: SearchGroups,
|
component: SearchGroups,
|
||||||
|
@ -58,12 +53,6 @@ export const routes: RouteDef[] = [
|
||||||
exact: false,
|
exact: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: "/",
|
|
||||||
component: DashboardSection,
|
|
||||||
breadcrumb: (t) => t("common:home"),
|
|
||||||
access: "anyone",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
path: "*",
|
path: "*",
|
||||||
component: PageNotFoundSection,
|
component: PageNotFoundSection,
|
||||||
|
|
Loading…
Reference in a new issue