<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';

// Components
import ModalComponent from 'components/modal/modal-component';
import LoginModal from 'components/modal/LoginModal';

// Actions
// import * as actions from 'redactions/dock';

// Services

class LoginRequired extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      isOpen: false
    };
  }

  promptLogin(event) {
    event.stopPropagation();
    this.setState({ isOpen: true });
  }

  closePrompt() {
    this.setState({ isOpen: false });
  }

  render() {
    const { user } = this.props;
    const { isOpen } = this.state;

    return user.token ? this.props.children : (
      <div className="c-login-required" onClickCapture={e => this.promptLogin(e)}>
        <ModalComponent isOpen={isOpen} onRequestClose={() => this.closePrompt()}>
          <LoginModal onRequestClose={() => this.closePrompt()} {...this.props} />
        </ModalComponent>
        {this.props.children}<commit_msg>use PureComponent for performance (LoginRequired component)<commit_after>import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';

// Components
import ModalComponent from 'components/modal/modal-component';
import LoginModal from 'components/modal/LoginModal';

class LoginRequired extends PureComponent {
  constructor(props) {
    super(props);
    this.state = {
      isOpen: false
    };
  }

  promptLogin(event) {
    event.stopPropagation();
    this.setState({ isOpen: true });
  }

  closePrompt() {
    this.setState({ isOpen: false });
  }

  render() {
    const { user } = this.props;
    const { isOpen } = this.state;

    return user.token ? this.props.children : (
      <div className="c-login-required" onClickCapture={e => this.promptLogin(e)}>
        <ModalComponent isOpen={isOpen} onRequestClose={() => this.closePrompt()}>
          <LoginModal onRequestClose={() => this.closePrompt()} {...this.props} />
        </ModalComponent>
        {this.props.children}
{'fraction_non_alphanumeric': 0.14434453383814483, 'fraction_numerical': 0.0, 'mean_word_length': 3.422594142259414, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, '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': '1659942', 'n_tokens_mistral': 628, 'n_tokens_neox': 624, 'n_words': 138}