Commit ac3570e8 authored by Jure's avatar Jure
Browse files

Merge branch 'navigation-unused-method' into 'master'

Remove unused method and refactor to stateless component

See merge request !60
parents eac62aec 49e8765c
......@@ -6,54 +6,39 @@ import { Navbar, Nav, NavItem, NavbarBrand } from 'react-bootstrap'
import Authorize from 'pubsweet-client/src/helpers/Authorize'
import NavbarUser from './NavbarUser'
export default class Navigation extends React.Component {
constructor (props) {
super(props)
this.logoutClick = this.logoutClick.bind(this)
this.redirectTo = CONFIG['pubsweet-client']['logout-redirect'] || '/'
}
render () {
const { actions, currentUser } = this.props
let logoutButtonIfAuthenticated
if (currentUser.isAuthenticated) {
logoutButtonIfAuthenticated = <NavbarUser
user={currentUser.user}
onLogoutClick={actions.logoutUser}
/>
const Navigation = ({ actions, currentUser }) => (
<Navbar fluid>
<Navbar.Header>
<NavbarBrand>
<a href='#'><img src='/pubsweet.jpg' alt='pubsweet' /></a>
</NavbarBrand>
</Navbar.Header>
<Nav eventKey={0}>
<LinkContainer to='/manage/posts'>
<NavItem>Posts</NavItem>
</LinkContainer>
<Authorize operation='read' object='users'>
<LinkContainer to='/manage/users'>
<NavItem>Users</NavItem>
</LinkContainer>
</Authorize>
<Authorize operation='read' object='teams'>
<LinkContainer to='/manage/teams'>
<NavItem>Teams</NavItem>
</LinkContainer>
</Authorize>
</Nav>
{
currentUser &&
currentUser.isAuthenticated &&
<NavbarUser user={currentUser.user} onLogoutClick={actions.logoutUser}/>
}
return (
<Navbar fluid>
<Navbar.Header>
<NavbarBrand>
<a href='#'><img src='/pubsweet.jpg' alt='pubsweet' /></a>
</NavbarBrand>
</Navbar.Header>
<Nav eventKey={0}>
<LinkContainer to='/manage/posts'>
<NavItem>Posts</NavItem>
</LinkContainer>
<Authorize operation='read' object='users'>
<LinkContainer to='/manage/users'>
<NavItem>Users</NavItem>
</LinkContainer>
</Authorize>
<Authorize operation='read' object='teams'>
<LinkContainer to='/manage/teams'>
<NavItem>Teams</NavItem>
</LinkContainer>
</Authorize>
</Nav>
{ logoutButtonIfAuthenticated }
</Navbar>
)
}
logoutClick (event) {
event.preventDefault()
this.props.actions.logoutUser(this.redirectTo)
}
}
</Navbar>
)
Navigation.propTypes = {
actions: PropTypes.object.isRequired,
currentUser: PropTypes.object
}
export default Navigation
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment