Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: themes provider deprecations #532

Merged
merged 3 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,46 @@ Then, if it appears that it's a real bug, you may report it using GitHub by foll

Please base your changes on the `master` branch.


### Testing Changes With the Distribution

Start your project:

```console
docker compose up --wait
```

Clone the API Platform Admin repository:

```console
git clone https://github.com/api-platform/admin.git
```

Start your distribution-based project:

```console
cd <your-project>
docker compose up --wait
```

Change the entrypoint of the API to use the one served by Docker in `pwa/pages/admin/index.tsx`:

```patch
- setDynamicAdmin(<HydraAdmin entrypoint={window.origin}></HydraAdmin>);
+ setDynamicAdmin(<HydraAdmin entrypoint="https://localhost"</HydraAdmin>);
dunglas marked this conversation as resolved.
Show resolved Hide resolved
```

Link your local version of API Plarform Admin and start the PWA locally (outside Docker):

```console
cd pwa/
pnpm link ../../admin
pnpm run dev
```




### Installing the Source Version

To install the source version of API Platform Admin in your project and contribute a patch, follow the instructions below.
Expand Down
17 changes: 12 additions & 5 deletions src/AdminGuesser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
I18nContextProvider,
Loading,
ThemeProvider,
ThemesContext,
defaultI18nProvider,
} from 'react-admin';
import { createHashHistory, createMemoryHistory } from 'history';
Expand Down Expand Up @@ -231,11 +232,17 @@ const AdminGuesserWithError = ({

return (
<I18nContextProvider value={i18nProvider}>
<ThemeProvider theme={theme}>
<ErrorBoundary onError={handleError} fallbackRender={renderError}>
<AdminGuesser {...props} i18nProvider={i18nProvider} theme={theme} />
</ErrorBoundary>
</ThemeProvider>
<ThemesContext.Provider value={theme}>
<ThemeProvider>
<ErrorBoundary onError={handleError} fallbackRender={renderError}>
<AdminGuesser
{...props}
i18nProvider={i18nProvider}
theme={theme}
/>
</ErrorBoundary>
</ThemeProvider>
</ThemesContext.Provider>
</I18nContextProvider>
);
};
Expand Down
3 changes: 1 addition & 2 deletions src/layout/AppBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import type { AppBarProps } from 'react-admin';
import { Box, Typography } from '@mui/material';

import Logo from './Logo.js';
import { darkTheme, lightTheme } from './themes.js';

const CustomAppBar = ({ classes, userMenu, ...props }: AppBarProps) => {
const authProvider = useAuthProvider();
Expand All @@ -24,7 +23,7 @@ const CustomAppBar = ({ classes, userMenu, ...props }: AppBarProps) => {
/>
<Logo />
<Box component="span" sx={{ flex: 1 }} />
<ToggleThemeButton lightTheme={lightTheme} darkTheme={darkTheme} />
<ToggleThemeButton />
</AppBar>
);
};
Expand Down