diff options
author | Kali Kaneko (leap communications) <kali@leap.se> | 2016-09-01 01:44:34 -0400 |
---|---|---|
committer | Kali Kaneko (leap communications) <kali@leap.se> | 2016-09-01 01:44:34 -0400 |
commit | 4728855b40d2d37da8e035c5081fab5819b07fd0 (patch) | |
tree | c8a7c727521fe06a2c4fe9221cb77d30e8f0c3b9 /src/leap/bitmask_js/app/components/main_panel/user_section.js | |
parent | 4613e74ce4e2c8b125a6a61585a4aec5f5151969 (diff) |
[refactor] move js to top-level folder
Diffstat (limited to 'src/leap/bitmask_js/app/components/main_panel/user_section.js')
-rw-r--r-- | src/leap/bitmask_js/app/components/main_panel/user_section.js | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/src/leap/bitmask_js/app/components/main_panel/user_section.js b/src/leap/bitmask_js/app/components/main_panel/user_section.js deleted file mode 100644 index 0b4ba136..00000000 --- a/src/leap/bitmask_js/app/components/main_panel/user_section.js +++ /dev/null @@ -1,71 +0,0 @@ -import React from 'react' -import { Button, Glyphicon, Alert } from 'react-bootstrap' -import SectionLayout from './section_layout' -import Login from 'components/login' -import Spinner from 'components/spinner' -import Account from 'models/account' - -import bitmask from 'lib/bitmask' - -export default class UserSection extends React.Component { - - static get defaultProps() {return{ - account: null, - onLogout: null, - onLogin: null - }} - - constructor(props) { - super(props) - this.state = { - error: null, - loading: false - } - this.logout = this.logout.bind(this) - } - - logout() { - this.setState({loading: true}) - this.props.account.logout().then( - account => { - this.setState({error: null, loading: false}) - if (this.props.onLogout) { - this.props.onLogout(account) - } - }, error => { - this.setState({error: error, loading: false}) - } - ) - } - - render () { - let message = null - if (this.state.error) { - // style may be: success, warning, danger, info - message = ( - <Alert bsStyle="danger">{this.state.error}</Alert> - ) - } - - if (this.props.account.authenticated) { - let button = null - if (this.state.loading) { - button = <Button disabled={true}><Spinner /></Button> - } else { - button = <Button onClick={this.logout}>Log Out</Button> - } - return ( - <SectionLayout icon="user" buttons={button} status="on"> - <h1>{this.props.account.address}</h1> - {message} - </SectionLayout> - ) - } else { - return ( - <SectionLayout icon="user" className="wide-margin"> - <Login onLogin={this.props.onLogin} domain={this.props.account.domain} /> - </SectionLayout> - ) - } - } -} |