<commit_before>//import Auth0Variables from './auth0-variables'
import Auth0Lock from 'auth0-lock'
import React, {Component, PropTypes} from 'react'
import StandardDropdownMenu from 'gComponents/utility/standard-dropdown-menu'
import DropDown from 'gComponents/utility/drop-down/index.js'
import {DropDownListElement} from 'gComponents/utility/drop-down/index.js'
import {LinkSettings} from 'gComponents/utility/links/index.js'
import * as meActions from 'gModules/me/actions.js'
import * as modalActions from 'gModules/modal/actions.js'
import * as navigationActions from 'gModules/navigation/actions.js'
import Icon from 'react-fa'
import './style.css'
import {trackAccountModalClick, trackUserMenuOpen, trackUserMenuClose} from 'server/segment/index.js'
import * as spaceActions from 'gModules/spaces/actions.js'
import {user,organization} from 'gEngine/engine'

import {connect} from 'react-redux';


@connect()
export default class Profile extends Component {
  displayName: 'Profile'

  signUp() {
    this.props.dispatch(meActions.signUp())
  }

  signIn() {
    this.props.dispatch(meActions.signIn())
  }

  logOut() {
    this.props.dispatch(meActions.logOut())
  }

  newModel(organizationId) {
    this.props.dispatch(spaceActions.create(organizationId))
  }

  _openModal() {
    trackAccountModalClick()
    this.props.dispatch(modalActions.openSettings())
  }

  profileDropdown() {
    const profile = this.props.me.profile
    const portalUrl = _.get(profile, 'account._links.payment_portal.href')

    let listElements = [
      {ionicIcon: 'md-person', header: 'account', onMouseDown: this._openModal.bind(this)},
      {icon: 'rocket', header: 'upgrade', onMouseDown: () => {navigationActions.navigate('/pricing')}},
      {ionicIcon: 'md-help', header: 'FAQ', onMouseDown: () => {navigationActions.navigate('/faq')}},
      {ionicIcon: 'md-log-out', header: 'Sign Out', onMouseDown: this.logOut.bind(this)}
    ]

    if (!!portalUrl) {
      listElements = [listElements[0], listElements[2], listElements[3]]
    }

    return (
      <div className='item'>
        <DropDown
            headerText={profile.name}
            openLink={<img className='avatar' src={profile.picture}/>}
            onOpen={trackUserMenuOpen}
            onClose={trackUserMenuClose}
            ref='dropdown'
        >
          <ul>
            {listElements.map(props => <DropDownListElement {...props} key={props.icon} closeOnClick={true} dropDown={this.refs.dropdown}/>)}
          </ul>
        </DropDown>
      </div>
    )
  }

  newModelDropdown(organizations) {
    let listElements = [ {header: 'Personal Model', onMouseDown: this.newModel.bind(this)} ]
    if (organizations) {
      listElements = listElements.concat(organizations.map(o => ({header: `${o.name} Model`, onMouseDown: this.newModel.bind(this, o.id)})))
    }

    return (
      <DropDown
        headerText={'Create a Model'}
        openLink={<a className='item'> <i className={`ion-md-add`}/> <span className='text'>New Model</span> </a>}
        ref='newModel'
      >
        <ul>
          {listElements.map(element => <DropDownListElement {...element} key={element.header} closeOnClick={true} dropDown={this.refs.newModel}/>)}
        </ul>
      </DropDown>
    )
  }

  closeDropdown(dropDown) {
    this.refs[dropDown] && this.refs[dropDown]._close()
  }

  organizationsDropdown(organizations) {
    const ref='organizations'<commit_msg>Fixing keys and dropdown closure in new model dropdown.<commit_after>//import Auth0Variables from './auth0-variables'
import Auth0Lock from 'auth0-lock'
import React, {Component, PropTypes} from 'react'
import StandardDropdownMenu from 'gComponents/utility/standard-dropdown-menu'
import DropDown from 'gComponents/utility/drop-down/index.js'
import {DropDownListElement} from 'gComponents/utility/drop-down/index.js'
import {LinkSettings} from 'gComponents/utility/links/index.js'
import * as meActions from 'gModules/me/actions.js'
import * as modalActions from 'gModules/modal/actions.js'
import * as navigationActions from 'gModules/navigation/actions.js'
import Icon from 'react-fa'
import './style.css'
import {trackAccountModalClick, trackUserMenuOpen, trackUserMenuClose} from 'server/segment/index.js'
import * as spaceActions from 'gModules/spaces/actions.js'
import {user,organization} from 'gEngine/engine'

import {connect} from 'react-redux';


@connect()
export default class Profile extends Component {
  displayName: 'Profile'

  signUp() {
    this.props.dispatch(meActions.signUp())
  }

  signIn() {
    this.props.dispatch(meActions.signIn())
  }

  logOut() {
    this.props.dispatch(meActions.logOut())
  }

  newModel(organizationId) {
    this.props.dispatch(spaceActions.create(organizationId))
  }

  _openModal() {
    trackAccountModalClick()
    this.props.dispatch(modalActions.openSettings())
  }

  profileDropdown() {
    const profile = this.props.me.profile
    const portalUrl = _.get(profile, 'account._links.payment_portal.href')

    let listElements = [
      {ionicIcon: 'md-person', header: 'account', onMouseDown: this._openModal.bind(this)},
      {icon: 'rocket', header: 'upgrade', onMouseDown: () => {navigationActions.navigate('/pricing')}},
      {ionicIcon: 'md-help', header: 'FAQ', onMouseDown: () => {navigationActions.navigate('/faq')}},
      {ionicIcon: 'md-log-out', header: 'Sign Out', onMouseDown: this.logOut.bind(this)}
    ]

    if (!!portalUrl) {
      listElements = [listElements[0], listElements[2], listElements[3]]
    }

    return (
      <div className='item'>
        <DropDown
            headerText={profile.name}
            openLink={<img className='avatar' src={profile.picture}/>}
            onOpen={trackUserMenuOpen}
            onClose={trackUserMenuClose}
            ref='dropdown'
        >
          <ul>
            {listElements.map(props => <DropDownListElement {...props} key={props.icon} closeOnClick={true} dropDown={this.refs.dropdown}/>)}
          </ul>
        </DropDown>
      </div>
    )
  }

  closeDropdown(dropDown) {
    this.refs[dropDown] && this.refs[dropDown]._close()
  }

  newModelDropdown(organizations) {
    const ref = 'newModel'
    let listElements = [ {props: {header: 'Personal Model', onMouseDown: ()=>{this.newModel(); this.closeDropdown(ref)}}, id: 0} ]
    if (organizations) {
      listElements = listElements.concat(organizations.map(
        o => (
          {
            props: {
              header: `${o.name} Model`,
              onMouseDown: () => {this.newModel(o.id); this.closeDropdown(ref)}
            },
            id: o.id
          }
        )
      ))
    }

    return (
      <DropDown
        headerText={'Create a Model'}
        openLink={<a className='item'> <i className={`ion-md-add`}/> <span className='text'>New Model</span> </a>}
        ref={ref}
      >
        <ul>
          {listElements.map(element => <DropDownListElement {...element.props} key={element.id}/>)}
        </ul>
      </DropDown>
    )
  }

  organizationsDropdown(organizations) {
    const ref='organizations'
{'fraction_non_alphanumeric': 0.1469381982746429, 'fraction_numerical': 0.0021213406873143827, 'mean_word_length': 3.3952765692977005, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 51, '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': '1191252', 'n_tokens_mistral': 2212, 'n_tokens_neox': 2175, 'n_words': 414}