index.jsx 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. Copyright (C) 2017 Cloudbase Solutions SRL
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as
  5. published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Affero General Public License for more details.
  11. You should have received a copy of the GNU Affero General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. // @flow
  15. import React from 'react'
  16. import { observer } from 'mobx-react'
  17. import styled from 'styled-components'
  18. import Logo from '../../atoms/Logo'
  19. import userStore from '../../../stores/UserStore'
  20. import { navigationMenu } from '../../../config'
  21. import backgroundImage from './images/star-bg.jpg'
  22. const Wrapper = styled.div`
  23. background-image: url('${backgroundImage}');
  24. display: flex;
  25. flex-direction: column;
  26. height: 100%;
  27. `
  28. const LogoStyled = styled(Logo) `
  29. margin: 40px auto 0 30px;
  30. cursor: pointer;
  31. `
  32. const Menu = styled.div`
  33. display: flex;
  34. flex-direction: column;
  35. margin-top:32px;
  36. `
  37. const MenuItem = styled.a`
  38. font-size: 18px;
  39. color: ${props => props.selected ? '#007AFF' : 'white'};
  40. cursor: pointer;
  41. margin-top: 26px;
  42. margin-left: 96px;
  43. display: inline-block;
  44. text-decoration: none;
  45. `
  46. const Footer = styled.div``
  47. @observer
  48. class Navigation extends React.Component<{ currentPage: string }> {
  49. renderMenu() {
  50. const isAdmin = userStore.loggedUser ? userStore.loggedUser.isAdmin : false
  51. return (
  52. <Menu>
  53. {navigationMenu.filter(i => i.disabled ? !i.disabled : i.requiresAdmin ? isAdmin : true).map(item => {
  54. return (
  55. <MenuItem
  56. key={item.value}
  57. selected={this.props.currentPage === item.value}
  58. href={`/#/${item.value}`}
  59. data-test-id={`navigation-item-${item.value}`}
  60. >{item.label}</MenuItem>
  61. )
  62. })}
  63. </Menu>
  64. )
  65. }
  66. render() {
  67. return (
  68. <Wrapper>
  69. <LogoStyled small href={navigationMenu[0].value} />
  70. {this.renderMenu()}
  71. <Footer />
  72. </Wrapper>
  73. )
  74. }
  75. }
  76. export default Navigation