Start React & Material UI update

This commit is contained in:
Pierre HUBERT 2022-06-12 18:50:22 +02:00
parent cd086f2a4c
commit a8f1354a43
22 changed files with 27339 additions and 17143 deletions

44143
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,48 +1,49 @@
{ {
"name": "comunic-console", "name": "comunic-console",
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"dependencies": { "dependencies": {
"@material-ui/core": "^4.11.4", "@emotion/react": "^11.9.3",
"@material-ui/data-grid": "^4.0.0-alpha.26", "@emotion/styled": "^11.9.3",
"@material-ui/icons": "^4.11.2", "@mui/icons-material": "^5.8.3",
"@testing-library/jest-dom": "^5.12.0", "@mui/material": "^5.8.3",
"@testing-library/react": "^11.2.6", "@mui/x-data-grid": "^5.12.1",
"@testing-library/user-event": "^12.8.3", "@testing-library/jest-dom": "^5.16.4",
"@types/jest": "^26.0.23", "@testing-library/react": "^13.3.0",
"@types/node": "^12.20.11", "@testing-library/user-event": "^13.5.0",
"@types/react": "^17.0.4", "@types/jest": "^27.5.2",
"@types/react-dom": "^17.0.3", "@types/node": "^16.11.39",
"@types/react-router-dom": "^5.1.7", "@types/react": "^18.0.12",
"react": "^17.0.2", "@types/react-dom": "^18.0.5",
"react-dom": "^17.0.2", "react": "^18.1.0",
"react-router-dom": "^5.2.0", "react-dom": "^18.1.0",
"react-scripts": "4.0.3", "react-router-dom": "^6.3.0",
"typescript": "^4.2.4", "react-scripts": "5.0.1",
"web-vitals": "^1.1.1" "typescript": "^4.7.3",
}, "web-vitals": "^2.1.4"
"scripts": { },
"start": "react-scripts start", "scripts": {
"build": "react-scripts build", "start": "react-scripts start",
"test": "react-scripts test", "build": "react-scripts build",
"eject": "react-scripts eject" "test": "react-scripts test",
}, "eject": "react-scripts eject"
"eslintConfig": { },
"extends": [ "eslintConfig": {
"react-app", "extends": [
"react-app/jest" "react-app",
] "react-app/jest"
}, ]
"browserslist": { },
"production": [ "browserslist": {
">0.2%", "production": [
"not dead", ">0.2%",
"not op_mini all" "not dead",
], "not op_mini all"
"development": [ ],
"last 1 chrome version", "development": [
"last 1 firefox version", "last 1 chrome version",
"last 1 safari version" "last 1 firefox version",
] "last 1 safari version"
} ]
}
} }

View File

