Add information to the recovery page

Adds error & environment information to the recovery page when
available. The info will be displayed when the error boundary catches an error only.

Otherwise, does a few minor tweaks to the UI of the page.

- Add DevPage button to throw an uncaught error to go into recovery
- Add "Delete Save" button in recovery from Game Options (refactored into its own
component)
- Use "Soft Reset" button from Game Options (refactored into its own
component)
- The "Soft Reset" & "Delete Save" buttons now have confirmations
- Add tooltip on "Disable Recovery Mode" button
- Add timestamp to the RECOVERY.json filename
- Add textarea containing markdown with the current error details, if
available
  - Error
  - Page
  - Version
  - Environment
  - Platform
  - UserAgent
  - Features
  - Source
  - Stack Trace
- Change GitHub new issue link to contain default body & title, if possible
- Change links to not take the full width (they were clickable by mistake)
- Fix "Disable Recovery Mode" not resetting the ErrorBoundary's state,
making going back to terminal impossible
This commit is contained in:
Martin Fournier
2022-01-10 11:29:58 -05:00
parent 8b69fd7faa
commit 65964c84b2
7 changed files with 325 additions and 74 deletions
+32
View File
@@ -0,0 +1,32 @@
import React, { useState } from 'react';
import { deleteGame } from "../../db";
import { ConfirmationModal } from "./ConfirmationModal";
import Button from "@mui/material/Button";
import { Tooltip } from '@mui/material';
import DeleteIcon from '@mui/icons-material/Delete';
interface IProps {
color?: "primary" | "warning" | "error";
}
export function DeleteGameButton({ color = "primary" }: IProps): React.ReactElement {
const [modalOpened, setModalOpened] = useState(false);
return (<>
<Tooltip title="This will permanently delete your local save game. Did you export it before?">
<Button startIcon={<DeleteIcon />} color={color} onClick={() => setModalOpened(true)}>Delete Save</Button>
</Tooltip>
<ConfirmationModal
onConfirm={() => {
setModalOpened(false);
deleteGame()
.then(() => setTimeout(() => location.reload(), 1000))
.catch((r) => console.error(`Could not delete game: ${r}`));
}}
open={modalOpened}
onClose={() => setModalOpened(false)}
confirmationText={"Really delete your game? (It's permanent!)"}
/>
</>)
}