<commit_before>import page  	  from 'page';
import React 	  from 'react';
import Immutable  from 'immutable';
import classNames from 'classnames';

import Action          from '../actions';
import UserAction      from '../actions/user';
import SettingsAction  from '../actions/settings';
import BroadcastAction from '../actions/broadcast';

import UserStore    from '../stores/user';
import Avatar       from '../components/avatar';
import Dropdown     from '../components/dropdown';
import MemberDialog from '../components/dialog/board-members';

import UserVoice   from '../components/user-voice';
import InfoView    from './dialog/view-info';
import AboutView   from './dialog/view-about';
import ProfileView from './dialog/edit-profile';

import Board from '../models/board';

import ActivityStore from '../stores/user-activity';

import listener    from '../mixins/listener';
import localeMixin from '../mixins/locale';

/**
 *
 */
export default React.createClass({
	mixins: [
		listener(ActivityStore),
		localeMixin()
	],

	propTypes: {
		title: React.PropTypes.string.isRequired,
		showHelp: React.PropTypes.bool,
		killReview: React.PropTypes.func,
		board: (props) => {
			if(!props.board instanceof Board) throw new Error();
		}
	},

	componentDidMount() {
		//this is not good... but what is!
		//get areas like the board component and workspace
		let contentArea = document.getElementById("content");
		contentArea.addEventListener("click", (event) => {
			if(this.state.dropdown) {
				this.toggleDropdown();
				window.UserVoice.push([ 'hide' ]);
			}
		});
	},

	onChange() {
		this.setState({
			members: this.props.board
				? ActivityStore.getMembers(this.props.board.id)
				: Immutable.List()
		});
	},

	getInitialState() {
		return {
			members: this.props.board
				? ActivityStore.getMembers(this.props.board.id)
				: Immutable.List(),
			dropdown: false, localesDropdown: false,
			feedback: false, infoActive: false,
			aboutActive: false, membersActive: false,
			profileActive: false
		}
	},

	showWorkspace() {
		return page.show('/boards');
	},

	toggleMembersDialog() {
		this.setState({ membersActive: !this.state.membersActive });
	},

	toggleDropdown() {
		this.setState({ dropdown: !this.state.dropdown });
		if(this.state.localesDropdown) {
			this.setState({ dropdown: !this.state.dropdown});
		}
	},

	toggleInfoView() {
		this.setState({ infoActive: !this.state.infoActive });
	},

	toggleAboutView() {
		this.setState({ aboutActive: !this.state.aboutActive });
	},

	toggleLocaleDropdown() {
		this.setState({ localesDropdown: !this.state.localesDropdown });
	},

	toggleProfileView() {
		this.setState({ profileActive: !this.state.profileActive });
	},

	boardMembersAmount() {
		if(!this.props.board) return null;

		return this.state.members.filter((member) => {
			return member.get('date') > new Date(new Date().getTime() - (5 * 60000));
		}).size;
   },

	render() {
		let infoDialog = null;
		let aboutDialog = null;
		let profileDialog = null;
		let infoIcon = null;

		if(!this.state.infoActive) {
			infoIcon = 'question';
			infoDialog = null;
		} else {
			infoIcon = 'times';
			infoDialog = <InfoView onDismiss = { this.toggleInfoView }  board={this.props.board}/>;
		}

		if(!this.state.aboutActive) {
			aboutDialog = null;
		} else {
			aboutDialog = <AboutView onDismiss = { this.toggleAboutView } />;
		}

		if(!this.state.profileActive) {
			profileDialog = null;
		} else {
			profileDialog = <ProfileView formProfile="profileSettings" onDismiss = { this.toggleProfileView } />;
		}

		let infoButtonClass =
			classNames(
				'infobutton',
				{ active: this.state.infoActive }
			);

		let userButtonClass =
			classNames(
				'avatar-wrapper',
				{ active: this.state.dropdown }
			);

		let membersButtonClass =
			classNames(
				'members',
				{ active: this.state.membersActive }
			);

		let boardMembersDialog = null;

		if (this.state.membersActive) {
			boardMembersDialog = <MemberDialog members={this.state.members} onDismiss={this.toggleMembersDialog}/>
		}

		let showBoardMembers = !this.props.showBoardMembers ? null : (
			<div id="members" onClick={this.toggleMembersDialog} className={membersButtonClass}>
				<span className="fa fa-fw fa-users">
					<span className="user-amount">
						{this.boardMembersAmount()}
					</span>
				</span>
			</div>
		);

		let showInfo = !this.props.showHelp ? null : (
			<div id="info" onClick={this.toggleInfoView} className={infoButtonClass}>
				<span className={`fa fa-fw fa-${infoIcon}`}></span>
			</div>
			);

		// If userstore is empty then go back to login
		if(!UserStore.getUser()) {
			page.redirect('/login');
		}

		let isProfileDisabled = UserStore.getUser().type === 'standard';
		let items = [
			{
				disabled: true,
				customclass: 'profile-name',
				content: `${this.locale('DROPDOWN_HELLO')}, ${UserStore.getUser().username}`
			},
			{
				icon: 'user',
				content: this.locale('DROPDOWN_PROFILE'),
				disabled: !isProfileDisabled,
				onClick: () => {
					this.toggleProfileView();
					this.toggleDropdown();
				}
			},
			{
				icon: 'language',
				content: this.locale('DROPDOWN_LOCALE'),
				onClick: () => {
					this.toggleLocaleDropdown()
				}
			},
			{
				icon: 'bullhorn',
				nospan: true,
				content: (
					<UserVoice>
						{this.locale('DROPDOWN_FEEDBACK')}
					</UserVoice>
				)
			},
			{
				icon: 'info',
				content: this.locale('DROPDOWN_ABOUT'),
				onClick: () => {
					this.toggleAboutView();
				}
			},
			{
				icon: 'sign-out',
				content: this.locale('DROPDOWN_LOGOUT'),
				onClick: () => {
					UserAction.logout()
						.catch((err) => {
							BroadcastAction.add(err, Action.User.Logout);
						});
				}
			}
		];
		let locales = [
			{
				flag: 'gb',
				content: 'English',
				onClick: () => {
					SettingsAction.setSetting('locale', 'en');
					this.toggleDropdown();
					this.toggleLocaleDropdown();
				}
			},
			{
				flag: 'fi',
				content: 'Suomi',
				onClick: () => {
					SettingsAction.setSetting('locale', 'fi');
					this.toggleDropdown();
					this.toggleLocaleDropdown();
				}
			},
			{
				flag: 'se',
				content: 'Svenska',
				onClick: () => {
					SettingsAction.setSetting('locale', 'se');
					this.toggleDropdown();
					this.toggleLocaleDropdown();
				}
			},
			{
				flag: 'dk',
				content: 'Dansk',
				onClick: () => {
					SettingsAction.setSetting('locale', 'dk');
					this.toggleDropdown();
					this.toggleLocaleDropdown();
				}
			},
			{
				flag: 'jp',
				content: '日本語',
				onClick: () => {
					SettingsAction.setSetting('locale', 'jp');
					this.toggleDropdown();
					this.toggleLocaleDropdown();
				}
			}
		];

		let user      = UserStore.getUser();
		let name      = user.get('username');
		let avatarURL = user.get('avatar');
		let userType  = user.get('type');

		return (
			<nav id="nav" className="nav">
				<img className="logo" src="/dist/assets/img/logo.svg"
					onClick={this.showWorkspace} />
				<h1 className="title">{this.props.title}</h1>
				{showBoardMembers}
				{showInfo}
				<div id="avatar" onClick={this.toggleDropdown} className={userButtonClass}>
						<Avatar size={30} name={name}
								imageurl={avatarURL}
								isOnline={true}
								usertype={userType}>
						</Avatar>
				</div>
				<Dropdown ref="dropdown" className="options" show={this.state.dropdown} items={items} />
				<Dropdown className="locales" show={this.state.localesDropdown} items={locales} />
				{infoDialog}
				{boardMembersDialog}
				{aboutDialog}
				{profileDialog}
			</nav>
		);
	}
});
<commit_msg>fixed a broken togglefunction<commit_after>import page  	  from 'page';
import React 	  from 'react';
import Immutable  from 'immutable';
import classNames from 'classnames';

