description-for-icons-top-bar-are-missing
[arvados.git] / src / components / confirmation-dialog / confirmation-dialog.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import * as React from "react";
6 import { Dialog, DialogTitle, DialogContent, DialogActions, Button, DialogContentText } from "@material-ui/core";
7 import { WithDialogProps } from "../../store/dialog/with-dialog";
8
9 export interface ConfirmationDialogDataProps {
10     title: string;
11     text: string;
12     cancelButtonLabel?: string;
13     confirmButtonLabel?: string;
14 }
15
16 export interface ConfirmationDialogProps {
17     onConfirm: () => void;
18 }
19
20 export const ConfirmationDialog = (props: ConfirmationDialogProps & WithDialogProps<ConfirmationDialogDataProps>) =>
21     <Dialog open={props.open}>
22         <DialogTitle>{props.data.title}</DialogTitle>
23         <DialogContent>
24             <DialogContentText>
25                 {props.data.text}
26             </DialogContentText>
27         </DialogContent>
28         <DialogActions>
29             <Button
30                 variant='flat'
31                 color='primary'
32                 onClick={props.closeDialog}>
33                 {props.data.cancelButtonLabel || 'Cancel'}
34             </Button>
35             <Button
36                 variant='contained'
37                 color='primary'
38                 type='submit'
39                 onClick={props.onConfirm}>
40                 {props.data.confirmButtonLabel || 'Ok'}
41             </Button>
42         </DialogActions>
43     </Dialog>;