<commit_before>import React from 'react';
import { connect } from 'react-redux';
import { Grid, Row, Col } from 'react-flexbox-grid/lib';
import Title from 'react-title-component';
import { FormattedMessage, FormattedHTMLMessage, injectIntl } from 'react-intl';
import messages from '../../resources/messages';

const API_REQUESTS_UNLIMITED = 0;

const localMessages = {
  admin: { id: 'user.profile.admin', defaultMessage: '<p><b>You are an admin-level user. Don\'t break anything!</b></p>' },
  email: { id: 'user.profile.email', defaultMessage: '<b>Email:</b> {email}' },
  name: { id: 'user.profile.name', defaultMessage: '<b>Name:</b> {name}' },
  apiKey: { id: 'user.profile.apiKey', defaultMessage: '<b>API Key:</b> {apiKey} (<i>dont\'t give this out to anyone else</i>)' },
  apiRequests: { id: 'user.profile.apiRequests', defaultMessage: '<b>API Weekly Requests:</b> {requested} / {allowed}' },
  apiRequestedItems: { id: 'user.profile.apiRequestedItems', defaultMessage: '<b>API Weekly Requested Items:</b> {requested} / {allowed}' },
};

const UserProfileContainer = (props) => {
  const { profile, apiKey } = props;
  const { formatMessage } = props.intl;
  const titleHandler = parentTitle => `${formatMessage(messages.userProfile)} | ${parentTitle}`;
  const adminContent = (profile.auth_roles.includes('admin')) ? <FormattedHTMLMessage {...localMessages.admin} /> : null;
  return (
    <Grid>
      <Title render={titleHandler} />
      <Row>
        <Col lg={12}>
          <h1><FormattedMessage {...messages.userProfile} /></h1>
        </Col>
      </Row>
      <Row>
        <Col lg={12}>
          {adminContent}
          <ul>
            <li><FormattedHTMLMessage {...localMessages.email} values={{ email: profile.email }} /></li>
            <li><FormattedHTMLMessage {...localMessages.name} values={{ name: profile.full_name }} /></li>
            <li><FormattedHTMLMessage {...localMessages.apiKey} values={{ apiKey }} /></li>
            <li><FormattedHTMLMessage
              {...localMessages.apiRequests}
              values={{
                requested: profile.weekly_requests_sum,
                allowed: (profile.weekly_requests_limit === API_REQUESTS_UNLIMITED) ? formatMessage(messages.unlimited) : profile.weekly_requests_limit,
              }}
            /></li>
            <li><FormattedHTMLMessage
              {...localMessages.apiRequestedItems}
              values={{
                requested: profile.weekly_requested_items_sum,
                allowed: (profile.weekly_requested_items_limit === API_REQUESTS_UNLIMITED) ? formatMessage(messages.unlimited) : profile.weekly_requests_limit,
              }}
            /></li>
          </ul>
        </Col>
      </Row>
    </Grid>
  );
};

UserProfileContainer.propTypes = {
  // from state
  profile: React.PropTypes.object,
  apiKey: React.PropTypes.string,
  // from compositional chain
  intl: React.PropTypes.object.isRequired,
};

const mapStateToProps = state => ({
  profile: state.user.profile,
  apiKey: state.user.key,
});

export default
  injectIntl(<commit_msg>remove ip-restricted token from profile page - its not your key! (#331)<commit_after>import React from 'react';
import { connect } from 'react-redux';
import { Grid, Row, Col } from 'react-flexbox-grid/lib';
import Title from 'react-title-component';
import { FormattedMessage, FormattedHTMLMessage, injectIntl } from 'react-intl';
import messages from '../../resources/messages';

const API_REQUESTS_UNLIMITED = 0;

const localMessages = {
  admin: { id: 'user.profile.admin', defaultMessage: '<p><b>You are an admin-level user. Don\'t break anything!</b></p>' },
  email: { id: 'user.profile.email', defaultMessage: '<b>Email:</b> {email}' },
  name: { id: 'user.profile.name', defaultMessage: '<b>Name:</b> {name}' },
  apiRequests: { id: 'user.profile.apiRequests', defaultMessage: '<b>API Weekly Requests:</b> {requested} / {allowed}' },
  apiRequestedItems: { id: 'user.profile.apiRequestedItems', defaultMessage: '<b>API Weekly Requested Items:</b> {requested} / {allowed}' },
};

const UserProfileContainer = (props) => {
  const { profile } = props;
  const { formatMessage } = props.intl;
  const titleHandler = parentTitle => `${formatMessage(messages.userProfile)} | ${parentTitle}`;
  const adminContent = (profile.auth_roles.includes('admin')) ? <FormattedHTMLMessage {...localMessages.admin} /> : null;
  return (
    <Grid>
      <Title render={titleHandler} />
      <Row>
        <Col lg={12}>
          <h1><FormattedMessage {...messages.userProfile} /></h1>
        </Col>
      </Row>
      <Row>
        <Col lg={12}>
          {adminContent}
          <ul>
            <li><FormattedHTMLMessage {...localMessages.email} values={{ email: profile.email }} /></li>
            <li><FormattedHTMLMessage {...localMessages.name} values={{ name: profile.full_name }} /></li>
            <li><FormattedHTMLMessage
              {...localMessages.apiRequests}
              values={{
                requested: profile.weekly_requests_sum,
                allowed: (profile.weekly_requests_limit === API_REQUESTS_UNLIMITED) ? formatMessage(messages.unlimited) : profile.weekly_requests_limit,
              }}
            /></li>
            <li><FormattedHTMLMessage
              {...localMessages.apiRequestedItems}
              values={{
                requested: profile.weekly_requested_items_sum,
                allowed: (profile.weekly_requested_items_limit === API_REQUESTS_UNLIMITED) ? formatMessage(messages.unlimited) : profile.weekly_requests_limit,
              }}
            /></li>
          </ul>
        </Col>
      </Row>
    </Grid>
  );
};

UserProfileContainer.propTypes = {
  // from state
  profile: React.PropTypes.object,
  // from compositional chain
  intl: React.PropTypes.object.isRequired,
};

const mapStateToProps = state => ({
  profile: state.user.profile,
});

export default
  injectIntl(
{'fraction_non_alphanumeric': 0.15561181434599156, 'fraction_numerical': 0.002869198312236287, 'mean_word_length': 3.009472259810555, 'pattern_counts': {'":': 0, '<': 92, '<?xml version=': 0, '>': 98, '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': '2001465', 'n_tokens_mistral': 1786, 'n_tokens_neox': 1775, 'n_words': 371}