@ -1,14 +1,14 @@
import { createTheme, ThemeProvider } from "@mui/material";
import { lightBlue, pink } from "@mui/material/colors";
import React from "react"; import React from "react";
import "./App.css"; import "./App.css";
import { createMuiTheme, ThemeProvider } from "@material-ui/core";
import { ApplicationDialogsProvider } from "./ui/widgets/DialogsProvider"; import { ApplicationDialogsProvider } from "./ui/widgets/DialogsProvider";
import { lightBlue, pink } from "@material-ui/core/colors";
import { InitWidget } from "./ui/widgets/InitWidget"; import { InitWidget } from "./ui/widgets/InitWidget";
function App() { function App() {
const darkTheme = createMuiTheme({ const darkTheme = createTheme({
palette: { palette: {
type: "dark", mode: "dark",
primary: lightBlue, primary: lightBlue,
secondary: pink, secondary: pink,
}, },

View File

@ -4,7 +4,7 @@
* @author Pierre Hubert * @author Pierre Hubert
*/ */
import { TextField, Button } from "@material-ui/core"; import { TextField, Button } from "@mui/material";
import React from "react"; import React from "react";
import { AdminAccount, AccountHelper } from "../../helpers/AccountHelper"; import { AdminAccount, AccountHelper } from "../../helpers/AccountHelper";
import { snackbar, matAlert } from "../widgets/DialogsProvider"; import { snackbar, matAlert } from "../widgets/DialogsProvider";

View File

@ -8,9 +8,9 @@ import {
TableHead, TableHead,
TableRow, TableRow,
Tooltip, Tooltip,
} from "@material-ui/core"; } from "@mui/material";
import { Delete } from "@material-ui/icons"; import { Delete } from "@mui/icons-material";
import LockIcon from "@material-ui/icons/Lock"; import LockIcon from "@mui/icons-material/Lock";
import React from "react"; import React from "react";
import { AccountHelper, AdminAccount } from "../../helpers/AccountHelper"; import { AccountHelper, AdminAccount } from "../../helpers/AccountHelper";
import { AdminAccountKey, AdminKeyHelper } from "../../helpers/AdminKeyHelper"; import { AdminAccountKey, AdminKeyHelper } from "../../helpers/AdminKeyHelper";

View File

@ -4,7 +4,7 @@
* @author Pierre Hubert * @author Pierre Hubert
*/ */
import { Checkbox, FormControlLabel, Tooltip } from "@material-ui/core"; import { Checkbox, FormControlLabel, Tooltip } from "@mui/material";
import React from "react"; import React from "react";
import { AdminAccount } from "../../helpers/AccountHelper"; import { AdminAccount } from "../../helpers/AccountHelper";
import { import {

View File

@ -1,4 +1,4 @@
import { Grid } from "@material-ui/core"; import { Grid } from "@mui/material";
import React from "react"; import React from "react";
import { CustomCard } from "../widgets/CustomCard"; import { CustomCard } from "../widgets/CustomCard";

View File

@ -6,7 +6,7 @@ import {
TableContainer, TableContainer,
TableHead, TableHead,
TableRow, TableRow,
} from "@material-ui/core"; } from "@mui/material";
import React from "react"; import React from "react";
import { AccountHelper, AdminAccount } from "../../helpers/AccountHelper"; import { AccountHelper, AdminAccount } from "../../helpers/AccountHelper";
import { import {

View File

@ -4,7 +4,7 @@
* @author Pierre Hubert * @author Pierre Hubert
*/ */
import { Grid } from "@material-ui/core"; import { Grid } from "@mui/material";
import React from "react"; import React from "react";
import { useParams } from "react-router-dom"; import { useParams } from "react-router-dom";
import { AccountHelper, AdminAccount } from "../../helpers/AccountHelper"; import { AccountHelper, AdminAccount } from "../../helpers/AccountHelper";

View File

@ -13,9 +13,9 @@ import {
TableContainer, TableContainer,
TableHead, TableHead,
TableRow, TableRow,
} from "@material-ui/core"; } from "@mui/material";
import AddIcon from "@material-ui/icons/Add"; import AddIcon from "@mui/icons-material/Add";
import SettingsIcon from "@material-ui/icons/Settings"; import SettingsIcon from "@mui/icons-material/Settings";
import React from "react"; import React from "react";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { AccountHelper, AdminAccount } from "../../helpers/AccountHelper"; import { AccountHelper, AdminAccount } from "../../helpers/AccountHelper";

View File

@ -6,8 +6,8 @@ import {
TableBody, TableBody,
TableCell, TableCell,
TableRow, TableRow,
} from "@material-ui/core"; } from "@mui/material";
import EmailIcon from "@material-ui/icons/Email"; import EmailIcon from "@mui/icons-material/Email";
import React from "react"; import React from "react";
import { import {
ComunicUser, ComunicUser,
@ -24,7 +24,7 @@ import {
} from "../widgets/DialogsProvider"; } from "../widgets/DialogsProvider";
import { PageTitle } from "../widgets/PageTitle"; import { PageTitle } from "../widgets/PageTitle";
import { TimestampWidget } from "../widgets/TimestampWidget"; import { TimestampWidget } from "../widgets/TimestampWidget";
import LinkIcon from "@material-ui/icons/Link"; import LinkIcon from "@mui/icons-material/Link";
import { CopyToClipboard } from "../../utils/ClipboardUtils"; import { CopyToClipboard } from "../../utils/ClipboardUtils";
interface UserProperty { interface UserProperty {
name: string; name: string;
@ -254,7 +254,7 @@ export class ComunicUserRoute extends React.Component<
> >
<Button <Button
variant="outlined" variant="outlined"
color="default" color="secondary"
startIcon={<EmailIcon />} startIcon={<EmailIcon />}
style={{ style={{
width: "100%", width: "100%",
@ -268,7 +268,7 @@ export class ComunicUserRoute extends React.Component<
<Button <Button
variant="outlined" variant="outlined"
color="default" color="secondary"
startIcon={<LinkIcon />} startIcon={<LinkIcon />}
style={{ width: "100%" }} style={{ width: "100%" }}
onClick={this.createPasswordResetLink} onClick={this.createPasswordResetLink}

View File

@ -17,9 +17,9 @@ import {
Paper, Paper,
TextField, TextField,
Typography, Typography,
} from "@material-ui/core"; } from "@mui/material";
import { ErrorOutline, Lock, VpnKey } from "@material-ui/icons"; import { ErrorOutline, Lock, VpnKey } from "@mui/icons-material";
import LockOutlinedIcon from "@material-ui/icons/LockOutlined"; import LockOutlinedIcon from "@mui/icons-material/LockOutlined";
import React from "react"; import React from "react";
import { AccountHelper, AuthOptions } from "../../helpers/AccountHelper"; import { AccountHelper, AuthOptions } from "../../helpers/AccountHelper";
import { AdminKeyHelper, AuthKey } from "../../helpers/AdminKeyHelper"; import { AdminKeyHelper, AuthKey } from "../../helpers/AdminKeyHelper";

View File

@ -16,19 +16,19 @@ import {
Paper, Paper,
Toolbar, Toolbar,
Typography, Typography,
} from "@material-ui/core"; } from "@mui/material";
import { Home, Person } from "@material-ui/icons"; import { Home, Person } from "@mui/icons-material";
import CloseSharpIcon from "@material-ui/icons/CloseSharp"; import CloseSharpIcon from "@mui/icons-material/CloseSharp";
import GroupIcon from "@material-ui/icons/Group"; import GroupIcon from "@mui/icons-material/Group";
import HistoryIcon from "@material-ui/icons/History"; import HistoryIcon from "@mui/icons-material/History";
import React from "react"; import React from "react";
import { import {
BrowserRouter as Router, BrowserRouter as Router,
Route, Route,
Switch, Routes,
useHistory, useNavigate,
useParams, useParams,
useRouteMatch, useMatch,
} from "react-router-dom"; } from "react-router-dom";
import { AccountHelper, AdminAccountRole } from "../../helpers/AccountHelper"; import { AccountHelper, AdminAccountRole } from "../../helpers/AccountHelper";
import { AccountLogsRoute } from "./AccountLogsRoute"; import { AccountLogsRoute } from "./AccountLogsRoute";
@ -39,55 +39,6 @@ import { HomeRoute } from "./HomeRoute";
import { NotFoundRoute } from "./NotFoundRoute"; import { NotFoundRoute } from "./NotFoundRoute";
import { SearchComunicUsersRoute } from "./SearchComunicUsersRoute"; import { SearchComunicUsersRoute } from "./SearchComunicUsersRoute";
const useStyles = makeStyles((theme) => ({
root: {
display: "flex",
},
toolbar: {
paddingRight: 24, // keep right padding when drawer closed
},
toolbarIcon: {
display: "flex",
alignItems: "center",
justifyContent: "flex-end",
padding: "0 8px",
...theme.mixins.toolbar,
},
appBar: {
zIndex: theme.zIndex.drawer + 1,
width: `100%`,
color: "white",
},
menuButton: {
marginRight: 36,
},
menuButtonHidden: {
display: "none",
},
title: {
flexGrow: 1,
},
appBarSpacer: theme.mixins.toolbar,
content: {
flexGrow: 1,
height: "100vh",
overflow: "auto",
},
container: {
paddingTop: theme.spacing(4),
paddingBottom: theme.spacing(4),
},
paper: {
padding: theme.spacing(2),
display: "flex",
overflow: "auto",
flexDirection: "column",
},
fixedHeight: {
height: 240,
},
}));
function Menu() { function Menu() {
return ( return (
<div> <div>
@ -126,14 +77,10 @@ function MainMenuItem(p: {
uri: string; uri: string;
needsRole?: AdminAccountRole; needsRole?: AdminAccountRole;
}) { }) {
const history = useHistory(); const n = useNavigate();
const openMyAccount = () => history.push(p.uri); const openMyAccount = () => n(p.uri);
const selected = const selected = useMatch(p.uri) != null;
useRouteMatch({
path: p.uri,
exact: true,
}) != null;
// Check if roles are filtered // Check if roles are filtered
if (p.needsRole) { if (p.needsRole) {
@ -150,8 +97,6 @@ function MainMenuItem(p: {
} }
export function MainRoute() { export function MainRoute() {
const classes = useStyles();
const signOut = () => { const signOut = () => {
AccountHelper.signOut(); AccountHelper.signOut();
}; };
@ -169,16 +114,20 @@ export function MainRoute() {
<AppBar <AppBar
position="fixed" position="fixed"
className={classes.appBar} style={{
zIndex: 1,
width: `100%`,
color: "white",
}}
color="primary" color="primary"
> >
<Toolbar className={classes.toolbar}> <Toolbar style={{ padding: 24 }}>
<Typography <Typography
component="h1" component="h1"
variant="h6" variant="h6"
color="inherit" color="inherit"
noWrap noWrap
className={classes.title} style={{ flexGrow: 1 }}
> >
Comunic Console Comunic Console
</Typography> </Typography>
@ -214,12 +163,12 @@ export function MainRoute() {
maxWidth: "1280px", maxWidth: "1280px",
}} }}
> >
<Switch> <Routes>
<Route exact path="/"> <Route path="/">
<HomeRoute></HomeRoute> <HomeRoute></HomeRoute>
</Route> </Route>
<Route exact path="/users"> <Route path="/users">
<SearchComunicUsersRoute /> <SearchComunicUsersRoute />
</Route> </Route>
@ -227,7 +176,7 @@ export function MainRoute() {
<ComunicUserRouteProxy /> <ComunicUserRouteProxy />
</Route> </Route>
<Route exact path="/accounts"> <Route path="/accounts">
<AccountsListRoute /> <AccountsListRoute />
</Route> </Route>
@ -242,7 +191,7 @@ export function MainRoute() {
<Route path="*"> <Route path="*">
<NotFoundRoute /> <NotFoundRoute />
</Route> </Route>
</Switch> </Routes>
</div> </div>
</div> </div>
</div> </div>

View File

@ -4,7 +4,7 @@
* @author Pierre Hubert * @author Pierre Hubert
*/ */
import { Typography } from "@material-ui/core"; import { Typography } from "@mui/material";
export function NotFoundRoute() { export function NotFoundRoute() {
return ( return (

View File

@ -11,9 +11,9 @@ import {
Paper, Paper,
TextField, TextField,
Typography, Typography,
} from "@material-ui/core"; } from "@mui/material";
import React from "react"; import React from "react";
import { useHistory } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { import {
ComunicUsersHelper, ComunicUsersHelper,
SearchResult, SearchResult,
@ -134,11 +134,8 @@ export class SearchComunicUsersRoute extends React.Component<
} }
function ResultItem(p: { user: SearchResult }) { function ResultItem(p: { user: SearchResult }) {
const history = useHistory(); const n = useNavigate();
const openButton = () => { const openButton = () => n("/user/" + p.user.id);
history.push("/user/" + p.user.id);
};
return ( return (
<ListItem button onClick={openButton}> <ListItem button onClick={openButton}>
<Grid container wrap="nowrap" spacing={2}> <Grid container wrap="nowrap" spacing={2}>

View File

@ -4,7 +4,7 @@
* @author Pierre Hubert * @author Pierre Hubert
*/ */
import { Button, Paper } from "@material-ui/core"; import { Button, Paper } from "@mui/material";
import React, { ReactNode } from "react"; import React, { ReactNode } from "react";
import { CenterCircularProgress } from "./CenterCircularProgress"; import { CenterCircularProgress } from "./CenterCircularProgress";

View File

@ -1,12 +1,16 @@
import { CircularProgress } from "@material-ui/core"; import { CircularProgress } from "@mui/material";
export function CenterCircularProgress() { export function CenterCircularProgress() {
return <div style={{ return (
display: "flex", <div
justifyContent: "center", style={{
alignItems: "center", display: "flex",
height: "100%" justifyContent: "center",
}}> alignItems: "center",
<CircularProgress></CircularProgress> height: "100%",
</div> }}
>
<CircularProgress></CircularProgress>
</div>
);
} }

View File

@ -1,4 +1,4 @@
import { Divider, Paper, Typography } from "@material-ui/core"; import { Divider, Paper, Typography } from "@mui/material";
import React from "react"; import React from "react";
export function CustomCard(p: { title: string; children?: React.ReactNode }) { export function CustomCard(p: { title: string; children?: React.ReactNode }) {

View File

@ -14,8 +14,8 @@ import {
TextField, TextField,
Snackbar, Snackbar,
IconButton, IconButton,
} from "@material-ui/core"; } from "@mui/material";
import { Close } from "@material-ui/icons"; import { Close } from "@mui/icons-material";
import React, { FormEvent } from "react"; import React, { FormEvent } from "react";
let cache: ApplicationDialogsProvider; let cache: ApplicationDialogsProvider;
@ -116,7 +116,7 @@ export class ApplicationDialogsProvider extends React.Component<
} }
handleCloseSnackbar( handleCloseSnackbar(
_event: React.SyntheticEvent | React.MouseEvent, _event: React.SyntheticEvent | React.MouseEvent | Event,
reason?: string reason?: string
) { ) {
if (reason === "clickaway") { if (reason === "clickaway") {
@ -216,7 +216,7 @@ export class ApplicationDialogsProvider extends React.Component<
</DialogContentText> </DialogContentText>
</DialogContent> </DialogContent>
<DialogActions> <DialogActions>
<Button onClick={this.handleCloseAlert} color="default"> <Button onClick={this.handleCloseAlert} color="primary">
OK OK
</Button> </Button>
</DialogActions> </DialogActions>
@ -265,10 +265,10 @@ export class ApplicationDialogsProvider extends React.Component<
</DialogContentText> </DialogContentText>
</DialogContent> </DialogContent>
<DialogActions> <DialogActions>
<Button onClick={this.rejectConfirm} color="default"> <Button onClick={this.rejectConfirm} color="secondary">
Cancel Cancel
</Button> </Button>
<Button onClick={this.acceptConfirm} color="default"> <Button onClick={this.acceptConfirm} color="secondary">
Confirm Confirm
</Button> </Button>
</DialogActions> </DialogActions>
@ -305,12 +305,12 @@ export class ApplicationDialogsProvider extends React.Component<
</form> </form>
</DialogContent> </DialogContent>
<DialogActions> <DialogActions>
<Button onClick={this.cancelInput} color="default"> <Button onClick={this.cancelInput} color="secondary">
Cancel Cancel
</Button> </Button>
<Button <Button
onClick={this.confirmInput} onClick={this.confirmInput}
color="default" color="secondary"
disabled={!this.isInputValid} disabled={!this.isInputValid}
> >
OK OK

View File

@ -1,4 +1,4 @@
import { Typography } from "@material-ui/core"; import { Typography } from "@mui/material";
/** /**
* Page title widget * Page title widget

View File

@ -1,4 +1,4 @@
import { Tooltip } from "@material-ui/core"; import { Tooltip } from "@mui/material";
import React from "react"; import React from "react";
/** /**

View File

@ -1,26 +1,20 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "es5", "target": "es5",
"lib": [ "lib": ["dom", "dom.iterable", "esnext"],
"dom", "allowJs": true,
"dom.iterable", "skipLibCheck": true,
"esnext" "esModuleInterop": true,
], "allowSyntheticDefaultImports": true,
"allowJs": true, "strict": true,
"skipLibCheck": true, "forceConsistentCasingInFileNames": true,
"esModuleInterop": true, "noFallthroughCasesInSwitch": true,
"allowSyntheticDefaultImports": true, "module": "esnext",
"strict": true, "moduleResolution": "node",
"forceConsistentCasingInFileNames": true, "resolveJsonModule": true,
"noFallthroughCasesInSwitch": true, "isolatedModules": true,
"module": "esnext", "noEmit": true,
"moduleResolution": "node", "jsx": "react-jsx"
"resolveJsonModule": true, },
"isolatedModules": true, "include": ["src"]
"noEmit": true,
"jsx": "react-jsx"
},
"include": [
"src"
]
} }