<commit_before>/** @jsx React.DOM */

App.Components.Header = React.createClass({
  getInitialState: function() {
    return {
      dropDownActive: false
    }
  },

  render: function () {
    return (
      <div className="mod-header">
        <h1 className="title"><a href="/">{I18n.t("header.title")}</a></h1>
        <div className="meta">
          <div className="name">
            {this.renderProfileLink()}
            {this.renderDropDown()}
          </div>
          <App.Components.LanguageSelector />
          <ul className="links">
            <li dangerouslySetInnerHTML={{__html: I18n.t("header.links.help_html") }}></li>
            {this.renderExitLogout()}
          </ul>
        </div>
      </div>
    );
  },

  renderProfileLink: function() {
    var title = I18n.t("header.welcome", { name: App.currentUser.displayName });

    if (!App.currentUser.superUser) {
      return (
        <a href="#" onClick={this.handleToggle}>
          {title}
          {this.renderDropDownIndicator()}
        </a>
      );
    } else {
      return title;
    }
  },

  renderDropDownIndicator: function() {
    if (this.state.dropDownActive) {
      return <i className="fa fa-caret-up" />;
    } else {
      return <i className="fa fa-caret-down" />;
    }
  },

  renderDropDown: function() {
    if (!App.currentUser.superUser && this.state.dropDownActive) {
      return (
        <ul>
          <h2>{I18n.t("header.you")}</h2>
          <ul>
            <li><a href="/profile">{I18n.t("header.profile")}</a></li>
          </ul>
          <App.Components.IDPSelector />
        </ul>
      );
    }
  },

  renderExitLogout: function() {
    if (App.currentUser.superUser && App.currentUser.switchedToIdp) {
      return (
        <li><a href="/exit">{I18n.t("header.links.exit")}</a></li>
      );
    } else {
      return (
        <li><a href="/logout">{I18n.t("header.links.logout")}</a></li>
      );
    }
  },

  handleToggle: function(e) {
    e.preventDefault();
    e.stopPropagation();
    this.setState({dropDownActive: !this.state.dropDownActive});
  }
});<commit_msg>Close menu when navigating to the profile page<commit_after>/** @jsx React.DOM */

App.Components.Header = React.createClass({
  getInitialState: function() {
    return {
      dropDownActive: false
    }
  },

  render: function () {
    return (
      <div className="mod-header">
        <h1 className="title"><a href="/">{I18n.t("header.title")}</a></h1>
        <div className="meta">
          <div className="name">
            {this.renderProfileLink()}
            {this.renderDropDown()}
          </div>
          <App.Components.LanguageSelector />
          <ul className="links">
            <li dangerouslySetInnerHTML={{__html: I18n.t("header.links.help_html") }}></li>
            {this.renderExitLogout()}
          </ul>
        </div>
      </div>
    );
  },

  renderProfileLink: function() {
    var title = I18n.t("header.welcome", { name: App.currentUser.displayName });

    if (!App.currentUser.superUser) {
      return (
        <a href="#" onClick={this.handleToggle}>
          {title}
          {this.renderDropDownIndicator()}
        </a>
      );
    } else {
      return title;
    }
  },

  renderDropDownIndicator: function() {
    if (this.state.dropDownActive) {
      return <i className="fa fa-caret-up" />;
    } else {
      return <i className="fa fa-caret-down" />;
    }
  },

  renderDropDown: function() {
    if (!App.currentUser.superUser && this.state.dropDownActive) {
      return (
        <ul>
          <h2>{I18n.t("header.you")}</h2>
          <ul>
            <li><a href="/profile" onClick={this.handleClose}>{I18n.t("header.profile")}</a></li>
          </ul>
          <App.Components.IDPSelector />
        </ul>
      );
    }
  },

  renderExitLogout: function() {
    if (App.currentUser.superUser && App.currentUser.switchedToIdp) {
      return (
        <li><a href="/exit">{I18n.t("header.links.exit")}</a></li>
      );
    } else {
      return (
        <li><a href="/logout">{I18n.t("header.links.logout")}</a></li>
      );
    }
  },

  handleClose: function() {
    this.setState({dropDownActive: false});
  },

  handleToggle: function(e) {
    e.preventDefault();
    e.stopPropagation();
    this.setState({dropDownActive: !this.state.dropDownActive});
  }
});
{'fraction_non_alphanumeric': 0.1792452830188679, 'fraction_numerical': 0.008283479061205707, 'mean_word_length': 2.1776315789473686, 'pattern_counts': {'":': 0, '<': 79, '<?xml version=': 0, '>': 79, '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': '6345803', 'n_tokens_mistral': 1436, 'n_tokens_neox': 1426, 'n_words': 212}