Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Compose route guards as element wrappers (#77686)

Romeo Van Snick4674a3610f78
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/library/tables/routes.tsx b/enterprise/frontend/src/metabase-enterprise/data-studio/library/tables/routes.tsx
index b4d75f058e4..e1b9623ab4d 100644
--- a/enterprise/frontend/src/metabase-enterprise/data-studio/library/tables/routes.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/library/tables/routes.tsx
@@ -24,7 +24,7 @@ export function getDataStudioTableRoutes(IsAdmin: ComponentType) {
<Route path=":tableId/fields" component={TableFieldsPage} />
<Route path=":tableId/fields/:fieldId" component={TableFieldsPage} />
<Route path=":tableId/segments" component={TableSegmentsPage} />
- <Route path=":tableId/segments/new" component={IsAdmin}>
+ <Route path=":tableId/segments/new" element={<IsAdmin />}>
<Route index component={PublishedTableNewSegmentPage} />
</Route>
<Route
@@ -44,7 +44,7 @@ export function getDataStudioTableRoutes(IsAdmin: ComponentType) {
</Route>
)}
<Route path=":tableId/measures" component={TableMeasuresPage} />
- <Route path=":tableId/measures/new" component={IsAdmin}>
+ <Route path=":tableId/measures/new" element={<IsAdmin />}>
<Route index component={PublishedTableNewMeasurePage} />
</Route>
<Route
diff --git a/enterprise/frontend/src/metabase-enterprise/database_routing/index.tsx b/enterprise/frontend/src/metabase-enterprise/database_routing/index.tsx
index 8c4bbf6fba5..a202e04d072 100644
--- a/enterprise/frontend/src/metabase-enterprise/database_routing/index.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/database_routing/index.tsx
@@ -39,12 +39,12 @@ export function initializePlugin() {
PLUGIN_DB_ROUTING.getDestinationDatabaseRoutes = (IsAdmin: any) => (
<Route path="destination-databases">
<Route index component={DestinationDatabasesModal} />
- <Route component={IsAdmin}>
+ <Route element={<IsAdmin />}>
<Route path="create" component={DestinationDatabaseConnectionModal} />
</Route>
<Route path=":destinationDatabaseId">
<Route index component={DestinationDatabaseConnectionModal} />
- <Route component={IsAdmin}>
+ <Route element={<IsAdmin />}>
<Route path="remove" component={RemoveDestinationDatabaseModal} />
</Route>
</Route>
diff --git a/enterprise/frontend/src/metabase-enterprise/workspaces/routes.tsx b/enterprise/frontend/src/metabase-enterprise/workspaces/routes.tsx
index 1c84f781ca2..acb5a1b2a92 100644
--- a/enterprise/frontend/src/metabase-enterprise/workspaces/routes.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/workspaces/routes.tsx
@@ -13,7 +13,7 @@ export function getDataStudioRoutes() {
export function getWorkspaceDatabaseRoutes(IsAdmin: RouteComponent) {
return (
- <Route component={IsAdmin}>
+ <Route element={<IsAdmin />}>
<Route path=":databaseId/admin" component={AdminConnectionInfoPage} />
</Route>
);
diff --git a/frontend/src/metabase/account/routes.tsx b/frontend/src/metabase/account/routes.tsx
index 1409ede9d4a..eeacd61e8d2 100644
--- a/frontend/src/metabase/account/routes.tsx
+++ b/frontend/src/metabase/account/routes.tsx
@@ -15,7 +15,7 @@ export const getAccountRoutes = (
IsAuthenticated: RouteComponent,
) => {
return (
- <Route path="/account" component={IsAuthenticated}>
+ <Route path="/account" element={<IsAuthenticated />}>
<Route component={AccountApp}>
<Route index component={redirect("profile")} />
<Route path="profile" component={UserProfileApp} />
diff --git a/frontend/src/metabase/admin/routes.tsx b/frontend/src/metabase/admin/routes.tsx
index 9dd116408a2..92623dbb6bb 100644
--- a/frontend/src/metabase/admin/routes.tsx
+++ b/frontend/src/metabase/admin/routes.tsx
@@ -90,12 +90,12 @@ export const getRoutes = (
const hasSimpleEmbedding = getTokenFeature(state, "embedding_simple");
return (
- <Route path="/admin" component={CanAccessSettings}>
+ <Route path="/admin" element={<CanAccessSettings />}>
<Route component={AdminApp}>
<Route index component={RedirectToAllowedSettings} />
<Route path="databases" component={createAdminRouteGuard("databases")}>
<Route index component={DatabaseListApp} />
- <Route component={IsAdmin}>
+ <Route element={<IsAdmin />}>
<Route path="create" component={DatabasePage} />
</Route>
<Route path=":databaseId/edit" component={DatabasePage} />
@@ -124,10 +124,10 @@ export const getRoutes = (
/>
<Route component={DataModelV1}>
<Route path="segments" component={SegmentListApp} />
- <Route path="segment/create" component={IsAdmin}>
+ <Route path="segment/create" element={<IsAdmin />}>
<Route index component={SegmentApp} />
</Route>
- <Route path="segment/:id" component={IsAdmin}>
+ <Route path="segment/:id" element={<IsAdmin />}>
<Route index component={SegmentApp} />
</Route>
<Route
@@ -256,7 +256,7 @@ export const getRoutes = (
{getSettingsRoutes(store, IsAdmin)}
</Route>
{/* PERMISSIONS */}
- <Route path="permissions" component={IsAdmin}>
+ <Route path="permissions" element={<IsAdmin />}>
{getAdminPermissionsRoutes()}
</Route>
diff --git a/frontend/src/metabase/admin/settings/tests/setup.tsx b/frontend/src/metabase/admin/settings/tests/setup.tsx
index bd77f197ab6..52af8fc9bff 100644
--- a/frontend/src/metabase/admin/settings/tests/setup.tsx
+++ b/frontend/src/metabase/admin/settings/tests/setup.tsx
@@ -1,6 +1,5 @@
import { render as testingLibraryRender } from "@testing-library/react";
import fetchMock from "fetch-mock";
-import type { ReactNode } from "react";
import {
setupEnterpriseOnlyPlugin,
@@ -26,7 +25,7 @@ import { mockSettings } from "__support__/settings";
import { getTestStoreAndWrapper, screen } from "__support__/ui";
import { getSettingsRoutes } from "metabase/admin/settingsRoutes";
import { createMockState } from "metabase/redux/store/mocks";
-import { Route } from "metabase/router";
+import { Outlet, Route } from "metabase/router";
import type { TokenFeature, TokenFeatures } from "metabase-types/api";
import {
createMockSettings,
@@ -206,9 +205,7 @@ export const setup = async ({
initialRoute: `/admin/settings${initialRoute}`,
});
- const PassThroughGuard = ({ children }: { children: ReactNode }) => (
- <>{children}</>
- );
+ const PassThroughGuard = () => <Outlet />;
testingLibraryRender(
<Route path="admin/settings">
diff --git a/frontend/src/metabase/admin/settingsRoutes.tsx b/frontend/src/metabase/admin/settingsRoutes.tsx
index 0b8e6fbbcfb..2330a4ca45a 100644
--- a/frontend/src/metabase/admin/settingsRoutes.tsx
+++ b/frontend/src/metabase/admin/settingsRoutes.tsx
@@ -88,7 +88,7 @@ export const getSettingsRoutes = (
<Route
path="custom-visualizations"
/* do not allow users with "Settings access" permissions to access custom viz pages */
- component={IsAdmin}
+ element={<IsAdmin />}
>
<Route index component={CustomVisualizationsManagePage} />
<Route path="new" component={CustomVisualizationsFormPage} />
diff --git a/frontend/src/metabase/data-studio/data-model/routes.tsx b/frontend/src/metabase/data-studio/data-model/routes.tsx
index 8b4d3ec938c..d3eb0e843ff 100644
--- a/frontend/src/metabase/data-studio/data-model/routes.tsx
+++ b/frontend/src/metabase/data-studio/data-model/routes.tsx
@@ -29,7 +29,7 @@ export function getDataStudioMetadataRoutes(IsAdmin: ComponentType) {
/>
<Route
path="database/:databaseId/schema/:schemaId/table/:tableId/segments/new"
- component={IsAdmin}
+ element={<IsAdmin />}
>
<Route index component={DataModelNewSegmentPage} />
</Route>
@@ -51,7 +51,7 @@ export function getDataStudioMetadataRoutes(IsAdmin: ComponentType) {
)}
<Route
path="database/:databaseId/schema/:schemaId/table/:tableId/measures/new"
- component={IsAdmin}
+ element={<IsAdmin />}
>
<Route index component={DataModelNewMeasurePage} />
</Route>
diff --git a/frontend/src/metabase/data-studio/routes.tsx b/frontend/src/metabase/data-studio/routes.tsx
index 1e3d5628f6b..480c49bf9e4 100644
--- a/frontend/src/metabase/data-studio/routes.tsx
+++ b/frontend/src/metabase/data-studio/routes.tsx
@@ -35,10 +35,10 @@ export function getDataStudioRoutes(
IsAdmin: RouteComponent,
) {
return (
- <Route component={CanAccessDataStudio}>
+ <Route element={<CanAccessDataStudio />}>
<Route path="data-studio" component={DataStudioLayout}>
<Route index component={DataStudioIndexRedirect} />
- <Route path="data" component={CanAccessDataModel}>
+ <Route path="data" element={<CanAccessDataModel />}>
<Route component={DataSectionLayout}>
{getDataStudioMetadataRoutes(IsAdmin)}
</Route>
diff --git a/frontend/src/metabase/router/Outlet.tsx b/frontend/src/metabase/router/Outlet.tsx
index f2bd3fcea30..f067b004c77 100644
--- a/frontend/src/metabase/router/Outlet.tsx
+++ b/frontend/src/metabase/router/Outlet.tsx
@@ -1,6 +1,8 @@
import type { ComponentType, ReactNode } from "react";
import { createContext, useContext } from "react";
+import type { Route } from "./route";
+
const OutletContext = createContext<ReactNode>(null);
/**
@@ -15,6 +17,69 @@ export function Outlet(): JSX.Element {
return <>{child}</>;
}
+type RouteWithElement = Route & { element?: ReactNode };
+
+type RouteElementComponent = ComponentType<{
+ children?: ReactNode;
+ route?: RouteWithElement;
+}>;
+
+// The generated route `component` is keyed by the element's component *type*, not
+// by element identity, and it renders the element off the v3-injected `route`.
+// Two sibling routes that render the same component (`element={<X/>}` at
+// `foo/:a` and `foo/:a/:b`) therefore share one `component`, so React reconciles
+// `X` across a navigation between them instead of remounting it — matching v3's
+// `component={X}` behaviour and preserving `X`'s state. It also keeps the
+// component stable across v3's config rebuilds, so a `redirect()` element does
+// not remount and re-fire its navigation in a loop.
+const componentByType = new WeakMap<object, RouteElementComponent>();
+
+/**
+ * Turns a v7-style `element` into a react-router v3 route `component`. The child
+ * route that v3 injects as `props.children` is exposed through context, letting
+ * the element render it with `<Outlet/>`. This is how `<Route element={<X/>}>`
+ * runs on v3.
+ */
+export function routeElementToComponent(
+ element: ReactNode,
+): RouteElementComponent {
+ const type = elementType(element);
+ if (type != null) {
+ let cached = componentByType.get(type);
+ if (!cached) {
+ cached = makeRouteElementComponent();
+ componentByType.set(type, cached);
+ }
+ return cached;
+ }
+ return makeRouteElementComponent();
+}
+
+// The component type of an element, usable as a WeakMap key (a component function
+// or a `React.memo`/`forwardRef` object). Host tags (strings) and fragments
+// (symbols) aren't keyable, so those fall back to a fresh, unmemoized component.
+function elementType(element: ReactNode): object | null {
+ if (element != null && typeof element === "object" && "type" in element) {
+ // Narrowed to an object with a `type` key just above; read it as `unknown`
+ // to classify the element's component type without assuming a React shape.
+ const type = (element as { type: unknown }).type;
+ if (typeof type === "function" || (typeof type === "object" && type)) {
+ return type;
+ }
+ }
+ return null;
+}
+
+function makeRouteElementComponent(): RouteElementComponent {
+ return function RouteElement({ children, route }) {
+ return (
+ <OutletContext.Provider value={children}>
+ {route?.element}
+ </OutletContext.Provider>
+ );
+ };
+}
+
/**
* Wraps a v7-style component so it can be used as a react-router v3 route
* `component`. The child route that v3 injects as `props.children` is exposed
@@ -23,7 +88,7 @@ export function Outlet(): JSX.Element {
export function withOutlet(
Component: ComponentType,
): ComponentType<{ children?: ReactNode }> {
- return function RouteWithOutlet({ children }) {
+ return function RoutedComponent({ children }) {
return (
<OutletContext.Provider value={children}>
<Component />
diff --git a/frontend/src/metabase/router/guards.tsx b/frontend/src/metabase/router/guards.tsx
index 2fd6d8ad3d0..34ad844efc2 100644
--- a/frontend/src/metabase/router/guards.tsx
+++ b/frontend/src/metabase/router/guards.tsx
@@ -11,6 +11,7 @@ import { getSetting } from "metabase/selectors/settings";
import { isSameOrSiteUrlOrigin, replaceLocation } from "metabase/utils/dom";
import { Navigate } from "./Navigate";
+import { Outlet } from "./Outlet";
import type { Location } from "./types";
import { useLocation } from "./use-location";
@@ -167,49 +168,63 @@ const UserCanAccessDataStudio = createRedirectGuard(
"/unauthorized",
);
-export const IsAuthenticated = ({ children }: Props) => (
+export const IsAuthenticated = () => (
<MetabaseIsSetup>
- <UserIsAuthenticated>{children}</UserIsAuthenticated>
+ <UserIsAuthenticated>
+ <Outlet />
+ </UserIsAuthenticated>
</MetabaseIsSetup>
);
-export const IsAdmin = ({ children }: Props) => (
+export const IsAdmin = () => (
<MetabaseIsSetup>
<UserIsAuthenticated>
- <UserIsAdmin>{children}</UserIsAdmin>
+ <UserIsAdmin>
+ <Outlet />
+ </UserIsAdmin>
</UserIsAuthenticated>
</MetabaseIsSetup>
);
-export const IsNotAuthenticated = ({ children }: Props) => (
+export const IsNotAuthenticated = () => (
<MetabaseIsSetup>
- <UserIsNotAuthenticated>{children}</UserIsNotAuthenticated>
+ <UserIsNotAuthenticated>
+ <Outlet />
+ </UserIsNotAuthenticated>
</MetabaseIsSetup>
);
-export const CanAccessSettings = ({ children }: Props) => (
+export const CanAccessSettings = () => (
<MetabaseIsSetup>
<UserIsAuthenticated>
- <UserCanAccessSettings>{children}</UserCanAccessSettings>
+ <UserCanAccessSettings>
+ <Outlet />
+ </UserCanAccessSettings>
</UserIsAuthenticated>
</MetabaseIsSetup>
);
-export const CanAccessOnboarding = ({ children }: Props) => (
- <UserCanAccessOnboarding>{children}</UserCanAccessOnboarding>
+export const CanAccessOnboarding = () => (
+ <UserCanAccessOnboarding>
+ <Outlet />
+ </UserCanAccessOnboarding>
);
// Must be in sync with canAccessDataStudio in frontend/src/metabase/data-studio/selectors.ts
-export const CanAccessDataStudio = ({ children }: Props) => (
+export const CanAccessDataStudio = () => (
<MetabaseIsSetup>
<UserIsAuthenticated>
<UserCanAccessDataStudio>
- <AvailableInEmbedding>{children}</AvailableInEmbedding>
+ <AvailableInEmbedding>
+ <Outlet />
+ </AvailableInEmbedding>
</UserCanAccessDataStudio>
</UserIsAuthenticated>
</MetabaseIsSetup>
);
-export const CanAccessDataModel = ({ children }: Props) => (
- <UserCanAccessDataModel>{children}</UserCanAccessDataModel>
+export const CanAccessDataModel = () => (
+ <UserCanAccessDataModel>
+ <Outlet />
+ </UserCanAccessDataModel>
);
diff --git a/frontend/src/metabase/router/guards.unit.spec.tsx b/frontend/src/metabase/router/guards.unit.spec.tsx
index 7559fa7a0c2..40f969822da 100644
--- a/frontend/src/metabase/router/guards.unit.spec.tsx
+++ b/frontend/src/metabase/router/guards.unit.spec.tsx
@@ -37,10 +37,10 @@ describe("route-guards", () => {
const { history } = renderWithProviders(
<>
- <Route component={IsAuthenticated}>
+ <Route element={<IsAuthenticated />}>
<Route path="/dashboard/:slug" component={Dashboard} />
</Route>
- <Route component={IsNotAuthenticated}>
+ <Route element={<IsNotAuthenticated />}>
<Route path="/auth/login" component={LoginPage} />
</Route>
</>,
@@ -72,7 +72,7 @@ describe("route-guards", () => {
const { history } = renderWithProviders(
<>
- <Route component={IsAdmin}>
+ <Route element={<IsAdmin />}>
<Route path="/admin/settings" component={Protected} />
</Route>
<Route path="/unauthorized" component={Unauthorized} />
@@ -100,7 +100,7 @@ describe("route-guards", () => {
const { history } = renderWithProviders(
<>
- <Route component={IsNotAuthenticated}>
+ <Route element={<IsNotAuthenticated />}>
<Route path="/auth/login" component={LoginPage} />
</Route>
<Route path="/" component={Home} />
@@ -136,7 +136,7 @@ describe("route-guards", () => {
});
const { history } = renderWithProviders(
- <Route component={IsNotAuthenticated}>
+ <Route element={<IsNotAuthenticated />}>
<Route path="/auth/login" component={LoginPage} />
</Route>,
{
diff --git a/frontend/src/metabase/router/route.tsx b/frontend/src/metabase/router/route.tsx
index 35e5391456f..0e05fcb7de9 100644
--- a/frontend/src/metabase/router/route.tsx
+++ b/frontend/src/metabase/router/route.tsx
@@ -1,5 +1,11 @@
-import { type ComponentClass, type ReactElement, createElement } from "react";
+import {
+ type ComponentClass,
+ type ReactElement,
+ type ReactNode,
+ createElement,
+} from "react";
+import { routeElementToComponent } from "./Outlet";
import {
type PlainRoute,
ReactRouterRoute,
@@ -8,11 +14,16 @@ import {
} from "./react-router";
/**
- * Props accepted by the `<Route>` element. Adds react-router v7's `index` on top
- * of v3's route props, so an index route is written `<Route index component={X}/>`
- * instead of the v3 `<IndexRoute>`.
+ * Props accepted by the `<Route>` element. Adds react-router v7's `index` and
+ * `element` on top of v3's route props. `index` registers the route as its
+ * parent's index route (what v3's `<IndexRoute>` did) and works with either
+ * `component` or `element`. `element` is bridged to a v3 `component` that renders
+ * it and exposes the matched child through `<Outlet/>`.
*/
-export type RouteElementProps = RouteProps & { index?: boolean };
+export type RouteElementProps = RouteProps & {
+ index?: boolean;
+ element?: ReactNode;
+};
interface RouteConfigElement {
(props: RouteElementProps): null;
@@ -50,7 +61,20 @@ export const Route: RouteConfigElement = Object.assign(
// Rebuild the element as a raw v3 `<Route>` so v3's own builder turns it (and
// its children) into a route object without dispatching back into this static.
const { index, ...props } = element.props;
- const [route] = createRoutes(createElement(ReactRouterRoute, props));
+ // v3 copies our `element` prop onto the route config but `PlainRoute` does
+ // not type it, so widen the result to read it below.
+ const [route] = createRoutes(createElement(ReactRouterRoute, props)) as [
+ (PlainRoute & { element?: ReactNode }) | undefined,
+ ];
+
+ // Bridge `element` onto v3: render it through a `component` that publishes
+ // the matched child on `<Outlet/>`'s context. The `element` stays on the
+ // route config so the bridge component can render it off the injected
+ // `route` prop, letting sibling routes that share a component reconcile
+ // instead of remounting. Goes away at the engine swap.
+ if (route?.element != null) {
+ route.component = routeElementToComponent(route.element);
+ }
if (index) {
if (parentRoute && route) {
diff --git a/frontend/src/metabase/router/route.unit.spec.tsx b/frontend/src/metabase/router/route.unit.spec.tsx
index 0b4a05e8236..002969c9e3a 100644
--- a/frontend/src/metabase/router/route.unit.spec.tsx
+++ b/frontend/src/metabase/router/route.unit.spec.tsx
@@ -1,7 +1,9 @@
-import type { PropsWithChildren } from "react";
+import { type PropsWithChildren, useEffect } from "react";
-import { renderWithProviders, screen } from "__support__/ui";
+import { act, renderWithProviders, screen } from "__support__/ui";
+import { checkNotNull } from "metabase/utils/types";
+import { Outlet } from "./Outlet";
import { Route } from "./route";
const Parent = ({ children }: PropsWithChildren) => <div>{children}</div>;
@@ -42,3 +44,98 @@ describe("router/Route", () => {
expect(await screen.findByText("child-page")).toBeInTheDocument();
});
});
+
+const Wrapper = () => (
+ <div>
+ <span>wrapper chrome</span>
+ <Outlet />
+ </div>
+);
+
+const Inner = () => (
+ <div>
+ <span>inner chrome</span>
+ <Outlet />
+ </div>
+);
+
+describe("router/Route element adapter", () => {
+ it("renders an `element` wrapper with the matched child exposed via <Outlet/>", async () => {
+ renderWithProviders(
+ <Route element={<Wrapper />}>
+ <Route path="/nested" component={ChildPage} />
+ </Route>,
+ { withRouter: true, initialRoute: "/nested" },
+ );
+
+ expect(await screen.findByText("child-page")).toBeInTheDocument();
+ expect(screen.getByText("wrapper chrome")).toBeInTheDocument();
+ });
+
+ it("composes nested `element` wrappers", async () => {
+ renderWithProviders(
+ <Route element={<Wrapper />}>
+ <Route element={<Inner />}>
+ <Route path="/deep" component={ChildPage} />
+ </Route>
+ </Route>,
+ { withRouter: true, initialRoute: "/deep" },
+ );
+
+ expect(await screen.findByText("child-page")).toBeInTheDocument();
+ expect(screen.getByText("wrapper chrome")).toBeInTheDocument();
+ expect(screen.getByText("inner chrome")).toBeInTheDocument();
+ });
+
+ it("still passes `component` routes straight through to v3", async () => {
+ renderWithProviders(<Route path="/plain" component={ChildPage} />, {
+ withRouter: true,
+ initialRoute: "/plain",
+ });
+
+ expect(await screen.findByText("child-page")).toBeInTheDocument();
+ });
+});
+
+describe("router/Route element memoization", () => {
+ it("reuses a shared element component across sibling routes instead of remounting it", async () => {
+ let mounts = 0;
+ const Shared = () => {
+ useEffect(() => {
+ mounts += 1;
+ }, []);
+ return (
+ <div>
+ <span>shared-chrome</span>
+ <Outlet />
+ </div>
+ );
+ };
+ const PageA = () => <div>page-a</div>;
+ const PageB = () => <div>page-b</div>;
+
+ const { history } = renderWithProviders(
+ <Route path="shared">
+ <Route path=":a" element={<Shared />}>
+ <Route index element={<PageA />} />
+ </Route>
+ <Route path=":a/:b" element={<Shared />}>
+ <Route index element={<PageB />} />
+ </Route>
+ </Route>,
+ { withRouter: true, initialRoute: "/shared/1" },
+ );
+
+ expect(await screen.findByText("page-a")).toBeInTheDocument();
+ expect(mounts).toBe(1);
+
+ act(() => {
+ checkNotNull(history).push("/shared/1/2");
+ });
+
+ // The sibling route renders the same `Shared` component, so it reconciles
+ // across the navigation instead of remounting: `mounts` stays at 1.
+ expect(await screen.findByText("page-b")).toBeInTheDocument();
+ expect(mounts).toBe(1);
+ });
+});
diff --git a/frontend/src/metabase/routes.tsx b/frontend/src/metabase/routes.tsx
index 5cb4b45debf..39c73f5a330 100644
--- a/frontend/src/metabase/routes.tsx
+++ b/frontend/src/metabase/routes.tsx
@@ -107,7 +107,7 @@ export const getRoutes = (store: AppStore) => {
{/* AUTH */}
<Route path="/auth">
<Route index component={redirect("/auth/login")} />
- <Route component={IsNotAuthenticated}>
+ <Route element={<IsNotAuthenticated />}>
<Route path="login" component={Login} />
<Route path="login/:provider" component={Login} />
</Route>
@@ -121,13 +121,13 @@ export const getRoutes = (store: AppStore) => {
</Route>
{/* MAIN */}
- <Route component={IsAuthenticated}>
+ <Route element={<IsAuthenticated />}>
{getMetabotRoutes()}
{/* The global all hands routes, things in here are for all the folks */}
<Route path="/" component={LandingPageRedirect} />
- <Route path="getting-started" component={CanAccessOnboarding}>
+ <Route path="getting-started" element={<CanAccessOnboarding />}>
<Route index component={Onboarding} />
</Route>
@@ -155,7 +155,7 @@ export const getRoutes = (store: AppStore) => {
})}
/>
- <Route path="collection/users" component={IsAdmin}>
+ <Route path="collection/users" element={<IsAdmin />}>
<Route index component={UserCollectionList} />
</Route>
@@ -166,7 +166,7 @@ export const getRoutes = (store: AppStore) => {
<Route index component={PLUGIN_TENANTS.TenantCollectionList} />
</Route>
- <Route path="collection/tenant-users" component={IsAdmin}>
+ <Route path="collection/tenant-users" element={<IsAdmin />}>
<Route index component={PLUGIN_TENANTS.TenantUsersList} />
<Route
path=":tenantId"