import Action          from '../actions';
import UserAction      from '../actions/user';
import SettingsAction  from '../actions/settings';
import BroadcastAction from '../actions/broadcast';

import UserStore    from '../stores/user';
import Avatar       from '../components/avatar';
import Dropdown     from '../components/dropdown';
import MemberDialog from '../components/dialog/board-members';

import UserVoice   from '../components/user-voice';
import InfoView    from './dialog/view-info';
import AboutView   from './dialog/view-about';
import ProfileView from './dialog/edit-profile';

import Board from '../models/board';

import ActivityStore from '../stores/user-activity';

import listener    from '../mixins/listener';
import localeMixin from '../mixins/locale';

/**
 *
 */
export default React.createClass({
	mixins: [
		listener(ActivityStore),
		localeMixin()
	],

	propTypes: {
		title: React.PropTypes.string.isRequired,
		showHelp: React.PropTypes.bool,
		killReview: React.PropTypes.func,
		board: (props) => {
			if(!props.board instanceof Board) throw new Error();
		}
	},

	componentDidMount() {
		//this is not good... but what is!
		//get areas like the board component and workspace
		let contentArea = document.getElementById("content");
		contentArea.addEventListener("click", (event) => {
			if(this.state.dropdown) {
				this.toggleDropdown();
				window.UserVoice.push([ 'hide' ]);
			}
		});
	},

	onChange() {
		this.setState({
			members: this.props.board
				? ActivityStore.getMembers(this.props.board.id)
				: Immutable.List()
		});
	},

	getInitialState() {
		return {
			members: this.props.board
				? ActivityStore.getMembers(this.props.board.id)
				: Immutable.List(),
			dropdown: false, localesDropdown: false,
			feedback: false, infoActive: false,
			aboutActive: false, membersActive: false,
			profileActive: false
		}
	},

	showWorkspace() {
		return page.show('/boards');
	},

	toggleMembersDialog() {
		this.setState({ membersActive: !this.state.membersActive });
	},

	toggleDropdown() {
		this.setState({ dropdown: !this.state.dropdown });
		if(this.state.localesDropdown) this.toggleLocaleDropdown();
	},

	toggleInfoView() {
		this.setState({ infoActive: !this.state.infoActive });
	},

	toggleAboutView() {
		this.setState({ aboutActive: !this.state.aboutActive });
	},

	toggleLocaleDropdown() {
		this.setState({ localesDropdown: !this.state.localesDropdown });
	},

	toggleProfileView() {
		this.setState({ profileActive: !this.state.profileActive });
	},

	boardMembersAmount() {
		if(!this.props.board) return null;

		return this.state.members.filter((member) => {
			return member.get('date') > new Date(new Date().getTime() - (5 * 60000));
		}).size;
   },

	render() {
		let infoDialog = null;
		let aboutDialog = null;
		let profileDialog = null;
		let infoIcon = null;

		if(!this.state.infoActive) {
			infoIcon = 'question';
			infoDialog = null;
		} else {
			infoIcon = 'times';
			infoDialog = <InfoView onDismiss = { this.toggleInfoView }  board={this.props.board}/>;
		}

		if(!this.state.aboutActive) {
			aboutDialog = null;
		} else {
			aboutDialog = <AboutView onDismiss = { this.toggleAboutView } />;
		}

		if(!this.state.profileActive) {
			profileDialog = null;
		} else {
			profileDialog = <ProfileView formProfile="profileSettings" onDismiss = { this.toggleProfileView } />;
		}

		let infoButtonClass =
			classNames(
				'infobutton',
				{ active: this.state.infoActive }
			);

		let userButtonClass =
			classNames(
				'avatar-wrapper',
				{ active: this.state.dropdown }
			);

		let membersButtonClass =
			classNames(
				'members',
				{ active: this.state.membersActive }
			);

		let boardMembersDialog = null;

		if (this.state.membersActive) {
			boardMembersDialog = <MemberDialog members={this.state.members} onDismiss={this.toggleMembersDialog}/>
		}

		let showBoardMembers = !this.props.showBoardMembers ? null : (
			<div id="members" onClick={this.toggleMembersDialog} className={membersButtonClass}>
				<span className="fa fa-fw fa-users">
					<span className="user-amount">
						{this.boardMembersAmount()}
					</span>
				</span>
			</div>
		);

		let showInfo = !this.props.showHelp ? null : (
			<div id="info" onClick={this.toggleInfoView} className={infoButtonClass}>
				<span className={`fa fa-fw fa-${infoIcon}`}></span>
			</div>
			);

		// If userstore is empty then go back to login
		if(!UserStore.getUser()) {
			page.redirect('/login');
		}

		let isProfileDisabled = UserStore.getUser().type === 'standard';
		let items = [
			{
				disabled: true,
				customclass: 'profile-name',
				content: `${this.locale('DROPDOWN_HELLO')}, ${UserStore.getUser().username}`
			},
			{
				icon: 'user',
				content: this.locale('DROPDOWN_PROFILE'),
				disabled: !isProfileDisabled,
				onClick: () => {
					this.toggleProfileView();
					this.toggleDropdown();
				}
			},
			{
				icon: 'language',
				content: this.locale('DROPDOWN_LOCALE'),
				onClick: () => {
					this.toggleLocaleDropdown()
				}
			},
			{
				icon: 'bullhorn',
				nospan: true,
				content: (
					<UserVoice>
						{this.locale('DROPDOWN_FEEDBACK')}
					</UserVoice>
				)
			},
			{
				icon: 'info',
				content: this.locale('DROPDOWN_ABOUT'),
				onClick: () => {
					this.toggleAboutView();
				}
			},
			{
				icon: 'sign-out',
				content: this.locale('DROPDOWN_LOGOUT'),
				onClick: () => {
					UserAction.logout()
						.catch((err) => {
							BroadcastAction.add(err, Action.User.Logout);
						});
				}
			}
		];
		let locales = [
			{
				flag: 'gb',
				content: 'English',
				onClick: () => {
					SettingsAction.setSetting('locale', 'en');
					this.toggleDropdown();
					this.toggleLocaleDropdown();
				}
			},
			{
				flag: 'fi',
				content: 'Suomi',
				onClick: () => {
					SettingsAction.setSetting('locale', 'fi');
					this.toggleDropdown();
					this.toggleLocaleDropdown();
				}
			},
			{
				flag: 'se',
				content: 'Svenska',
				onClick: () => {
					SettingsAction.setSetting('locale', 'se');
					this.toggleDropdown();
					this.toggleLocaleDropdown();
				}
			},
			{
				flag: 'dk',
				content: 'Dansk',
				onClick: () => {
					SettingsAction.setSetting('locale', 'dk');
					this.toggleDropdown();
					this.toggleLocaleDropdown();
				}
			},
			{
				flag: 'jp',
				content: '日本語',
				onClick: () => {
					SettingsAction.setSetting('locale', 'jp');
					this.toggleDropdown();
					this.toggleLocaleDropdown();
				}
			}
		];

		let user      = UserStore.getUser();
		let name      = user.get('username');
		let avatarURL = user.get('avatar');
		let userType  = user.get('type');

		return (
			<nav id="nav" className="nav">
				<img className="logo" src="/dist/assets/img/logo.svg"
					onClick={this.showWorkspace} />
				<h1 className="title">{this.props.title}</h1>
				{showBoardMembers}
				{showInfo}
				<div id="avatar" onClick={this.toggleDropdown} className={userButtonClass}>
						<Avatar size={30} name={name}
								imageurl={avatarURL}
								isOnline={true}
								usertype={userType}>
						</Avatar>
				</div>
				<Dropdown ref="dropdown" className="options" show={this.state.dropdown} items={items} />
				<Dropdown className="locales" show={this.state.localesDropdown} items={locales} />
				{infoDialog}
				{boardMembersDialog}
				{aboutDialog}
				{profileDialog}
			</nav>
		);
	}
});

{'fraction_non_alphanumeric': 0.1608252876603624, 'fraction_numerical': 0.0013225763787858748, 'mean_word_length': 3.183402489626556, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 85, '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': '1993060', 'n_tokens_mistral': 6011, 'n_tokens_neox': 4861, 'n_words': 915}