Can delete the VM from the WebUI
This commit is contained in:
@ -11,7 +11,8 @@ import React, { PropsWithChildren } from "react";
|
||||
type ConfirmContext = (
|
||||
message: string,
|
||||
title?: string,
|
||||
confirmButton?: string
|
||||
confirmButton?: string,
|
||||
cancelButton?: string
|
||||
) => Promise<boolean>;
|
||||
|
||||
const ConfirmContextK = React.createContext<ConfirmContext | null>(null);
|
||||
@ -26,6 +27,9 @@ export function ConfirmDialogProvider(
|
||||
const [confirmButton, setConfirmButton] = React.useState<string | undefined>(
|
||||
undefined
|
||||
);
|
||||
const [cancelButton, setCancelButton] = React.useState<string | undefined>(
|
||||
undefined
|
||||
);
|
||||
|
||||
const cb = React.useRef<null | ((a: boolean) => void)>(null);
|
||||
|
||||
@ -36,10 +40,16 @@ export function ConfirmDialogProvider(
|
||||
cb.current = null;
|
||||
};
|
||||
|
||||
const hook: ConfirmContext = (message, title, confirmButton) => {
|
||||
const hook: ConfirmContext = (
|
||||
message,
|
||||
title,
|
||||
confirmButton,
|
||||
cancelButton
|
||||
) => {
|
||||
setTitle(title);
|
||||
setMessage(message);
|
||||
setConfirmButton(confirmButton);
|
||||
setCancelButton(cancelButton);
|
||||
setOpen(true);
|
||||
|
||||
return new Promise((res) => {
|
||||
@ -67,7 +77,7 @@ export function ConfirmDialogProvider(
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={() => handleClose(false)} autoFocus>
|
||||
Cancel
|
||||
{cancelButton ?? "Cancel"}
|
||||
</Button>
|
||||
<Button onClick={() => handleClose(true)} color="error">
|
||||
{confirmButton ?? "Confirm"}
|
||||
|
Reference in New Issue
Block a user