Skip to content

Commit 70ac230

Browse files
committed
disable cancel/abort buttons after aborting
1 parent 5a381ef commit 70ac230

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

src/views/Validator/AbortDialog.tsx

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Box, Button, Dialog, Flex, Text } from '@radix-ui/themes'
2+
import { useState } from 'react'
23

34
interface AbortDialogProps {
45
open: boolean
@@ -7,15 +8,28 @@ interface AbortDialogProps {
78
}
89

910
export function AbortDialog({ open, onCancel, onAbort }: AbortDialogProps) {
11+
const [isAborting, setIsAborting] = useState(false)
12+
13+
const handleCancel = () => {
14+
onCancel()
15+
}
16+
17+
const handleAbort = () => {
18+
setIsAborting(true)
19+
20+
onAbort()
21+
}
22+
23+
const handleOpenChange = (nextOpen: boolean) => {
24+
if (nextOpen || isAborting) {
25+
return
26+
}
27+
28+
onCancel()
29+
}
30+
1031
return (
11-
<Dialog.Root
12-
open={open}
13-
onOpenChange={(nextOpen) => {
14-
if (!nextOpen) {
15-
onCancel()
16-
}
17-
}}
18-
>
32+
<Dialog.Root open={open} onOpenChange={handleOpenChange}>
1933
<Dialog.Content size="3">
2034
<Flex direction="column" minHeight="150px">
2135
<Dialog.Title>Debugging</Dialog.Title>
@@ -26,11 +40,16 @@ export function AbortDialog({ open, onCancel, onAbort }: AbortDialogProps) {
2640
</Box>
2741
<Flex justify="end" gap="3">
2842
<Dialog.Close>
29-
<Button variant="outline" color="orange">
43+
<Button
44+
disabled={isAborting}
45+
variant="outline"
46+
color="orange"
47+
onClick={handleCancel}
48+
>
3049
Cancel
3150
</Button>
3251
</Dialog.Close>
33-
<Button color="red" onClick={onAbort}>
52+
<Button disabled={isAborting} color="red" onClick={handleAbort}>
3453
Abort
3554
</Button>
3655
</Flex>

0 commit comments

Comments
 (0)