<commit_before>import React, { Component } from 'react'
import { Link } from 'react-router'

import { getUser } from '../../fetch/fetch'
import { waitForDataAndSetState, cancelAllPromises } from '../../helpers/components'

import { nav, home, log, account, logout, authentification, avatar } from './Header.scss'

class Header extends Component {
  constructor(props) {
    super(props)
    this.state = {
      errors: [],
    }
  }

  componentWillMount() {
    return waitForDataAndSetState(getUser(), this, 'user')
  }

  componentWillUnmount() {
    return cancelAllPromises(this)
  }

  render() {
    const { user } = this.state
    const loginRedirect = `${process.env.PUBLIC_URL}/publication`
    const isPublication = window.location.pathname.startsWith('/publication')
    const logoutRedirect = isPublication ? process.env.PUBLIC_URL : process.env.PUBLIC_URL + window.location.pathname
    const logInUrl =`https://inspire.data.gouv.fr/dgv/login?redirect=${encodeURIComponent(loginRedirect)}`
    const logoutUrl =`https://inspire.data.gouv.fr/dgv/logout?redirect=${encodeURIComponent(logoutRedirect)}`
    const login = <a className={log} href={logInUrl}>Publier des données</a>

    return (
      <nav className={nav}>
        <a className={home} href='/'>inspire.data.gouv.fr</a>
        {!user ? login : (
          <div className={authentification}>
            <Link to={'/publication'}>
              <div className={account}>
                <img alt='avatar' className={avatar} src={user.avatar} />
                {`${user.first_name} ${user.last_name}`}
              </div>
            </Link>
            <a className={log} href={logoutUrl}><span className={logout}>Déconnexion</span><i className='power icon'></i></a>
          </div>
        )}
      </nav>
    )
  }
}

export default Header<commit_msg>Use router link instead of standard <a/> for home link<commit_after>import React, { Component } from 'react'
import { IndexLink, Link } from 'react-router'

import { getUser } from '../../fetch/fetch'
import { waitForDataAndSetState, cancelAllPromises } from '../../helpers/components'

import styles from './Header.scss'

class Header extends Component {
  constructor(props) {
    super(props)
    this.state = {
      errors: [],
    }
  }

  componentWillMount() {
    return waitForDataAndSetState(getUser(), this, 'user')
  }

  componentWillUnmount() {
    return cancelAllPromises(this)
  }

  render() {
    const { user } = this.state
    const loginRedirect = `${process.env.PUBLIC_URL}/publication`
    const isPublication = window.location.pathname.startsWith('/publication')
    const logoutRedirect = isPublication ? process.env.PUBLIC_URL : process.env.PUBLIC_URL + window.location.pathname
    const logInUrl =`https://inspire.data.gouv.fr/dgv/login?redirect=${encodeURIComponent(loginRedirect)}`
    const logoutUrl =`https://inspire.data.gouv.fr/dgv/logout?redirect=${encodeURIComponent(logoutRedirect)}`
    const login = <a className={styles.log} href={logInUrl}>Publier des données</a>

    return (
      <nav className={styles.nav}>
        <IndexLink to='/' className={styles.home}>inspire.data.gouv.fr</IndexLink>

        {!user ? login : (
          <div className={styles.authentification}>
            <Link to={'/publication'}>
              <div className={styles.account}>
                <img alt='avatar' className={styles.avatar} src={user.avatar} />
                {`${user.first_name} ${user.last_name}`}
              </div>
            </Link>
            <a className={styles.log} href={logoutUrl}><span className={styles.logout}>Déconnexion</span><i className='power icon'></i></a>
          </div>
        )}
      </nav>
    )
  }
}

export default Header
{'fraction_non_alphanumeric': 0.15005359056806003, 'fraction_numerical': 0.0, 'mean_word_length': 3.097694840834248, 'pattern_counts': {'":': 0, '<': 42, '<?xml version=': 0, '>': 42, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '498639', 'n_tokens_mistral': 1165, 'n_tokens_neox': 1155, 'n_words': 215}