<commit_before>/* global SETTINGS: false */
import React from 'react';
import { connect } from 'react-redux';
import SplitButton from 'react-bootstrap/lib/SplitButton';
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
import MenuItem from 'react-bootstrap/lib/MenuItem';

class LoginButton extends React.Component {
  static propTypes = {
    dispatch: React.PropTypes.func.isRequired,
    profile:  React.PropTypes.object.isRequired,
  };

  render() {
    const { profile } = this.props;

    // span tags are a workaround for weird indentation with react-bootstrap
    // and React 15. React 15 removed span tags but react-bootstrap still expects
    // them.
    let title = <span>
      {profile.preferred_name || SETTINGS.name}
    </span>;

    return (
      <LinkContainer to={{ pathname: '/dashboard' }} active={false}>
        <SplitButton
          title={title}
          bsStyle="danger"
          id="logout-button">
          <MenuItem
            href="/logout"
            eventKey="logout">
            Logout
          </MenuItem>
        </SplitButton>
      </LinkContainer>
    );
  }
}

const mapStateToProps = (state) => {
  let profile = {
    profile: {}
  };
  if (state.profiles[SETTINGS.username] !== undefined) {
    profile = state.profiles[SETTINGS.username];
  }
  return {
    profile: profile
  };
};<commit_msg>Fixed bug with LoginButton not updating preferred name<commit_after>/* global SETTINGS: false */
import React from 'react';
import { connect } from 'react-redux';
import SplitButton from 'react-bootstrap/lib/SplitButton';
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
import MenuItem from 'react-bootstrap/lib/MenuItem';

class LoginButton extends React.Component {
  static propTypes = {
    dispatch: React.PropTypes.func.isRequired,
    profile:  React.PropTypes.object.isRequired,
  };

  render() {
    const { profile } = this.props;

    // span tags are a workaround for weird indentation with react-bootstrap
    // and React 15. React 15 removed span tags but react-bootstrap still expects
    // them.
    let title = <span>
      {profile.preferred_name || SETTINGS.name}
    </span>;

    return (
      <LinkContainer to={{ pathname: '/dashboard' }} active={false}>
        <SplitButton
          title={title}
          bsStyle="danger"
          id="logout-button">
          <MenuItem
            href="/logout"
            eventKey="logout">
            Logout
          </MenuItem>
        </SplitButton>
      </LinkContainer>
    );
  }
}

const mapStateToProps = (state) => {
  let profile = {};
  if (state.profiles[SETTINGS.username] !== undefined) {
    profile = state.profiles[SETTINGS.username].profile;
  }
  return {
    profile: profile
  };
};
{'fraction_non_alphanumeric': 0.12066473988439307, 'fraction_numerical': 0.002890173410404624, 'mean_word_length': 2.7018716577540105, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 21, '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': '1866792', 'n_tokens_mistral': 799, 'n_tokens_neox': 786, 'n_words': 202}