From fe841f668771b867609b230de79b4c0f0bc92c04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Thu, 7 Mar 2024 00:11:05 +0100 Subject: [PATCH] chore: simplify migration --- src/AdminGuesser.tsx | 76 ++++++++++++++++++------------------------- src/layout/AppBar.tsx | 8 +---- 2 files changed, 32 insertions(+), 52 deletions(-) diff --git a/src/AdminGuesser.tsx b/src/AdminGuesser.tsx index c92ca6c0..5c335fc9 100644 --- a/src/AdminGuesser.tsx +++ b/src/AdminGuesser.tsx @@ -1,15 +1,12 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react'; import PropTypes from 'prop-types'; import { - Admin, + AdminContext, + AdminUI, ComponentPropType, - I18nContextProvider, Loading, - ThemeProvider, - ThemesContext, defaultI18nProvider, } from 'react-admin'; -import { createHashHistory, createMemoryHistory } from 'history'; import { ErrorBoundary } from 'react-error-boundary'; import type { FallbackProps } from 'react-error-boundary'; import type { ComponentType, ErrorInfo } from 'react'; @@ -23,6 +20,7 @@ import { Error as DefaultError, Layout, LoginPage, + darkTheme, lightTheme, } from './layout/index.js'; import getRoutesAndResourcesFromNodes, { @@ -68,7 +66,7 @@ const getOverrideCode = (resources: Resource[]) => { export const AdminResourcesGuesser = ({ // Admin props loadingPage: LoadingPage = Loading, - admin: AdminEl = Admin, + admin: AdminEl = AdminUI, // Props children, includeDeprecated, @@ -116,7 +114,7 @@ const AdminGuesser = ({ includeDeprecated = false, // Admin props dataProvider, - history, + i18nProvider, layout = Layout, loginPage = LoginPage, loading: loadingPage, @@ -129,14 +127,6 @@ const AdminGuesser = ({ const [loading, setLoading] = useState(true); const [, setError] = useState(); const [introspect, setIntrospect] = useState(true); - let adminHistory = history; - - if (!adminHistory) { - adminHistory = - typeof window === 'undefined' - ? createMemoryHistory() - : createHashHistory(); - } useEffect(() => { if (typeof dataProvider.introspect !== 'function') { @@ -175,23 +165,29 @@ const AdminGuesser = ({ ); return ( - - - - {children} - - - + + + + + {children} + + + + ); }; @@ -231,19 +227,9 @@ const AdminGuesserWithError = ({ ); return ( - - - - - - - - - + + + ); }; diff --git a/src/layout/AppBar.tsx b/src/layout/AppBar.tsx index 3dc83d50..429b6f9d 100644 --- a/src/layout/AppBar.tsx +++ b/src/layout/AppBar.tsx @@ -1,10 +1,5 @@ import React from 'react'; -import { - AppBar, - AppBarClasses, - ToggleThemeButton, - useAuthProvider, -} from 'react-admin'; +import { AppBar, AppBarClasses, useAuthProvider } from 'react-admin'; import type { AppBarProps } from 'react-admin'; import { Box, Typography } from '@mui/material'; @@ -23,7 +18,6 @@ const CustomAppBar = ({ classes, userMenu, ...props }: AppBarProps) => { /> - ); };