1
0
mirror of https://github.com/ascribe/onion.git synced 2024-11-15 17:45:10 +01:00
onion/js/components/header.js

62 lines
1.9 KiB
JavaScript
Raw Normal View History

'use strict';
2015-05-20 16:19:40 +02:00
import React from 'react';
2015-05-21 15:16:56 +02:00
import Router from 'react-router';
2015-05-21 15:14:05 +02:00
2015-05-20 16:19:40 +02:00
import UserActions from '../actions/user_actions';
import UserStore from '../stores/user_store';
import Nav from 'react-bootstrap/lib/Nav';
import Navbar from 'react-bootstrap/lib/Navbar';
import DropdownButton from 'react-bootstrap/lib/DropdownButton';
import MenuItem from 'react-bootstrap/lib/MenuItem';
import { getLangText } from '../utils/lang_utils';
2015-05-21 15:16:56 +02:00
let Link = Router.Link;
2015-05-20 16:19:40 +02:00
let Header = React.createClass({
getInitialState() {
return UserStore.getState();
},
componentDidMount() {
UserActions.fetchCurrentUser();
2015-06-05 11:40:49 +02:00
UserStore.listen(this.onChange);
2015-06-03 11:49:39 +02:00
},
componentWillUnmount() {
2015-06-04 13:16:19 +02:00
UserStore.unlisten(this.onChange);
2015-05-20 16:19:40 +02:00
},
onChange(state) {
this.setState(state);
},
render() {
return (
<Navbar>
<Nav>
2015-06-09 16:10:25 +02:00
<Link className="navbar-brand" to="pieces">
<span>ascribe </span>
<span className="glyph-ascribe-spool-chunked ascribe-color"></span>
2015-06-09 16:10:25 +02:00
</Link>
</Nav>
<Nav right>
2015-06-03 11:49:39 +02:00
<DropdownButton eventKey="1" title={this.state.currentUser.username}>
<MenuItem eventKey="1" href="/art/account_settings/">{getLangText('Account Settings')}</MenuItem>
<li className="divider"></li>
<MenuItem eventKey="2" href="/art/faq/">{getLangText('FAQ')}</MenuItem>
<MenuItem eventKey="3" href="/art/terms/">{getLangText('Terms of Service')}</MenuItem>
<MenuItem divider />
<MenuItem eventKey="4" href="/api/users/logout/">{getLangText('Log out')}</MenuItem>
</DropdownButton>
</Nav>
</Navbar>
2015-05-21 15:20:02 +02:00
);
2015-05-20 16:19:40 +02:00
}
});
export default Header;