From c7d2545ec7bbcdba30b775453d53df5a359410bd Mon Sep 17 00:00:00 2001
From: crupest <crupest@outlook.com>
Date: Thu, 21 Sep 2023 15:35:27 +0800
Subject: Revert dialog.

---
 FrontEnd/src/components/dialog/OperationDialog.tsx | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

(limited to 'FrontEnd/src/components/dialog/OperationDialog.tsx')

diff --git a/FrontEnd/src/components/dialog/OperationDialog.tsx b/FrontEnd/src/components/dialog/OperationDialog.tsx
index 6ca4d0a0..feaf5c79 100644
--- a/FrontEnd/src/components/dialog/OperationDialog.tsx
+++ b/FrontEnd/src/components/dialog/OperationDialog.tsx
@@ -11,7 +11,6 @@ import {
 import { ButtonRowV2 } from "../button";
 import Dialog from "./Dialog";
 import DialogContainer from "./DialogContainer";
-import { useDialogController } from "./DialogProvider";
 
 import "./OperationDialog.css";
 
@@ -36,6 +35,8 @@ function OperationDialogPrompt(props: OperationDialogPromptProps) {
 }
 
 export interface OperationDialogProps<TData> {
+  open: boolean;
+  onClose: () => void;
   color?: ThemeColor;
   inputColor?: ThemeColor;
   title: Text;
@@ -54,6 +55,8 @@ export interface OperationDialogProps<TData> {
 
 function OperationDialog<TData>(props: OperationDialogProps<TData>) {
   const {
+    open,
+    onClose,
     color,
     inputColor,
     title,
@@ -92,8 +95,6 @@ function OperationDialog<TData>(props: OperationDialogProps<TData>) {
         data: unknown;
       };
 
-  const dialogController = useDialogController();
-
   const [step, setStep] = useState<Step>({ type: "input" });
 
   const { inputGroupProps, hasErrorAndDirty, setAllDisabled, confirm } =
@@ -103,7 +104,7 @@ function OperationDialog<TData>(props: OperationDialogProps<TData>) {
 
   function close() {
     if (step.type !== "process") {
-      dialogController.closeDialog();
+      onClose();
       if (step.type === "success" && onSuccessAndClose) {
         onSuccessAndClose?.(step.data);
       }
@@ -116,7 +117,6 @@ function OperationDialog<TData>(props: OperationDialogProps<TData>) {
     const result = confirm();
     if (result.type === "ok") {
       setStep({ type: "process" });
-      dialogController.setCanSwitchDialog(false);
       setAllDisabled(true);
       onProcess(result.values)
         .then(
@@ -133,9 +133,6 @@ function OperationDialog<TData>(props: OperationDialogProps<TData>) {
             });
           },
         )
-        .finally(() => {
-          dialogController.setCanSwitchDialog(true);
-        });
     }
   }
 
@@ -210,7 +207,7 @@ function OperationDialog<TData>(props: OperationDialogProps<TData>) {
   }
 
   return (
-    <Dialog color={color}>
+    <Dialog open={open} onClose={close} color={color}>
       <DialogContainer title={title} titleColor={color} buttonsV2={buttons}>
         {body}
       </DialogContainer>
-- 
cgit v1.2.3

