]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/components/chat-bot-logs/Dialog.js
chat bot protocol ui
[alttp.git] / resources / js / components / chat-bot-logs / Dialog.js
diff --git a/resources/js/components/chat-bot-logs/Dialog.js b/resources/js/components/chat-bot-logs/Dialog.js
new file mode 100644 (file)
index 0000000..ffe457c
--- /dev/null
@@ -0,0 +1,65 @@
+import PropTypes from 'prop-types';
+import React from 'react';
+import { Alert, Button, Modal } from 'react-bootstrap';
+import { withTranslation } from 'react-i18next';
+
+import List from './List';
+import i18n from '../../i18n';
+
+class Dialog extends React.Component {
+
+       componentDidMount() {
+               this.timer = setInterval(() => {
+                       this.forceUpdate();
+               }, 30000);
+       }
+
+       componentWillUnmount() {
+               clearInterval(this.timer);
+       }
+
+       render() {
+               const {
+                       log,
+                       onHide,
+                       show,
+               } = this.props;
+               return <Modal className="chat-bot-log-dialog" onHide={onHide} show={show} size="lg">
+                       <Modal.Header closeButton>
+                               <Modal.Title>
+                                       {i18n.t('chatBotLog.heading')}
+                               </Modal.Title>
+                       </Modal.Header>
+                       {log && log.length ?
+                               <List log={log} />
+                       :
+                               <Modal.Body>
+                                       <Alert variant="info">
+                                               {i18n.t('chatBotLog.empty')}
+                                       </Alert>
+                               </Modal.Body>
+                       }
+                       <Modal.Footer>
+                               <Button onClick={onHide} variant="secondary">
+                                       {i18n.t('button.close')}
+                               </Button>
+                       </Modal.Footer>
+               </Modal>;
+       }
+
+}
+
+Dialog.propTypes = {
+       log: PropTypes.arrayOf(PropTypes.shape({
+       })),
+       onHide: PropTypes.func,
+       show: PropTypes.bool,
+};
+
+Dialog.defaultProps = {
+       log: null,
+       onHide: null,
+       show: false,
+};
+
+export default withTranslation()(Dialog);