<commit_before>/*
 * Created by whincwu on 2017/10/28
 */
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import {isFunction} from '../utils'

export default class XConsoleView extends Component {
  static propTypes = {
    plugins: PropTypes.arrayOf(PropTypes.object),
    onClose: PropTypes.func
  }

  static defaultProps = {
    plugins: [],
    onClose: () => {}
  }

  constructor (props) {
    super(props)
    const plugins = props.plugins
    this.state = {
      // actived plugin id
      value: plugins.length > 0 ? plugins[0].id : undefined
    }
    this.cachedPluginViews = {}

    // bind methods used in JSX
    this.changeTab = this.changeTab.bind(this)
  }

  componentDidMount () {
    const plugins = this.props.plugins
    this.changeTab(plugins[0] ? plugins[0].id : '')
  }

  changeTab (newValue, oldValue) {
    const plugins = this.props.plugins
    // trigger 'hide' event of disactived plugin before rerender
    const disactivedPlugin = plugins.find(plugin => plugin.id === oldValue)
    if (disactivedPlugin && isFunction(disactivedPlugin.onHide)) {
      disactivedPlugin.onHide()
    }
    // trigger 'show' event of actived plugin before rerender
    const activedPlugin = plugins.find(plugin => plugin.id === newValue)
    if (activedPlugin && isFunction(activedPlugin.onShow)) {<commit_msg>refactor(XConsoleView): remove unused code<commit_after>/*
 * Created by whincwu on 2017/10/28
 */
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import {isFunction} from '../utils'

export default class XConsoleView extends Component {
  static propTypes = {
    plugins: PropTypes.arrayOf(PropTypes.object),
    onClose: PropTypes.func
  }

  static defaultProps = {
    plugins: [],
    onClose: () => {}
  }

  constructor (props) {
    super(props)
    const plugins = props.plugins
    this.state = {
      // actived plugin id
      value: plugins.length > 0 ? plugins[0].id : undefined
    }

    // bind methods used in JSX
    this.changeTab = this.changeTab.bind(this)
  }

  componentDidMount () {
    const plugins = this.props.plugins
    this.changeTab(plugins[0] ? plugins[0].id : '')
  }

  changeTab (newValue, oldValue) {
    const plugins = this.props.plugins
    // trigger 'hide' event of disactived plugin before rerender
    const disactivedPlugin = plugins.find(plugin => plugin.id === oldValue)
    if (disactivedPlugin && isFunction(disactivedPlugin.onHide)) {
      disactivedPlugin.onHide()
    }
    // trigger 'show' event of actived plugin before rerender
    const activedPlugin = plugins.find(plugin => plugin.id === newValue)
    if (activedPlugin && isFunction(activedPlugin.onShow)) {
{'fraction_non_alphanumeric': 0.11745090774360874, 'fraction_numerical': 0.00889218228973694, 'mean_word_length': 3.2586750788643535, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '1746910', 'n_tokens_mistral': 827, 'n_tokens_neox': 802, 'n_words': 208}