<commit_before>import React from 'react';
import Relay from 'react-relay';
import SidebarLayout from 'layouts/SidebarLayout';
import VocabularyView from './VocabularyView';
import CastVoteMutation from 'mutations/CastVoteMutation';
import NovelSelect from 'containers/NovelSelect';
import Novel from 'containers/Novel';
import { Paper } from 'material-ui';


class ContributeView extends React.Component {
    static propTypes = {
      relay: React.PropTypes.object.isRequired,
      history: React.PropTypes.object.isRequired,
      contributor: React.PropTypes.object.isRequired,
      viewer: React.PropTypes.object.isRequired,
      children: React.PropTypes.element.isRequired
    };

    constructor(props) {
      super(props);
      this.state = {
        voteText: ''
      };
    }

    _handleTextInputSave = (token) => {
      const chapter = this.props.viewer.novel.chapter;
      Relay.Store.update(
        new CastVoteMutation({
          tokenId: token.id,
          chapterId: chapter.id,
          ordinal: chapter.tokens.totalCount,
          viewer: this.props.contributor
        })
      );
    }

    _handleNovelChange = (novelId) => {
      const novel = this.props.viewer.novels.edges.filter(edge => edge.node.id === novelId)[0].node;
      const chapterId = novel.latestChapter.id;
      const novelContributeUrl = `/contribute/novel/${novelId}/chapter/${chapterId}`;
      this.props.history.replaceState({'allowContribute': true}, novelContributeUrl);
    }

    _handleVoteChange = (voteText) => {
      this.setState({voteText});
    }

    _handleVoteCast = () => {

    }

    renderNotebook() {
      const { viewer, history } = this.props;
      return (
        <Paper>
          <NovelSelect
            currentNovelId={viewer.novel.id}
            novels={viewer.novels}
            onChange={this._handleNovelChange}
            />
          <Novel novel={viewer.novel} history={history}>
            {this.props.children && React.cloneElement(this.props.children, {
              onVoteChange: this._handleVoteChange
            })}
          </Novel>
        </Paper>
      );
    }

    renderVocabularyView() {
      return (
        <VocabularyView
          voteText={this.state.voteText}
          chapter={this.props.viewer.novel.latestChapter} />
      );
    }

    render () {
      return (
        <SidebarLayout
          content={this.renderNotebook()}
          sidebar={this.renderVocabularyView()}
          /><commit_msg>styling novel select area -> toolbar<commit_after>import React from 'react';
import Relay from 'react-relay';
import SidebarLayout from 'layouts/SidebarLayout';
import VocabularyView from './VocabularyView';
import CastVoteMutation from 'mutations/CastVoteMutation';
import NovelSelect from 'containers/NovelSelect';
import Novel from 'containers/Novel';
import { Paper, FontIcon, Toolbar, ToolbarGroup } from 'material-ui';
import Colors from 'material-ui/lib/styles/colors';

class ContributeView extends React.Component {
    static propTypes = {
      relay: React.PropTypes.object.isRequired,
      history: React.PropTypes.object.isRequired,
      contributor: React.PropTypes.object.isRequired,
      viewer: React.PropTypes.object.isRequired,
      children: React.PropTypes.element.isRequired
    };

    constructor(props) {
      super(props);
      this.state = {
        voteText: ''
      };
    }

    _handleTextInputSave = (token) => {
      const chapter = this.props.viewer.novel.chapter;
      Relay.Store.update(
        new CastVoteMutation({
          tokenId: token.id,
          chapterId: chapter.id,
          ordinal: chapter.tokens.totalCount,
          viewer: this.props.contributor
        })
      );
    }

    _handleNovelChange = (novelId) => {
      const novel = this.props.viewer.novels.edges.filter(edge => edge.node.id === novelId)[0].node;
      const chapterId = novel.latestChapter.id;
      const novelContributeUrl = `/contribute/novel/${novelId}/chapter/${chapterId}`;
      this.props.history.replaceState({'allowContribute': true}, novelContributeUrl);
    }

    _handleVoteChange = (voteText) => {
      this.setState({voteText});
    }

    _handleVoteCast = () => {

    }

    renderNotebook() {
      const { viewer, history } = this.props;
      return (
        <Paper>
          <Toolbar>
            <ToolbarGroup key={0} float="left">
              <FontIcon className="material-icons" hoverColor={Colors.red700} color={Colors.red900}>book</FontIcon>
              <NovelSelect
                currentNovelId={viewer.novel.id}
                novels={viewer.novels}
                onChange={this._handleNovelChange}
                />
            </ToolbarGroup>
          </Toolbar>
          <Novel novel={viewer.novel} history={history}>
            {this.props.children && React.cloneElement(this.props.children, {
              onVoteChange: this._handleVoteChange
            })}
          </Novel>
        </Paper>
      );
    }

    renderVocabularyView() {
      return (
        <VocabularyView
          voteText={this.state.voteText}
          chapter={this.props.viewer.novel.latestChapter} />
      );
    }

    render () {
      return (
        <SidebarLayout
          content={this.renderNotebook()}
          sidebar={this.renderVocabularyView()}
          />
{'fraction_non_alphanumeric': 0.12006764374295378, 'fraction_numerical': 0.0016910935738444193, 'mean_word_length': 2.396936821952776, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 34, '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': '2240941', 'n_tokens_mistral': 1605, 'n_tokens_neox': 1567, 'n_words': 257}