diff --git a/ui/src/Components/MainModal/MainModalContent.js b/ui/src/Components/MainModal/MainModalContent.js new file mode 100644 index 000000000..1784979b6 --- /dev/null +++ b/ui/src/Components/MainModal/MainModalContent.js @@ -0,0 +1,96 @@ +import React, { Component } from "react"; +import ReactDOM from "react-dom"; +import PropTypes from "prop-types"; + +import { observer } from "mobx-react"; +import { observable, action } from "mobx"; + +import { AlertStore } from "Stores/AlertStore"; +import { Settings } from "Stores/Settings"; +import { Configuration } from "./Configuration"; +import { Help } from "./Help"; + +const Tab = ({ title, active, onClick }) => ( + + {title} + +); +Tab.propTypes = { + title: PropTypes.string.isRequired, + active: PropTypes.bool, + onClick: PropTypes.func.isRequired +}; + +const TabNames = Object.freeze({ + Configuration: "configuration", + Help: "help" +}); + +const MainModalContent = observer( + class MainModalContent extends Component { + static propTypes = { + alertStore: PropTypes.instanceOf(AlertStore).isRequired, + settingsStore: PropTypes.instanceOf(Settings).isRequired, + onHide: PropTypes.func.isRequired + }; + + tab = observable( + { + current: TabNames.Configuration, + setTab(newTab) { + this.current = newTab; + } + }, + { setTab: action.bound } + ); + + render() { + const { alertStore, settingsStore, onHide } = this.props; + + return ReactDOM.createPortal( +
+
+
+
+ +
+
+ {this.tab.current === TabNames.Help ? : null} + {this.tab.current === TabNames.Configuration ? ( + + ) : null} +
+
+ + Version: {alertStore.info.version} + +
+
+
+
, + document.body + ); + } + } +); + +export { MainModalContent }; diff --git a/ui/src/Components/MainModal/index.js b/ui/src/Components/MainModal/index.js index f00010604..af98d9d11 100644 --- a/ui/src/Components/MainModal/index.js +++ b/ui/src/Components/MainModal/index.js @@ -9,29 +9,7 @@ import { faCog } from "@fortawesome/free-solid-svg-icons/faCog"; import { AlertStore } from "Stores/AlertStore"; import { Settings } from "Stores/Settings"; -import { Configuration } from "./Configuration"; -import { Help } from "./Help"; - -const Tab = ({ title, active, onClick }) => ( - - {title} - -); -Tab.propTypes = { - title: PropTypes.string.isRequired, - active: PropTypes.bool, - onClick: PropTypes.func.isRequired -}; - -const TabNames = Object.freeze({ - Configuration: "configuration", - Help: "help" -}); +import { MainModalContent } from "./MainModalContent"; const MainModal = observer( class MainModal extends Component { @@ -53,16 +31,6 @@ const MainModal = observer( { toggle: action.bound, hide: action.bound } ); - tab = observable( - { - current: TabNames.Configuration, - setTab(newTab) { - this.current = newTab; - } - }, - { setTab: action.bound } - ); - componentDidUpdate() { document.body.classList.toggle("modal-open", this.toggle.show); } @@ -82,47 +50,11 @@ const MainModal = observer( {this.toggle.show ? ( -
-
-
-
- -
-
- {this.tab.current === TabNames.Help ? : null} - {this.tab.current === TabNames.Configuration ? ( - - ) : null} -
-
- - Version: {alertStore.info.version} - -
-
-
-
+ ) : null} );