diff --git a/src/components/CodeEditorWindow/Menu/SpeedDialMenu.jsx b/src/components/CodeEditorWindow/Menu/SpeedDialMenu.jsx index adabacb0..20ab7e25 100644 --- a/src/components/CodeEditorWindow/Menu/SpeedDialMenu.jsx +++ b/src/components/CodeEditorWindow/Menu/SpeedDialMenu.jsx @@ -1,13 +1,13 @@ import React from "react"; import PropTypes from "prop-types"; -import Box from "@mui/material/Box"; import SpeedDial from "@mui/material/SpeedDial"; import Bolt from "@mui/icons-material/Bolt"; import SpeedDialAction from "@mui/material/SpeedDialAction"; import SaveIcon from "@mui/icons-material/Save"; import HistoryRounded from "@mui/icons-material/HistoryRounded"; +import RestartAlt from "@mui/icons-material/RestartAlt"; -function SpeedDialMenu({ openSavedCode, openHistory }) { +function SpeedDialMenu({ openSavedCode, openHistory, resetConsole }) { const [open, setOpen] = React.useState(false); const handleOpen = () => setOpen(true); const handleClose = () => setOpen(false); @@ -36,6 +36,13 @@ function SpeedDialMenu({ openSavedCode, openHistory }) { tooltipOpen onClick={openHistory} /> + } + tooltipTitle={"Reset"} + tooltipOpen + onClick={resetConsole} + /> ); } @@ -44,6 +51,7 @@ function SpeedDialMenu({ openSavedCode, openHistory }) { SpeedDialMenu.propTypes = { openSavedCode: PropTypes.func, openHistory: PropTypes.func, + resetConsole: PropTypes.func, }; export default SpeedDialMenu; \ No newline at end of file diff --git a/src/pages/Console.jsx b/src/pages/Console.jsx index 503bf864..06b77195 100644 --- a/src/pages/Console.jsx +++ b/src/pages/Console.jsx @@ -5,7 +5,6 @@ import Box from "@mui/material/Box"; import { Typography, Grid } from "@mui/material"; import ErrorNotifier from "../components/ToastNotifications/ErrorNotifier"; import { Panel, PanelGroup, PanelResizeHandle } from "react-resizable-panels"; -import Menu from "../components/CodeEditorWindow/Menu"; import CodeEditorWindow from "../components/CodeEditorWindow"; import ResultEditorWindow from "../components/ResultEditorWindow"; import SpeedDialMenu from "../components/CodeEditorWindow/Menu/SpeedDialMenu"; @@ -43,7 +42,7 @@ const defaultResult = `{}`; function Console() { const theme = useTheme(); - const [code, setCode] = useState(query); + const [code, setCode] = useState( localStorage.getItem('qwuiConsoleCode') ?? query); const [result, setResult] = useState(defaultResult); const [errorMessage, setErrorMessage] = useState(null); @@ -53,6 +52,7 @@ function Console() { const onChangeCode = (action, data) => { switch (action) { case "code": { + localStorage.setItem("qwuiConsoleCode", data); setCode(data); break; } @@ -114,7 +114,9 @@ function Console() { setOpenHistory(true)} - openSavedCode={() => setOpenSavedCode(true)}/> + openSavedCode={() => setOpenSavedCode(true)} + resetConsole={() => onChangeCode("code", query)} + />