diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..1744b88 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,38 @@ +{ + "env": { + "browser": true, + "es6": true, + "node": true + }, + "plugins": [ + "react" + ], + "extends": "eslint:recommended", + "parserOptions": { + "ecmaVersion": 2018, + "sourceType": "module", + "ecmaFeatures": { + "jsx": true + } + }, + "rules": { + "react/jsx-uses-react": "error", + "react/jsx-uses-vars": "error", + "indent": [ + "error", + 4 + ], + "linebreak-style": [ + "error", + "unix" + ], + "quotes": [ + "error", + "single" + ], + "semi": [ + "error", + "always" + ] + } +} diff --git a/.hound.yml b/.hound.yml new file mode 100644 index 0000000..fc4f352 --- /dev/null +++ b/.hound.yml @@ -0,0 +1,8 @@ +fail_on_violations: true + +jshint: + enabled: false + +eslint: + enabled: true + config_file: .eslintrc.json diff --git a/js/CommonComponents.js b/js/CommonComponents.js index ef8c39a..408ab37 100644 --- a/js/CommonComponents.js +++ b/js/CommonComponents.js @@ -10,7 +10,12 @@ import { NavItem, NavLink } from 'reactstrap'; -import React from "react"; + +import { connect } from 'react-redux'; + +import React from 'react'; + +import { logout } from './api'; export function BigImage(props) { return ( @@ -26,6 +31,7 @@ export class TurniereNavigation extends React.Component { super(props); this.toggle = this.toggle.bind(this); + this.state = { collapsed: true }; @@ -68,15 +74,39 @@ function Betabadge() { return (BETA); } -function LoginLogoutButtons() { - return ( - - - - - ); +class InvisibleLoginLogoutButtons extends React.Component { + + render() { + const { isSignedIn, username } = this.props; + + if(isSignedIn) { + return ( + + + + + ); + } else { + return ( + + + + + ); + } + } + } +const mapStateToLoginLogoutButtonProperties = (state) => { + const { isSignedIn, username } = state.userinfo; + return { isSignedIn, username }; +}; + +const LoginLogoutButtons = connect( + mapStateToLoginLogoutButtonProperties +)(InvisibleLoginLogoutButtons); + export function Footer() { return (