ente/src/components/MessageDailog.tsx

51 lines
1.6 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;
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>
<Modal.Body>
{attributes.title && (
<Modal.Title>
<strong>{attributes.title}</strong>
<hr />
</Modal.Title>
)}
{children}
</Modal.Body>
<Modal.Footer style={{ borderTop: 'none' }}>
2021-04-05 12:17:33 +00:00
{attributes.ok && (
<Button variant="secondary" onClick={props.onHide}>
{constants.OK}
</Button>
)}
{attributes.cancel && (
2021-04-05 12:10:32 +00:00
<Button variant="danger" onClick={props.onHide}>
2021-04-05 12:17:33 +00:00
{attributes.cancel.text}
2021-04-05 11:59:22 +00:00
</Button>
)}
{attributes.proceed && (
<Button
variant="success"
onClick={attributes.proceed.action}
>
{attributes.proceed.text}
</Button>
)}
</Modal.Footer>
</Modal>
);
}