<commit_before>import React, { PropTypes } from 'react';
import moment from 'moment';

import APINotLoaded from 'es6!display/not_loaded';
import SectionHeader from 'es6!display/section_header';
import { Error } from 'es6!display/errors';
import { Grid } from 'es6!display/grid';
import { TimeText } from 'es6!display/time';

import * as api from 'es6!server/api';

import custom_content_hook from 'es6!utils/custom_content';
import { email_head } from 'es6!utils/utils';

var cx = React.addons.classSet;

var ChangesPage = React.createClass({

  propTypes: {
    // should we automatically add padding to the page content?
    bodyPadding: PropTypes.bool,
    // the first time you render the page with this set to true,
    // we record the time and show a widget with perf info in the header
    // TODO: handle transitions for a single-page app..
    isPageLoaded: PropTypes.bool,
    // If you're on a page linked to in the top bar, highlight it
    highlight: PropTypes.string,
    // we have to use position: fixed for some pages
    fixed: PropTypes.bool,
  },


  getInitialState: function() {
    return {
      adminMessage: null,
    }
  },

  getDefaultProps: function() {
    return {
      bodyPadding: true,
      isPageLoaded: true,
      fixed: false
    };
  },

  componentDidMount: function() {
    var messageEndpoint = '/api/0/messages/';
    api.fetch(this, {
      adminMessage: messageEndpoint,
    });
  },

  render: function() {
    if (!api.isLoaded(this.state.adminMessage)) {
      return <APINotLoaded state={this.state.adminMessage} />;
    }

    var message_markup = null;

    var message_data = this.state.adminMessage.getReturnedData();
    if (message_data && message_data.message) {
      var message_markup = <div className="persistentMessageHeader">
        {message_data.message}{"  - "}{message_data.user.email}
      </div>;
    }

    if (this.props.isPageLoaded) {
      // NOTE: once browsers support it, we could start using
      // window.performance.mark
      window.changesPageLoaded = window.changesPageLoaded ||
        new Date().getTime(); // We want to compare to this window.performance,
                              // so want to use new Date() rather than moment.
    }

    var style = this.props.bodyPadding ? {padding: 20} : {};

    return <div>
      {message_markup}
      <ChangesPageHeader highlight={this.props.highlight} fixed={this.props.fixed} />
      <div style={style}>
        {this.props.children}
      </div>
    </div>;
  }
});

/*
 * The header that shows up at the the top of every page. Decided against
 * using fixed positioning: its not important enough (if it were the primary
 * means of navigation on the page, I'd have used it.)
 */
var ChangesPageHeader = React.createClass({

  propTypes: {
    highlight: PropTypes.string, // see ChangesPage
    fixed: PropTypes.bool
  },

  render: function() {
    var feedback_href = custom_content_hook('feedbackHref');
    var feedback_link = null;
    if (feedback_href) {
      feedback_link = <a className="headerLinkBlock floatR"
        target="_blank"
        href={feedback_href}><commit_msg>Tell people v2 is still alpha/beta<commit_after>import React, { PropTypes } from 'react';
import moment from 'moment';

import APINotLoaded from 'es6!display/not_loaded';
import SectionHeader from 'es6!display/section_header';
import { Error } from 'es6!display/errors';
import { Grid } from 'es6!display/grid';
import { TimeText } from 'es6!display/time';

import * as api from 'es6!server/api';

import custom_content_hook from 'es6!utils/custom_content';
import { email_head } from 'es6!utils/utils';

var cx = React.addons.classSet;

var ChangesPage = React.createClass({

  propTypes: {
    // should we automatically add padding to the page content?
    bodyPadding: PropTypes.bool,
    // the first time you render the page with this set to true,
    // we record the time and show a widget with perf info in the header
    // TODO: handle transitions for a single-page app..
    isPageLoaded: PropTypes.bool,
    // If you're on a page linked to in the top bar, highlight it
    highlight: PropTypes.string,
    // we have to use position: fixed for some pages
    fixed: PropTypes.bool,
  },


  getInitialState: function() {
    return {
      adminMessage: null,
    }
  },

  getDefaultProps: function() {
    return {
      bodyPadding: true,
      isPageLoaded: true,
      fixed: false
    };
  },

  componentDidMount: function() {
    var messageEndpoint = '/api/0/messages/';
    api.fetch(this, {
      adminMessage: messageEndpoint,
    });
  },

  render: function() {
    if (!api.isLoaded(this.state.adminMessage)) {
      return <APINotLoaded state={this.state.adminMessage} />;
    }

    var message_markup = null;

    var message_data = this.state.adminMessage.getReturnedData();
    if (message_data && message_data.message) {
      var message_markup = <div className="persistentMessageHeader">
        {message_data.message}{"  - "}{message_data.user.email}
      </div>;
    }

    if (this.props.isPageLoaded) {
      // NOTE: once browsers support it, we could start using
      // window.performance.mark
      window.changesPageLoaded = window.changesPageLoaded ||
        new Date().getTime(); // We want to compare to this window.performance,
                              // so want to use new Date() rather than moment.
    }

    var style = this.props.bodyPadding ? {padding: 20} : {};

    return <div>
      <div className="persistentMessageHeader">
        You probably came here from clicking a link in Phabricator. This is
        still not quite ready for primetime (I added the Phabricator extension
        a bit early), but you{"'"}re welcome to test and email us feedback
        (we'll add a feedback link to the header soon too.)
      </div>
      {message_markup}
      <ChangesPageHeader highlight={this.props.highlight} fixed={this.props.fixed} />
      <div style={style}>
        {this.props.children}
      </div>
    </div>;
  }
});

/*
 * The header that shows up at the the top of every page. Decided against
 * using fixed positioning: its not important enough (if it were the primary
 * means of navigation on the page, I'd have used it.)
 */
var ChangesPageHeader = React.createClass({

  propTypes: {
    highlight: PropTypes.string, // see ChangesPage
    fixed: PropTypes.bool
  },

  render: function() {
    var feedback_href = custom_content_hook('feedbackHref');
    var feedback_link = null;
    if (feedback_href) {
      feedback_link = <a className="headerLinkBlock floatR"
        target="_blank"
        href={feedback_href}>
{'fraction_non_alphanumeric': 0.10937029225670383, 'fraction_numerical': 0.00346489906598373, 'mean_word_length': 2.975449101796407, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3371610', 'n_tokens_mistral': 1940, 'n_tokens_neox': 1902, 'n_words': 604}