diff --git a/embark-ui/src/components/Login.css b/embark-ui/src/components/Login.css new file mode 100644 index 000000000..4c5e94246 --- /dev/null +++ b/embark-ui/src/components/Login.css @@ -0,0 +1,33 @@ +.login-container { + width: 80%; + max-width: 900px; +} + +.login-layout-container-section { + padding: 0.8em; + background: #20a8d8; +} + +.login-layout-container-section:first-child { + background: white; + padding: 3em; +} + +.logo { + display: block; + margin: 0 auto; + max-height: 40px; +} + +@media only screen and (min-width: 768px) { + + .login-layout-container-section { + padding: 3em; + } + + .logo { + max-height: 180px; + margin-top: 3em; + } +} + diff --git a/embark-ui/src/components/Login.js b/embark-ui/src/components/Login.js new file mode 100644 index 000000000..c1e267723 --- /dev/null +++ b/embark-ui/src/components/Login.js @@ -0,0 +1,70 @@ +import PropTypes from "prop-types"; +import React from 'react'; +import logo from '../images/logo.png'; +import './Login.css'; + +class Login extends React.Component { + constructor(props){ + super(props); + this.state = props.credentials; + } + + handleChange(event){ + this.setState({[event.target.name]: event.target.value}); + } + + handleSubmit(event) { + event.preventDefault(); + this.props.authenticate(this.state.host, this.state.token); + } + + render() { + return ( +
+
+
+

Login

+
+
this.handleSubmit(e)}> +
+ + this.handleChange(e)} + value={this.state.host}/> +
+
+ + this.handleChange(e)} + value={this.state.token}/> + Execute embark run in the command line to get your token. +
+ +
+
+
+
+ Embark Logo +
+
+
+ ); + } +} + +Login.propTypes = { + authenticate: PropTypes.func, + credentials: PropTypes.object, + error: PropTypes.string +}; + +export default Login; + diff --git a/embark-ui/src/components/LoginLayout.css b/embark-ui/src/components/LoginLayout.css deleted file mode 100644 index 21cac28dc..000000000 --- a/embark-ui/src/components/LoginLayout.css +++ /dev/null @@ -1,54 +0,0 @@ -.login-layout { - display: flex; - align-items: center; - justify-content: center; -} - -.login-layout-container { - width: 80%; - max-width: 900px; - display: flex; - flex-direction: column; -} - -.login-layout-container-section { - flex: 1; - padding: 0.8em; - background: #20a8d8; - align-items: center; - justify-content: center; - order: 1; -} - -.login-layout-container-section:first-child { - background: white; - padding: 3em; - order: 2; -} - -.logo { - display: block; - margin: 0 auto; - max-height: 40px; -} - -@media only screen and (min-width: 700px) { - - .login-layout-container { - flex-direction: row; - } - - .login-layout-container-section { - padding: 3em; - } - - .login-layout-container-section:first-child { - order: 1; - } - - .logo { - max-height: 180px; - margin-top: 3em; - } -} - diff --git a/embark-ui/src/components/LoginLayout.js b/embark-ui/src/components/LoginLayout.js deleted file mode 100644 index e336abb7a..000000000 --- a/embark-ui/src/components/LoginLayout.js +++ /dev/null @@ -1,18 +0,0 @@ -import React from 'react'; -import logo from '../images/logo.png'; -import './LoginLayout.css'; - -const LoginLayout = ({children}) => ( -
-
-
- {children} -
-
- Embark Logo -
-
-
-); - -export default LoginLayout; diff --git a/embark-ui/src/components/Unauthenticated.css b/embark-ui/src/components/Unauthenticated.css deleted file mode 100644 index 87c025ba1..000000000 --- a/embark-ui/src/components/Unauthenticated.css +++ /dev/null @@ -1,3 +0,0 @@ -.login-form { - margin-top: 1em; -} diff --git a/embark-ui/src/components/Unauthenticated.js b/embark-ui/src/components/Unauthenticated.js deleted file mode 100644 index 10ded37d7..000000000 --- a/embark-ui/src/components/Unauthenticated.js +++ /dev/null @@ -1,62 +0,0 @@ -import PropTypes from "prop-types"; -import React from 'react'; -import './Unauthenticated.css'; - -class Unauthenticated extends React.Component { - constructor(props){ - super(props); - this.state = props.credentials; - } - - handleChange(event){ - this.setState({[event.target.name]: event.target.value}); - } - - handleSubmit(event) { - event.preventDefault(); - this.props.authenticate(this.state.host, this.state.token); - } - - render() { - return ( - -

Login

-
-
this.handleSubmit(e)}> -
- - this.handleChange(e)} - value={this.state.host}/> -
-
- - this.handleChange(e)} - value={this.state.token}/> - Execute embark run in the command line to get your token. -
- -
-
-
- ); - } -} - -Unauthenticated.propTypes = { - authenticate: PropTypes.func, - credentials: PropTypes.object, - error: PropTypes.string -}; - -export default Unauthenticated; - diff --git a/embark-ui/src/containers/AppContainer.js b/embark-ui/src/containers/AppContainer.js index 6b74d2799..8f74d0bf6 100644 --- a/embark-ui/src/containers/AppContainer.js +++ b/embark-ui/src/containers/AppContainer.js @@ -3,9 +3,8 @@ import {connect} from 'react-redux'; import React, {Component} from 'react'; import {withRouter} from "react-router-dom"; import routes from '../routes'; -import Unauthenticated from '../components/Unauthenticated'; +import Login from '../components/Login'; import Layout from "../components/Layout"; -import LoginLayout from '../components/LoginLayout'; import { authenticate, fetchCredentials, logout, @@ -57,17 +56,15 @@ class AppContainer extends Component { } } - shouldRenderUnauthenticated() { + shouldRenderLogin() { return this.props.authenticationError || !this.props.credentials.authenticated; } render() { return ( - {this.shouldRenderUnauthenticated() ? - - - + {this.shouldRenderLogin() ? + : {routes}