ente/src/components/MessageDailog.tsx

59 lines
1.8 KiB
TypeScript
Raw Normal View History

2021-04-05 11:59:22 +00:00
import React from 'react';
import { Button, Modal } from 'react-bootstrap';
2021-04-05 12:17:33 +00:00
import constants from 'utils/strings/constants';
2021-04-05 11:59:22 +00:00
interface Props {
show: boolean;
2021-04-05 12:10:32 +00:00
children?: any;
2021-04-05 11:59:22 +00:00
onHide: () => void;
2021-04-05 12:10:32 +00:00
attributes?: {
title?: string;
2021-04-05 12:17:33 +00:00
ok?: boolean;
staticBackdrop?: boolean;
2021-04-05 12:17:33 +00:00
cancel?: { text: string };
2021-04-05 12:10:32 +00:00
proceed?: { text: string; action: any };
2021-04-05 11:59:22 +00:00
};
}
export function MessageDialog({ attributes, children, ...props }: Props) {
return (
<Modal
{...props}
size="lg"
centered
backdrop={attributes?.staticBackdrop ? 'static' : 'true'}
>
2021-04-05 11:59:22 +00:00
<Modal.Body>
2021-04-05 13:17:18 +00:00
{attributes?.title && (
2021-04-05 11:59:22 +00:00
<Modal.Title>
<strong>{attributes.title}</strong>
<hr />
</Modal.Title>
)}
{children}
</Modal.Body>
2021-04-05 13:17:18 +00:00
{attributes && (
<Modal.Footer style={{ borderTop: 'none' }}>
{attributes.ok && (
<Button variant="secondary" onClick={props.onHide}>
{constants.OK}
</Button>
)}
{attributes.cancel && (
2021-04-05 13:53:12 +00:00
<Button variant="outline-danger" onClick={props.onHide}>
2021-04-05 13:17:18 +00:00
{attributes.cancel.text}
</Button>
)}
{attributes.proceed && (
<Button
2021-04-05 13:53:12 +00:00
variant="outline-success"
2021-04-05 13:17:18 +00:00
onClick={attributes.proceed.action}
>
{attributes.proceed.text}
</Button>
)}
</Modal.Footer>
)}
2021-04-05 11:59:22 +00:00
</Modal>
);
}