Update Material-UI imports to MUI imports

master^2
Tudor Stanciu 2024-03-25 02:06:10 +02:00
parent 95d92db790
commit d9501339c6
12 changed files with 34 additions and 103 deletions

View File

@ -1,12 +1,7 @@
import React, { useState } from "react"; import React, { useState } from "react";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import { import { InputAdornment, TextField, makeStyles, IconButton } from "@mui/material";
InputAdornment, import { Visibility, VisibilityOff, LockOutlined } from "@mui/icons-material";
TextField,
makeStyles,
IconButton
} from "@material-ui/core";
import { Visibility, VisibilityOff, LockOutlined } from "@material-ui/icons";
const useStyles = makeStyles(theme => ({ const useStyles = makeStyles(theme => ({
margin: { margin: {

View File

@ -1,9 +1,6 @@
import React from "react"; import React from "react";
import { IconButton } from "@material-ui/core"; import { IconButton } from "@material-ui/core";
import { import { Brightness2 as MoonIcon, WbSunny as SunIcon } from "@mui/icons-material";
Brightness2 as MoonIcon,
WbSunny as SunIcon
} from "@material-ui/icons";
import { useApplicationTheme } from "../../providers/ThemeProvider"; import { useApplicationTheme } from "../../providers/ThemeProvider";
const LightDarkToggle = () => { const LightDarkToggle = () => {
@ -12,11 +9,7 @@ const LightDarkToggle = () => {
const handleChange = () => onDarkModeChanged(!isDark); const handleChange = () => onDarkModeChanged(!isDark);
return ( return (
<IconButton <IconButton aria-label="light-dark-toggle" color="inherit" onClick={handleChange}>
aria-label="light-dark-toggle"
color="inherit"
onClick={handleChange}
>
{isDark ? <SunIcon /> : <MoonIcon />} {isDark ? <SunIcon /> : <MoonIcon />}
</IconButton> </IconButton>
); );

View File

@ -1,9 +1,6 @@
import React from "react"; import React from "react";
import { IconButton } from "@material-ui/core"; import { IconButton } from "@material-ui/core";
import { import { Visibility as VisibilityIcon, VisibilityOff as VisibilityOffIcon } from "@mui/icons-material";
Visibility as VisibilityIcon,
VisibilityOff as VisibilityOffIcon
} from "@material-ui/icons";
import { useSensitiveInfo } from "../../hooks"; import { useSensitiveInfo } from "../../hooks";
const SensitiveInfoToggle = () => { const SensitiveInfoToggle = () => {
@ -12,11 +9,7 @@ const SensitiveInfoToggle = () => {
const handleChange = () => onSensitiveInfoEnabled(!enabled); const handleChange = () => onSensitiveInfoEnabled(!enabled);
return ( return (
<IconButton <IconButton aria-label="sensitive-info-toggle" color="inherit" onClick={handleChange}>
aria-label="sensitive-info-toggle"
color="inherit"
onClick={handleChange}
>
{enabled ? <VisibilityOffIcon /> : <VisibilityIcon />} {enabled ? <VisibilityOffIcon /> : <VisibilityIcon />}
</IconButton> </IconButton>
); );

View File

@ -29,7 +29,7 @@ import {
Star, Star,
Whatshot, Whatshot,
Widgets Widgets
} from "@material-ui/icons"; } from "@mui/icons-material";
const timelineIcons = [ const timelineIcons = [
Announcement, Announcement,
@ -84,10 +84,7 @@ const TimelineComponent = ({ releases }) => {
</Typography> </Typography>
</TimelineOppositeContent> </TimelineOppositeContent>
<TimelineSeparator> <TimelineSeparator>
<TimelineDot <TimelineDot color={release.dot.color} variant={release.dot.variant}>
color={release.dot.color}
variant={release.dot.variant}
>
<release.icon /> <release.icon />
</TimelineDot> </TimelineDot>
{!release.isLast && <TimelineConnector />} {!release.isLast && <TimelineConnector />}

View File

@ -1,14 +1,8 @@
import React from "react"; import React from "react";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import { makeStyles } from "@material-ui/core/styles"; import { makeStyles } from "@material-ui/core/styles";
import { import { TextField, InputAdornment, Button, CardActions, CardContent } from "@material-ui/core";
TextField, import { AccountCircleOutlined } from "@mui/icons-material";
InputAdornment,
Button,
CardActions,
CardContent
} from "@material-ui/core";
import { AccountCircleOutlined } from "@material-ui/icons";
import PasswordField from "../../../components/common/inputs/PasswordField"; import PasswordField from "../../../components/common/inputs/PasswordField";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import styles from "../styles"; import styles from "../styles";
@ -49,12 +43,7 @@ const LoginComponent = ({ credentials, onChange, onLogin }) => {
/> />
</CardContent> </CardContent>
<CardActions className={classes.actions}> <CardActions className={classes.actions}>
<Button <Button className={classes.onRight} variant="contained" color="primary" onClick={onLogin}>
className={classes.onRight}
variant="contained"
color="primary"
onClick={onLogin}
>
{t("Login.Label")} {t("Login.Label")}
</Button> </Button>
</CardActions> </CardActions>

View File

@ -4,7 +4,7 @@ import MachineTableRow from "./MachineTableRow";
import MachineAccordion from "./MachineAccordion"; import MachineAccordion from "./MachineAccordion";
import { ViewModes } from "./ViewModeSelection"; import { ViewModes } from "./ViewModeSelection";
import { useToast } from "../../../hooks"; import { useToast } from "../../../hooks";
import { LastPage, RotateLeft, Launch, Stop } from "@material-ui/icons"; import { LastPage, RotateLeft, Launch, Stop } from "@mui/icons-material";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { routes, post } from "../../../utils/api"; import { routes, post } from "../../../utils/api";
@ -106,20 +106,10 @@ const MachineContainer = ({ machine, viewMode }) => {
return ( return (
<> <>
{viewMode === ViewModes.TABLE && ( {viewMode === ViewModes.TABLE && (
<MachineTableRow <MachineTableRow machine={machine} actions={actions} logs={logs} addLog={addLog} />
machine={machine}
actions={actions}
logs={logs}
addLog={addLog}
/>
)} )}
{viewMode === ViewModes.ACCORDION && ( {viewMode === ViewModes.ACCORDION && (
<MachineAccordion <MachineAccordion machine={machine} actions={actions} logs={logs} addLog={addLog} />
machine={machine}
actions={actions}
logs={logs}
addLog={addLog}
/>
)} )}
</> </>
); );

View File

@ -1,7 +1,7 @@
import React from "react"; import React from "react";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import { TableCell, TableRow, IconButton, Collapse } from "@material-ui/core"; import { TableCell, TableRow, IconButton, Collapse } from "@material-ui/core";
import { KeyboardArrowDown, KeyboardArrowUp } from "@material-ui/icons"; import { KeyboardArrowDown, KeyboardArrowUp } from "@mui/icons-material";
import { makeStyles } from "@material-ui/core/styles"; import { makeStyles } from "@material-ui/core/styles";
import MachineCollapsedContent from "./common/MachineCollapsedContent"; import MachineCollapsedContent from "./common/MachineCollapsedContent";
import { useSensitiveInfo } from "../../../hooks"; import { useSensitiveInfo } from "../../../hooks";
@ -24,11 +24,7 @@ const MachineTableRow = ({ machine, actions, logs, addLog }) => {
<React.Fragment> <React.Fragment>
<TableRow className={classes.root}> <TableRow className={classes.root}>
<TableCell> <TableCell>
<IconButton <IconButton aria-label="expand row" size="small" onClick={() => setOpen(!open)}>
aria-label="expand row"
size="small"
onClick={() => setOpen(!open)}
>
{open ? <KeyboardArrowUp /> : <KeyboardArrowDown />} {open ? <KeyboardArrowUp /> : <KeyboardArrowDown />}
</IconButton> </IconButton>
</TableCell> </TableCell>
@ -45,11 +41,7 @@ const MachineTableRow = ({ machine, actions, logs, addLog }) => {
<TableRow> <TableRow>
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={6}> <TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={6}>
<Collapse in={open} timeout="auto" unmountOnExit> <Collapse in={open} timeout="auto" unmountOnExit>
<MachineCollapsedContent <MachineCollapsedContent description={machine.description} logs={logs} style={{ paddingBottom: "10px" }} />
description={machine.description}
logs={logs}
style={{ paddingBottom: "10px" }}
/>
</Collapse> </Collapse>
</TableCell> </TableCell>
</TableRow> </TableRow>

View File

@ -3,7 +3,7 @@ import PropTypes from "prop-types";
import WakeComponent from "./WakeComponent"; import WakeComponent from "./WakeComponent";
import ActionButton from "./ActionButton"; import ActionButton from "./ActionButton";
import { Menu } from "@material-ui/core"; import { Menu } from "@material-ui/core";
import { MoreHoriz } from "@material-ui/icons"; import { MoreHoriz } from "@mui/icons-material";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { usePermissions } from "../../../../hooks"; import { usePermissions } from "../../../../hooks";
@ -13,15 +13,9 @@ const ActionsGroup = ({ machine, actions, addLog }) => {
const { t } = useTranslation(); const { t } = useTranslation();
const { operateMachines: canOperateMachines } = usePermissions(); const { operateMachines: canOperateMachines } = usePermissions();
const mainActions = useMemo( const mainActions = useMemo(() => actions.filter(a => a.main === true), [actions]);
() => actions.filter(a => a.main === true),
[actions]
);
const secondaryActions = useMemo( const secondaryActions = useMemo(() => actions.filter(a => a.main === false), [actions]);
() => actions.filter(a => a.main === false),
[actions]
);
const handleMenuOpen = (_, event) => { const handleMenuOpen = (_, event) => {
setMenuAnchor(event.currentTarget); setMenuAnchor(event.currentTarget);
@ -33,11 +27,7 @@ const ActionsGroup = ({ machine, actions, addLog }) => {
return ( return (
<> <>
<WakeComponent <WakeComponent machine={machine} addLog={addLog} disabled={!canOperateMachines} />
machine={machine}
addLog={addLog}
disabled={!canOperateMachines}
/>
{mainActions.map(action => ( {mainActions.map(action => (
<ActionButton <ActionButton
key={`machine-item-${machine.machineId}-${action.code}`} key={`machine-item-${machine.machineId}-${action.code}`}

View File

@ -1,7 +1,7 @@
import React, { useState, useEffect, useCallback } from "react"; import React, { useState, useEffect, useCallback } from "react";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import { IconButton, Tooltip } from "@material-ui/core"; import { IconButton, Tooltip } from "@material-ui/core";
import { PowerSettingsNew } from "@material-ui/icons"; import { PowerSettingsNew } from "@mui/icons-material";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { useToast } from "../../../../hooks"; import { useToast } from "../../../../hooks";
import { msToMinAndSec } from "../../../../utils/time"; import { msToMinAndSec } from "../../../../utils/time";
@ -18,10 +18,8 @@ const WakeComponent = ({ machine, addLog, disabled }) => {
const { t } = useTranslation(); const { t } = useTranslation();
const { success, error } = useToast(); const { success, error } = useToast();
const pingInterval = const pingInterval = process.env.REACT_APP_MACHINE_PING_INTERVAL || defaultPingInterval;
process.env.REACT_APP_MACHINE_PING_INTERVAL || defaultPingInterval; const startingTime = process.env.REACT_APP_MACHINE_STARTING_TIME || defaultStartingTime;
const startingTime =
process.env.REACT_APP_MACHINE_STARTING_TIME || defaultStartingTime;
const getCurrentDateTime = useCallback(() => { const getCurrentDateTime = useCallback(() => {
const currentDateTime = Date.now(); const currentDateTime = Date.now();
@ -31,10 +29,7 @@ const WakeComponent = ({ machine, addLog, disabled }) => {
return result; return result;
}, [t]); }, [t]);
const log = useCallback( const log = useCallback(message => addLog(`[${getCurrentDateTime()}] ${message}`), [addLog, getCurrentDateTime]);
message => addLog(`[${getCurrentDateTime()}] ${message}`),
[addLog, getCurrentDateTime]
);
const wakeMachine = useCallback(async () => { const wakeMachine = useCallback(async () => {
await post( await post(
@ -48,11 +43,7 @@ const WakeComponent = ({ machine, addLog, disabled }) => {
success(result.status); success(result.status);
//retrigger //retrigger
log( log(`Periodic ping will be re-triggered in ${startingTime} ms [${msToMinAndSec(startingTime)}]`);
`Periodic ping will be re-triggered in ${startingTime} ms [${msToMinAndSec(
startingTime
)}]`
);
setTimeout(() => { setTimeout(() => {
setTrigger(prev => !prev); setTrigger(prev => !prev);
}, startingTime); }, startingTime);

View File

@ -1,14 +1,16 @@
import React, { Suspense } from "react"; import React, { Suspense } from "react";
import ReactDOM from "react-dom"; import ReactDOM from "react-dom/client";
import ThemeProvider from "./providers/ThemeProvider"; import ThemeProvider from "./providers/ThemeProvider";
import CssBaseline from "@material-ui/core/CssBaseline"; import { CssBaseline } from "@mui/material";
import AppRouter from "./components/AppRouter"; import AppRouter from "./components/AppRouter";
import { TuitioProvider } from "@flare/tuitio-client-react"; import { TuitioProvider } from "@flare/tuitio-client-react";
import { ToastProvider } from "./providers"; import { ToastProvider } from "./providers";
import env from "./utils/env"; import env from "./utils/env";
import "./utils/i18n"; import "./utils/i18n";
ReactDOM.render( const root = ReactDOM.createRoot(document.getElementById("root") as HTMLElement);
root.render(
<TuitioProvider tuitioUrl={env.REACT_APP_TUITIO_URL}> <TuitioProvider tuitioUrl={env.REACT_APP_TUITIO_URL}>
<ThemeProvider> <ThemeProvider>
<CssBaseline /> <CssBaseline />
@ -18,6 +20,5 @@ ReactDOM.render(
</ToastProvider> </ToastProvider>
</Suspense> </Suspense>
</ThemeProvider> </ThemeProvider>
</TuitioProvider>, </TuitioProvider>
document.getElementById("root")
); );

View File

@ -1,6 +1,6 @@
import React, { useReducer, useMemo, useContext } from "react"; import React, { useReducer, useMemo, useContext } from "react";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import { ThemeProvider as MuiThemeProvider } from "@material-ui/styles"; import { ThemeProvider as MuiThemeProvider } from "@mui/material/styles";
import { localStorage } from "@flare/js-utils"; import { localStorage } from "@flare/js-utils";
import { getThemes } from "../themes"; import { getThemes } from "../themes";

View File

@ -38,7 +38,7 @@ const handleError = err => {
}; };
const defaultOptions = { const defaultOptions = {
onCompleted: () => {}, onCompleted: () => null,
onError: handleError onError: handleError
}; };