From 5d9f9d2681d036b9beb36b510b13ed0d12c57ddc Mon Sep 17 00:00:00 2001 From: Nolshine Date: Thu, 16 Sep 2021 01:21:45 +0100 Subject: [PATCH] implement game delete confirmation modal --- src/ui/React/ConfirmationModal.tsx | 28 ++++++++++++++++++++++++++++ src/ui/React/GameOptionsRoot.tsx | 10 +++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/ui/React/ConfirmationModal.tsx diff --git a/src/ui/React/ConfirmationModal.tsx b/src/ui/React/ConfirmationModal.tsx new file mode 100644 index 000000000..64ff7a47b --- /dev/null +++ b/src/ui/React/ConfirmationModal.tsx @@ -0,0 +1,28 @@ +import React from "react"; +import { Modal } from "./Modal"; + +import Button from "@material-ui/core/Button"; +import Typography from "@material-ui/core/Typography"; + +interface IProps { + open: boolean; + onClose: () => void; + onConfirm: () => void; + confirmationText: string; + } + + export function ConfirmationModal(props: IProps): React.ReactElement { + return ( + + <> + + {props.confirmationText} + + + + + ); + } + \ No newline at end of file diff --git a/src/ui/React/GameOptionsRoot.tsx b/src/ui/React/GameOptionsRoot.tsx index ccdab7861..7d5171ddd 100644 --- a/src/ui/React/GameOptionsRoot.tsx +++ b/src/ui/React/GameOptionsRoot.tsx @@ -17,6 +17,7 @@ import ListItem from "@material-ui/core/ListItem"; import Link from "@material-ui/core/Link"; import Tooltip from "@material-ui/core/Tooltip"; import { FileDiagnosticModal } from "../../Diagnostic/FileDiagnosticModal"; +import { ConfirmationModal } from "./ConfirmationModal"; import { Settings } from "../../Settings/Settings"; @@ -68,6 +69,7 @@ export function GameOptionsRoot(props: IProps): React.ReactElement { const [disableTextEffects, setDisableTextEffects] = useState(Settings.DisableTextEffects); const [locale, setLocale] = useState(Settings.Locale); const [diagnosticOpen, setDiagnosticOpen] = useState(false); + const [deleteGameOpen, setDeleteOpen] = useState(false); function handleExecTimeChange(event: any, newValue: number | number[]): void { setExecTime(newValue as number); @@ -449,7 +451,7 @@ export function GameOptionsRoot(props: IProps): React.ReactElement { - + @@ -513,6 +515,12 @@ export function GameOptionsRoot(props: IProps): React.ReactElement { setDiagnosticOpen(false)} /> + {props.delete(); setDeleteOpen(false);}} + open={deleteGameOpen} + onClose={() => setDeleteOpen(false)} + confirmationText={"Really delete your game? (It's permanent!)"} + /> ); }