File tree 1 file changed +52
-0
lines changed
h/static/scripts/group-forms/components
1 file changed +52
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { ModalDialog , Button } from '@hypothesis/frontend-shared' ;
2
+
3
+ export type WarningDialogProps = {
4
+ /** Title of the dialog. */
5
+ title : string ;
6
+
7
+ /** Message displayed in the dialog. */
8
+ message : string ;
9
+
10
+ /** Label for the confirmation button. */
11
+ confirmAction : string ;
12
+
13
+ /** Callback invoked when the user confirms the action. */
14
+ onConfirm : ( ) => void ;
15
+
16
+ /** Callback invoked when the user aborts the action. */
17
+ onCancel : ( ) => void ;
18
+ } ;
19
+
20
+ /**
21
+ * A modal dialog that warns users about a potentially destructive action.
22
+ */
23
+ export default function WarningDialog ( {
24
+ title,
25
+ message,
26
+ confirmAction,
27
+ onConfirm,
28
+ onCancel,
29
+ } : WarningDialogProps ) {
30
+ return (
31
+ < ModalDialog
32
+ buttons = {
33
+ < >
34
+ < Button data-testid = "cancel-button" onClick = { onCancel } >
35
+ Cancel
36
+ </ Button >
37
+ < Button
38
+ variant = "primary"
39
+ data-testid = "confirm-button"
40
+ onClick = { onConfirm }
41
+ >
42
+ { confirmAction }
43
+ </ Button >
44
+ </ >
45
+ }
46
+ title = { title }
47
+ onClose = { onCancel }
48
+ >
49
+ { message }
50
+ </ ModalDialog >
51
+ ) ;
52
+ }
You can’t perform that action at this time.
0 commit comments