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

import _ from 'lodash'

import ContentWrapper from '~/components/Layout/ContentWrapper'
import PageHeader from '~/components/Layout/PageHeader'

import InjectedModuleView from '~/components/PluginInjectionSite/module'

class ModuleView extends React.Component {
  static contextTypes = {
    router: PropTypes.object.isRequired
  }

  shouldComponentUpdate(nextProps) {
    return JSON.stringify(nextProps) !== JSON.stringify(this.props)
  }

  renderLink(module) {
    if (!module || !module.homepage) {
      return null
    }
    return (
      <small>
        {' '}
        &middot;{' '}
        <a target="_blank" href={module.homepage}>
          docs
        </a>
      </small>
    )
  }

  renderNotFound(err) {
    return (
      <div className="panel panel-warning">
        <div className="panel-heading">Module not found</div>
        <div className="panel-body">
          <h4>The module is not properly registered</h4>
          <p>
            It seems like you are trying to load a module that has not been registered. Please make sure the module is
            registered then restart the bot.
          </p>
          {err && <p>{err}</p>}
          <p>
            {/* TODO update doc & help */}
            <a role="button" className="btn btn-primary btn-lg">
              Learn more
            </a>
          </p>
        </div>
      </div>
    )
  }

  render() {
    const modules = this.props.modules
    if (!modules) {
      return null
    }

    const { moduleName, subView } = this.props.match.params
    const module = _.find(modules, { name: moduleName })

    const contents = module ? (
      <InjectedModuleView moduleName={moduleName} viewName={subView} onNotFound={this.renderNotFound} />
    ) : (
      this.renderNotFound()
    )

    const header = module ? (
      <span>
        {module && module.menuText} {this.renderLink(module)}
      </span>
    ) : (
      `Module ${moduleName} Not Found`
    )

    const stretch = _.get(module, 'moduleView.stretched')

    return (
      <ContentWrapper stretch={stretch}>
        <PageHeader>{header}</PageHeader>
        {contents}
      </ContentWrapper><commit_msg>removed 'docs' link in top header<commit_after>import React from 'react'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'

import _ from 'lodash'

import ContentWrapper from '~/components/Layout/ContentWrapper'
import PageHeader from '~/components/Layout/PageHeader'

import InjectedModuleView from '~/components/PluginInjectionSite/module'

class ModuleView extends React.Component {
  static contextTypes = {
    router: PropTypes.object.isRequired
  }

  shouldComponentUpdate(nextProps) {
    return JSON.stringify(nextProps) !== JSON.stringify(this.props)
  }

  renderNotFound(err) {
    return (
      <div className="panel panel-warning">
        <div className="panel-heading">Module not found</div>
        <div className="panel-body">
          <h4>The module is not properly registered</h4>
          <p>
            It seems like you are trying to load a module that has not been registered. Please make sure the module is
            registered then restart the bot.
          </p>
          {err && <p>{err}</p>}
          <p>
            {/* TODO update doc & help */}
            <a role="button" className="btn btn-primary btn-lg">
              Learn more
            </a>
          </p>
        </div>
      </div>
    )
  }

  render() {
    const modules = this.props.modules
    if (!modules) {
      return null
    }

    const { moduleName, subView } = this.props.match.params
    const module = _.find(modules, { name: moduleName })

    const contents = module ? (
      <InjectedModuleView moduleName={moduleName} viewName={subView} onNotFound={this.renderNotFound} />
    ) : (
      this.renderNotFound()
    )

    const header = module ? <span>{module && module.menuText}</span> : `Module ${moduleName} Not Found`

    const stretch = _.get(module, 'moduleView.stretched')

    return (
      <ContentWrapper stretch={stretch}>
        <PageHeader>{header}</PageHeader>
        {contents}
      </ContentWrapper>
{'fraction_non_alphanumeric': 0.12046204620462046, 'fraction_numerical': 0.000942951438000943, 'mean_word_length': 2.4384116693679094, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 53, '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': '6533099', 'n_tokens_mistral': 1215, 'n_tokens_neox': 1191, 'n_words': 314}