<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';
import { autobind } from 'core-decorators';
import { connect } from 'react-redux';
import axios from 'axios';
import API from '../../../API'
import MenuButton from '../../../../../lib/react/components/MenuButton';
import SettingsMenu from './SettingsMenu';
import { withRouter } from 'react-router-dom';
import { logout } from '../../../actions/authActions';
import LoginRefresher from '../../sharedComponents/LoginRefresher';


const mapStateToProps = (state, ownProps) => {
	return {
		refresh: state.auth.tokens.refresh
	}
}

@connect(mapStateToProps)
@withRouter
@autobind
class SecondaryNavigation extends React.Component {
	static propTypes = {
		authenticated: PropTypes.bool
	}

	state = {
		loading: false
	}

	async logout() {
		this.setState({loading: true});

		const config = {
			url: API.api,
			method: 'POST',
			data: {
				variables: { refreshToken: this.props.refresh },
				query: 
				`mutation LogoutUser($refreshToken:String!) { 
					logout(refreshToken:$refreshToken) {
						ok
						failureMessage
					}
				}`
			}
		}

		// Send logout request to server
		let result = await axios(config);
		this.setState({loading: false});
		this.props.dispatch(logout(new Date()));
		
		if (!result.data.data.logout.ok) {
			console.warn(result.data.data.logout.failureMessage);
		}
	}

	setRefreshing(isRefreshing, error) {
		if (this.state.loading !== isRefreshing) {
			this.setState({ loading: isRefreshing });
		}

		if (error) {
			// TODO: maybe - add notification that refresh failed?
			console.warn(error);
		}
	}

	render() {
		if (this.props.authenticated) {
			return (
				<div style={{marginRight: '0.5rem'}}>
					<MenuButton minimal loading={this.state.loading} iconName='cog' menu={
						<SettingsMenu handleLogout={this.logout}/>
					}/>
					<LoginRefresher refreshToken={this.props.refresh} setRefreshing={this.setRefreshing}/>
				</div>
			);
		}
		else return null;
	}
}


export default SecondaryNavigation;<commit_msg>[FIX] Fix admin nav styling<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';
import { autobind } from 'core-decorators';
import { connect } from 'react-redux';
import axios from 'axios';
import API from '../../../API'
import MenuButton from '../../../../../lib/react/components/MenuButton';
import SettingsMenu from './SettingsMenu';
import { withRouter } from 'react-router-dom';
import { logout } from '../../../actions/authActions';
import LoginRefresher from '../../sharedComponents/LoginRefresher';


const mapStateToProps = (state, ownProps) => {
	return {
		refresh: state.auth.tokens.refresh
	}
}

@connect(mapStateToProps)
@withRouter
@autobind
class SecondaryNavigation extends React.Component {
	static propTypes = {
		authenticated: PropTypes.bool
	}

	state = {
		loading: false
	}

	async logout() {
		this.setState({loading: true});

		const config = {
			url: API.api,
			method: 'POST',
			data: {
				variables: { refreshToken: this.props.refresh },
				query: 
				`mutation LogoutUser($refreshToken:String!) { 
					logout(refreshToken:$refreshToken) {
						ok
						failureMessage
					}
				}`
			}
		}

		// Send logout request to server
		let result = await axios(config);
		this.setState({loading: false});
		this.props.dispatch(logout(new Date()));
		
		if (!result.data.data.logout.ok) {
			console.warn(result.data.data.logout.failureMessage);
		}
	}

	setRefreshing(isRefreshing, error) {
		if (this.state.loading !== isRefreshing) {
			this.setState({ loading: isRefreshing });
		}

		if (error) {
			// TODO: maybe - add notification that refresh failed?
			console.warn(error);
		}
	}

	render() {
		if (this.props.authenticated) {
			return (
				<div style={{marginRight: '0.5rem'}}>
					<MenuButton buttonClass='pt-minimal' loading={this.state.loading} iconName='cog' menu={
						<SettingsMenu handleLogout={this.logout}/>
					}/>
					<LoginRefresher refreshToken={this.props.refresh} setRefreshing={this.setRefreshing}/>
				</div>
			);
		}
		else return null;
	}
}


export default SecondaryNavigation;
{'fraction_non_alphanumeric': 0.15113230035756853, 'fraction_numerical': 0.0009535160905840286, 'mean_word_length': 3.492505353319058, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, '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': '6984556', 'n_tokens_mistral': 1543, 'n_tokens_neox': 1342, 'n_words': 297}