mirror of
https://github.com/UA-Fediland/synapse-admin.git
synced 2024-11-22 06:21:28 +00:00
Migrate makeStyles
to MUI v5 (#330)
This commit is contained in:
parent
17379a7325
commit
58e02d6dff
7 changed files with 2360 additions and 2967 deletions
|
@ -26,6 +26,7 @@
|
||||||
"@emotion/styled": "^11.10.6",
|
"@emotion/styled": "^11.10.6",
|
||||||
"@mui/icons-material": "^5.14.19",
|
"@mui/icons-material": "^5.14.19",
|
||||||
"@mui/material": "^5.14.8",
|
"@mui/material": "^5.14.8",
|
||||||
|
"@mui/styles": "5.14.10",
|
||||||
"papaparse": "^5.4.1",
|
"papaparse": "^5.4.1",
|
||||||
"prop-types": "^15.8.1",
|
"prop-types": "^15.8.1",
|
||||||
"ra-language-chinese": "^2.0.10",
|
"ra-language-chinese": "^2.0.10",
|
||||||
|
|
|
@ -1,12 +1,6 @@
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import {
|
import { useDataProvider, useNotify, Title } from "react-admin";
|
||||||
Button as ReactAdminButton,
|
|
||||||
useDataProvider,
|
|
||||||
useNotify,
|
|
||||||
Title,
|
|
||||||
} from "react-admin";
|
|
||||||
import { parse as parseCsv, unparse as unparseCsv } from "papaparse";
|
import { parse as parseCsv, unparse as unparseCsv } from "papaparse";
|
||||||
import GetAppIcon from "@mui/icons-material/GetApp";
|
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Card,
|
Card,
|
||||||
|
@ -23,19 +17,6 @@ import { generateRandomUser } from "./users";
|
||||||
|
|
||||||
const LOGGING = true;
|
const LOGGING = true;
|
||||||
|
|
||||||
export const ImportButton = ({ label, variant = "text" }) => {
|
|
||||||
return (
|
|
||||||
<ReactAdminButton
|
|
||||||
color="primary"
|
|
||||||
component="span"
|
|
||||||
variant={variant}
|
|
||||||
label={label}
|
|
||||||
>
|
|
||||||
<GetAppIcon style={{ transform: "rotate(180deg)", fontSize: "20" }} />
|
|
||||||
</ReactAdminButton>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const expectedFields = ["id", "displayname"].sort();
|
const expectedFields = ["id", "displayname"].sort();
|
||||||
const optionalFields = [
|
const optionalFields = [
|
||||||
"user_type",
|
"user_type",
|
||||||
|
|
|
@ -348,7 +348,6 @@ const LoginPage = ({ theme }) => {
|
||||||
type="submit"
|
type="submit"
|
||||||
color="primary"
|
color="primary"
|
||||||
disabled={loading || !supportPassAuth}
|
disabled={loading || !supportPassAuth}
|
||||||
className={classes.button}
|
|
||||||
fullWidth
|
fullWidth
|
||||||
>
|
>
|
||||||
{loading && <CircularProgress size={25} thickness={2} />}
|
{loading && <CircularProgress size={25} thickness={2} />}
|
||||||
|
@ -359,7 +358,6 @@ const LoginPage = ({ theme }) => {
|
||||||
color="secondary"
|
color="secondary"
|
||||||
onClick={handleSSO}
|
onClick={handleSSO}
|
||||||
disabled={loading || ssoBaseUrl === ""}
|
disabled={loading || ssoBaseUrl === ""}
|
||||||
className={classes.button}
|
|
||||||
fullWidth
|
fullWidth
|
||||||
>
|
>
|
||||||
{loading && <CircularProgress size={25} thickness={2} />}
|
{loading && <CircularProgress size={25} thickness={2} />}
|
||||||
|
|
|
@ -2,7 +2,6 @@ import React, { Fragment } from "react";
|
||||||
import { Avatar, Chip } from "@mui/material";
|
import { Avatar, Chip } from "@mui/material";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import FolderSharedIcon from "@mui/icons-material/FolderShared";
|
import FolderSharedIcon from "@mui/icons-material/FolderShared";
|
||||||
import { makeStyles } from "@material-ui/core/styles";
|
|
||||||
import {
|
import {
|
||||||
BooleanField,
|
BooleanField,
|
||||||
BulkDeleteButton,
|
BulkDeleteButton,
|
||||||
|
@ -23,13 +22,6 @@ import {
|
||||||
useUnselectAll,
|
useUnselectAll,
|
||||||
} from "react-admin";
|
} from "react-admin";
|
||||||
|
|
||||||
const useStyles = makeStyles({
|
|
||||||
small: {
|
|
||||||
height: "40px",
|
|
||||||
width: "40px",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const RoomDirectoryPagination = props => (
|
const RoomDirectoryPagination = props => (
|
||||||
<Pagination {...props} rowsPerPageOptions={[100, 500, 1000, 2000]} />
|
<Pagination {...props} rowsPerPageOptions={[100, 500, 1000, 2000]} />
|
||||||
);
|
);
|
||||||
|
@ -158,19 +150,19 @@ const RoomDirectoryFilter = ({ ...props }) => {
|
||||||
label={translate("resources.rooms.fields.room_id")}
|
label={translate("resources.rooms.fields.room_id")}
|
||||||
source="room_id"
|
source="room_id"
|
||||||
defaultValue={false}
|
defaultValue={false}
|
||||||
style={{ marginBottom: 8 }}
|
sx={{ marginBottom: "8px" }}
|
||||||
/>
|
/>
|
||||||
<Chip
|
<Chip
|
||||||
label={translate("resources.rooms.fields.topic")}
|
label={translate("resources.rooms.fields.topic")}
|
||||||
source="topic"
|
source="topic"
|
||||||
defaultValue={false}
|
defaultValue={false}
|
||||||
style={{ marginBottom: 8 }}
|
sx={{ marginBottom: "8px" }}
|
||||||
/>
|
/>
|
||||||
<Chip
|
<Chip
|
||||||
label={translate("resources.rooms.fields.canonical_alias")}
|
label={translate("resources.rooms.fields.canonical_alias")}
|
||||||
source="canonical_alias"
|
source="canonical_alias"
|
||||||
defaultValue={false}
|
defaultValue={false}
|
||||||
style={{ marginBottom: 8 }}
|
sx={{ marginBottom: "8px" }}
|
||||||
/>
|
/>
|
||||||
</Filter>
|
</Filter>
|
||||||
);
|
);
|
||||||
|
@ -181,7 +173,6 @@ export const FilterableRoomDirectoryList = ({
|
||||||
dispatch,
|
dispatch,
|
||||||
...props
|
...props
|
||||||
}) => {
|
}) => {
|
||||||
const classes = useStyles();
|
|
||||||
const filter = roomDirectoryFilters;
|
const filter = roomDirectoryFilters;
|
||||||
const roomIdFilter = filter && filter.room_id ? true : false;
|
const roomIdFilter = filter && filter.room_id ? true : false;
|
||||||
const topicFilter = filter && filter.topic ? true : false;
|
const topicFilter = filter && filter.topic ? true : false;
|
||||||
|
@ -199,7 +190,7 @@ export const FilterableRoomDirectoryList = ({
|
||||||
<AvatarField
|
<AvatarField
|
||||||
source="avatar_src"
|
source="avatar_src"
|
||||||
sortable={false}
|
sortable={false}
|
||||||
className={classes.small}
|
sx={{ height: "40px", width: "40px" }}
|
||||||
label="resources.rooms.fields.avatar"
|
label="resources.rooms.fields.avatar"
|
||||||
/>
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
|
|
|
@ -24,8 +24,8 @@ import {
|
||||||
} from "react-admin";
|
} from "react-admin";
|
||||||
import get from "lodash/get";
|
import get from "lodash/get";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import { makeStyles } from "@material-ui/core/styles";
|
|
||||||
import { Tooltip, Typography, Chip } from "@mui/material";
|
import { Tooltip, Typography, Chip } from "@mui/material";
|
||||||
|
import Box from "@mui/material/Box";
|
||||||
import FastForwardIcon from "@mui/icons-material/FastForward";
|
import FastForwardIcon from "@mui/icons-material/FastForward";
|
||||||
import HttpsIcon from "@mui/icons-material/Https";
|
import HttpsIcon from "@mui/icons-material/Https";
|
||||||
import NoEncryptionIcon from "@mui/icons-material/NoEncryption";
|
import NoEncryptionIcon from "@mui/icons-material/NoEncryption";
|
||||||
|
@ -50,13 +50,6 @@ const date_format = {
|
||||||
second: "2-digit",
|
second: "2-digit",
|
||||||
};
|
};
|
||||||
|
|
||||||
const useStyles = makeStyles(theme => ({
|
|
||||||
helper_forward_extremities: {
|
|
||||||
fontFamily: "Roboto, Helvetica, Arial, sans-serif",
|
|
||||||
margin: "0.5em",
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
|
|
||||||
const RoomPagination = props => (
|
const RoomPagination = props => (
|
||||||
<Pagination {...props} rowsPerPageOptions={[10, 25, 50, 100, 500, 1000]} />
|
<Pagination {...props} rowsPerPageOptions={[10, 25, 50, 100, 500, 1000]} />
|
||||||
);
|
);
|
||||||
|
@ -129,7 +122,6 @@ const RoomShowActions = ({ basePath, data, resource }) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const RoomShow = props => {
|
export const RoomShow = props => {
|
||||||
const classes = useStyles({ props });
|
|
||||||
const translate = useTranslate();
|
const translate = useTranslate();
|
||||||
return (
|
return (
|
||||||
<Show {...props} actions={<RoomShowActions />} title={<RoomTitle />}>
|
<Show {...props} actions={<RoomShowActions />} title={<RoomTitle />}>
|
||||||
|
@ -281,9 +273,14 @@ export const RoomShow = props => {
|
||||||
icon={<FastForwardIcon />}
|
icon={<FastForwardIcon />}
|
||||||
path="forward_extremities"
|
path="forward_extremities"
|
||||||
>
|
>
|
||||||
<div className={classes.helper_forward_extremities}>
|
<Box
|
||||||
|
sx={{
|
||||||
|
fontFamily: "Roboto, Helvetica, Arial, sans-serif",
|
||||||
|
margin: "0.5em",
|
||||||
|
}}
|
||||||
|
>
|
||||||
{translate("resources.rooms.helper.forward_extremities")}
|
{translate("resources.rooms.helper.forward_extremities")}
|
||||||
</div>
|
</Box>
|
||||||
<ReferenceManyField
|
<ReferenceManyField
|
||||||
reference="forward_extremities"
|
reference="forward_extremities"
|
||||||
target="room_id"
|
target="room_id"
|
||||||
|
@ -329,25 +326,25 @@ const RoomFilter = ({ ...props }) => {
|
||||||
label={translate("resources.rooms.fields.joined_local_members")}
|
label={translate("resources.rooms.fields.joined_local_members")}
|
||||||
source="joined_local_members"
|
source="joined_local_members"
|
||||||
defaultValue={false}
|
defaultValue={false}
|
||||||
style={{ marginBottom: 8 }}
|
sx={{ marginBottom: "8px" }}
|
||||||
/>
|
/>
|
||||||
<Chip
|
<Chip
|
||||||
label={translate("resources.rooms.fields.state_events")}
|
label={translate("resources.rooms.fields.state_events")}
|
||||||
source="state_events"
|
source="state_events"
|
||||||
defaultValue={false}
|
defaultValue={false}
|
||||||
style={{ marginBottom: 8 }}
|
sx={{ marginBottom: "8px" }}
|
||||||
/>
|
/>
|
||||||
<Chip
|
<Chip
|
||||||
label={translate("resources.rooms.fields.version")}
|
label={translate("resources.rooms.fields.version")}
|
||||||
source="version"
|
source="version"
|
||||||
defaultValue={false}
|
defaultValue={false}
|
||||||
style={{ marginBottom: 8 }}
|
sx={{ marginBottom: "8px" }}
|
||||||
/>
|
/>
|
||||||
<Chip
|
<Chip
|
||||||
label={translate("resources.rooms.fields.federatable")}
|
label={translate("resources.rooms.fields.federatable")}
|
||||||
source="federatable"
|
source="federatable"
|
||||||
defaultValue={false}
|
defaultValue={false}
|
||||||
style={{ marginBottom: 8 }}
|
sx={{ marginBottom: "8px" }}
|
||||||
/>
|
/>
|
||||||
</Filter>
|
</Filter>
|
||||||
);
|
);
|
||||||
|
|
|
@ -52,7 +52,6 @@ import { Link } from "react-router-dom";
|
||||||
import { ServerNoticeButton, ServerNoticeBulkButton } from "./ServerNotices";
|
import { ServerNoticeButton, ServerNoticeBulkButton } from "./ServerNotices";
|
||||||
import { DeviceRemoveButton } from "./devices";
|
import { DeviceRemoveButton } from "./devices";
|
||||||
import { ProtectMediaButton, QuarantineMediaButton } from "./media";
|
import { ProtectMediaButton, QuarantineMediaButton } from "./media";
|
||||||
import { makeStyles } from "@material-ui/core/styles";
|
|
||||||
|
|
||||||
const redirect = () => {
|
const redirect = () => {
|
||||||
return {
|
return {
|
||||||
|
@ -60,18 +59,6 @@ const redirect = () => {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const useStyles = makeStyles({
|
|
||||||
small: {
|
|
||||||
height: "40px",
|
|
||||||
width: "40px",
|
|
||||||
},
|
|
||||||
large: {
|
|
||||||
height: "120px",
|
|
||||||
width: "120px",
|
|
||||||
float: "right",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const choices_medium = [
|
const choices_medium = [
|
||||||
{ id: "email", name: "resources.users.email" },
|
{ id: "email", name: "resources.users.email" },
|
||||||
{ id: "msisdn", name: "resources.users.msisdn" },
|
{ id: "msisdn", name: "resources.users.msisdn" },
|
||||||
|
@ -130,7 +117,7 @@ const UserListActions = ({
|
||||||
/>
|
/>
|
||||||
{/* Add your custom actions */}
|
{/* Add your custom actions */}
|
||||||
<Button component={Link} to={redirect} label="CSV Import">
|
<Button component={Link} to={redirect} label="CSV Import">
|
||||||
<GetAppIcon style={{ transform: "rotate(180deg)", fontSize: "20" }} />
|
<GetAppIcon sx={{ transform: "rotate(180deg)", fontSize: "20px" }} />
|
||||||
</Button>
|
</Button>
|
||||||
</TopToolbar>
|
</TopToolbar>
|
||||||
);
|
);
|
||||||
|
@ -169,12 +156,11 @@ const UserBulkActionButtons = props => (
|
||||||
</Fragment>
|
</Fragment>
|
||||||
);
|
);
|
||||||
|
|
||||||
const AvatarField = ({ source, className, record = {} }) => (
|
const AvatarField = ({ source, record = {}, sx }) => (
|
||||||
<Avatar src={record[source]} className={className} />
|
<Avatar src={record[source]} sx={sx} />
|
||||||
);
|
);
|
||||||
|
|
||||||
export const UserList = props => {
|
export const UserList = props => {
|
||||||
const classes = useStyles();
|
|
||||||
return (
|
return (
|
||||||
<List
|
<List
|
||||||
{...props}
|
{...props}
|
||||||
|
@ -188,7 +174,7 @@ export const UserList = props => {
|
||||||
<Datagrid rowClick="edit">
|
<Datagrid rowClick="edit">
|
||||||
<AvatarField
|
<AvatarField
|
||||||
source="avatar_src"
|
source="avatar_src"
|
||||||
className={classes.small}
|
sx={{ height: "40px", width: "40px" }}
|
||||||
sortBy="avatar_url"
|
sortBy="avatar_url"
|
||||||
/>
|
/>
|
||||||
<TextField source="id" sortBy="name" />
|
<TextField source="id" sortBy="name" />
|
||||||
|
@ -344,7 +330,6 @@ const UserTitle = props => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const UserEdit = props => {
|
export const UserEdit = props => {
|
||||||
const classes = useStyles();
|
|
||||||
const translate = useTranslate();
|
const translate = useTranslate();
|
||||||
return (
|
return (
|
||||||
<Edit {...props} title={<UserTitle />} actions={<UserEditActions />}>
|
<Edit {...props} title={<UserTitle />} actions={<UserEditActions />}>
|
||||||
|
@ -356,7 +341,7 @@ export const UserEdit = props => {
|
||||||
<AvatarField
|
<AvatarField
|
||||||
source="avatar_src"
|
source="avatar_src"
|
||||||
sortable={false}
|
sortable={false}
|
||||||
className={classes.large}
|
sx={{ height: "120px", width: "120px", float: "right" }}
|
||||||
/>
|
/>
|
||||||
<TextInput source="id" disabled />
|
<TextInput source="id" disabled />
|
||||||
<TextInput source="displayname" />
|
<TextInput source="displayname" />
|
||||||
|
|
Loading…
Reference in a new issue