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

Migrate makeStyles to MUI v5 #330

Merged
merged 16 commits into from
Feb 2, 2024
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"@emotion/react": "^11.7.1",
"@emotion/styled": "^11.6.0",
"@mui/icons-material": "^5.3.1",
"@mui/material": "^5.4.0",
"@mui/material": "^5.11.7",
"@mui/styles": "^5.11.7",
"papaparse": "^5.2.0",
"prop-types": "^15.7.2",
"ra-language-chinese": "^2.0.10",
Expand Down
137 changes: 79 additions & 58 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from "react";
import { Admin, Resource, resolveBrowserLocale } from "react-admin";
import { StylesProvider, createGenerateClassName } from "@mui/styles";
import { createTheme, ThemeProvider } from "@mui/material/styles";
import polyglotI18nProvider from "ra-i18n-polyglot";
import authProvider from "./synapse/authProvider";
import dataProvider from "./synapse/dataProvider";
Expand Down Expand Up @@ -41,65 +43,84 @@ const i18nProvider = polyglotI18nProvider(
resolveBrowserLocale()
);

const defaultTheme = createTheme();
const generateClassName = createGenerateClassName({
disableGlobal: true,
seed: "mui-jss",
});

const App = () => (
<Admin
disableTelemetry
loginPage={LoginPage}
authProvider={authProvider}
dataProvider={dataProvider}
i18nProvider={i18nProvider}
customRoutes={[
<Route key="userImport" path="/import_users" component={ImportFeature} />,
]}
>
<Resource
name="users"
list={UserList}
create={UserCreate}
edit={UserEdit}
icon={UserIcon}
/>
<Resource name="rooms" list={RoomList} show={RoomShow} icon={RoomIcon} />
<Resource
name="user_media_statistics"
list={UserMediaStatsList}
icon={EqualizerIcon}
/>
<Resource
name="reports"
list={ReportList}
show={ReportShow}
icon={ReportIcon}
/>
<Resource
name="room_directory"
list={RoomDirectoryList}
icon={FolderSharedIcon}
/>
<Resource
name="destinations"
list={DestinationList}
show={DestinationShow}
icon={CloudQueueIcon}
/>
<Resource
name="registration_tokens"
list={RegistrationTokenList}
create={RegistrationTokenCreate}
edit={RegistrationTokenEdit}
icon={ConfirmationNumberIcon}
/>
<Resource name="connections" />
<Resource name="devices" />
<Resource name="room_members" />
<Resource name="users_media" />
<Resource name="joined_rooms" />
<Resource name="pushers" />
<Resource name="servernotices" />
<Resource name="forward_extremities" />
<Resource name="room_state" />
<Resource name="destination_rooms" />
</Admin>
<StylesProvider generateClassName={generateClassName}>
<ThemeProvider theme={defaultTheme}>
<Admin
disableTelemetry
loginPage={LoginPage}
authProvider={authProvider}
dataProvider={dataProvider}
i18nProvider={i18nProvider}
customRoutes={[
<Route
key="userImport"
path="/import_users"
component={ImportFeature}
/>,
]}
>
<Resource
name="users"
list={UserList}
create={UserCreate}
edit={UserEdit}
icon={UserIcon}
/>
<Resource
name="rooms"
list={RoomList}
show={RoomShow}
icon={RoomIcon}
/>
<Resource
name="user_media_statistics"
list={UserMediaStatsList}
icon={EqualizerIcon}
/>
<Resource
name="reports"
list={ReportList}
show={ReportShow}
icon={ReportIcon}
/>
<Resource
name="room_directory"
list={RoomDirectoryList}
icon={FolderSharedIcon}
/>
<Resource
name="destinations"
list={DestinationList}
show={DestinationShow}
icon={CloudQueueIcon}
/>
<Resource
name="registration_tokens"
list={RegistrationTokenList}
create={RegistrationTokenCreate}
edit={RegistrationTokenEdit}
icon={ConfirmationNumberIcon}
/>
<Resource name="connections" />
<Resource name="devices" />
<Resource name="room_members" />
<Resource name="users_media" />
<Resource name="joined_rooms" />
<Resource name="pushers" />
<Resource name="servernotices" />
<Resource name="forward_extremities" />
<Resource name="room_state" />
<Resource name="destination_rooms" />
</Admin>
</ThemeProvider>
</StylesProvider>
);

export default App;
4 changes: 1 addition & 3 deletions src/components/LoginPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
Select,
TextField,
} from "@mui/material";
import { makeStyles } from "@material-ui/core/styles";
import { makeStyles } from "@mui/styles";
import LockIcon from "@mui/icons-material/Lock";

const useStyles = makeStyles(theme => ({
Expand Down Expand Up @@ -345,7 +345,6 @@ const LoginPage = ({ theme }) => {
type="submit"
color="primary"
disabled={loading || !supportPassAuth}
className={classes.button}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not seen any reason for this. No class was defined for this on top of this file.

fullWidth
>
{loading && <CircularProgress size={25} thickness={2} />}
Expand All @@ -356,7 +355,6 @@ const LoginPage = ({ theme }) => {
color="secondary"
onClick={handleSSO}
disabled={loading || ssoBaseUrl === ""}
className={classes.button}
fullWidth
>
{loading && <CircularProgress size={25} thickness={2} />}
Expand Down
2 changes: 1 addition & 1 deletion src/components/RoomDirectory.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Fragment } from "react";
import { Avatar, Chip } from "@mui/material";
import { connect } from "react-redux";
import FolderSharedIcon from "@mui/icons-material/FolderShared";
import { makeStyles } from "@material-ui/core/styles";
import { makeStyles } from "@mui/styles";
import {
BooleanField,
BulkDeleteButton,
Expand Down
2 changes: 1 addition & 1 deletion src/components/devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
useRefresh,
} from "react-admin";
import ActionDelete from "@mui/icons-material/Delete";
import { makeStyles } from "@material-ui/core/styles";
import { makeStyles } from "@mui/styles";
import { alpha } from "@mui/material/styles";
import classnames from "classnames";

Expand Down
2 changes: 1 addition & 1 deletion src/components/media.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Fragment, useState } from "react";
import classnames from "classnames";
import { alpha } from "@mui/material/styles";
import { makeStyles } from "@material-ui/core/styles";
import { makeStyles } from "@mui/styles";
import {
BooleanInput,
Button,
Expand Down
2 changes: 1 addition & 1 deletion src/components/rooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
} from "react-admin";
import get from "lodash/get";
import PropTypes from "prop-types";
import { makeStyles } from "@material-ui/core/styles";
import { makeStyles } from "@mui/styles";
import { Tooltip, Typography, Chip } from "@mui/material";
import FastForwardIcon from "@mui/icons-material/FastForward";
import HttpsIcon from "@mui/icons-material/Https";
Expand Down
2 changes: 1 addition & 1 deletion src/components/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import { Link } from "react-router-dom";
import { ServerNoticeButton, ServerNoticeBulkButton } from "./ServerNotices";
import { DeviceRemoveButton } from "./devices";
import { ProtectMediaButton, QuarantineMediaButton } from "./media";
import { makeStyles } from "@material-ui/core/styles";
import { makeStyles } from "@mui/styles";

const redirect = () => {
return {
Expand Down
Loading