<commit_before>import React, { Component } from 'react';
import {Nav, Navbar, NavDropdown, MenuItem} from 'react-bootstrap';
import HelpModal from './HelpModal';
import SettingsModal from './SettingsModal';

class ChatDropdownMenu extends Component {
    constructor(props) {
        super(props);
        this.state = {
            username: '<EMAIL>',
            isSettingsModalOpen: false,
            isHelpModalOpen: false
        };
    }

    handleMenuItem = (eventKey, event) => {
        if (eventKey === 'help') {
            this.setState({isHelpModalOpen: true});
        }
        else if (eventKey === 'settings') {
            this.setState({isSettingsModalOpen: true});
        }
    }

    hideModal = (modalType) => {
        if (modalType === 'help') {
            this.setState({isHelpModalOpen: false});
        }
        else if (modalType === 'settings') {
            this.setState({isSettingsModalOpen: false});
        }
    }<commit_msg>Call logout from Chat dropdown menu<commit_after>import React, { Component } from 'react';
import {Nav, Navbar, NavDropdown, MenuItem} from 'react-bootstrap';
import HelpModal from './HelpModal';
import SettingsModal from './SettingsModal';
import * as config from '../../config';

import axios from 'axios';
axios.defaults.withCredentials = true;

class ChatDropdownMenu extends Component {
    constructor(props) {
        super(props);
        this.state = {
            username: '<EMAIL>',
            isSettingsModalOpen: false,
            isHelpModalOpen: false
        };
    }

    static get contextTypes() {
        return {
            router: React.PropTypes.object.isRequired,
        };
    }

    handleMenuItem = (eventKey, event) => {
        if (eventKey === 'help') {
            this.setState({isHelpModalOpen: true});
        }
        else if (eventKey === 'settings') {
            this.setState({isSettingsModalOpen: true});
        }
        else if (eventKey === 'logout') {
            this.logout();
        }
    }

    logout = () => {
        axios.get(config.backendUrl + '/logout')
        .then(res => {
            if (res.status === 200 && res.data === 'Logout OK') {
                this.context.router.history.push('/');
            }
        })
        .catch(error => {
            console.log(error);
        })
    }

    hideModal = (modalType) => {
        if (modalType === 'help') {
            this.setState({isHelpModalOpen: false});
        }
        else if (modalType === 'settings') {
            this.setState({isSettingsModalOpen: false});
        }
    }
{'fraction_non_alphanumeric': 0.1393092743500194, 'fraction_numerical': 0.0011641443538998836, 'mean_word_length': 2.0293772032902466, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, 'https://': 0, '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': '3400081', 'n_tokens_mistral': 712, 'n_tokens_neox': 711, 'n_words': 160}