<commit_before>/**
* @license AGPL-3.0
* @author aAXEe (https://github.com/aAXEe)
* @author mojoaxel (https://github.com/mojoaxel)
*/
import React, { PropTypes } from 'react'
import { connect } from 'react-redux'
import { FormattedMessage } from 'react-intl'
import { Collapse } from 'react-bootstrap'

import { setLayerVisible } from '../../store/actions'
import { LayerType } from '../../config/chartlayer'
import OsmToggle from '../../components/misc/Toggle'

import LayerProgressBar from './layerProgressBar'

import './featureLayerConfig.scss'

class ConfigList extends React.Component {
  constructor (props) {
    super(props)
    this.currentBaseLayerId = this.currentBaseLayerId.bind(this)
    this.selectBaseLayer = this.selectBaseLayer.bind(this)
  }

  currentBaseLayerId () {
    let id
    this.context.layers.forEach(layer => {
      if (!layer.isBaseLayer) return
      if (this.props.layerVisible[layer.id]) {
        id = layer.id
      }
    }, this)
    return id
  }

  selectBaseLayer (id) {
    let currentBase = this.currentBaseLayerId()
    if (id === currentBase) return  // do not deactivate the current base layer
    if (currentBase) {
      this.props.onChangeLayerVisible(currentBase, false)
    }
    this.props.onChangeLayerVisible(id, true)
  }

  render () {
    return (
      <div>
        <div>
          <FormattedMessage id={'layerlist-baselayer'} />
        </div>
        <ul className='layerList base'>
          {this.context.layers.map(layer => {
            let loadState = this.props.layerLoadState[layer.id] || {loading: 0, loaded: 0}
            let layerVisible = !!this.props.layerVisible[layer.id]
            if (!layer.isBaseLayer) return
            return (
              <li key={'layer_' + layer.id}>
                <LayerProgressBar
                  enabled={layerVisible}
                  loadState={loadState} />
                <OsmToggle
                  checked={layerVisible}
                  label={<FormattedMessage id={layer.nameKey} />}
                  layerId={layer.id}
                  onChange={() => this.selectBaseLayer(layer.id)} />
              </li>
            ) })}
        </ul>
        <div>
          <FormattedMessage id={'layerlist-overlaylayer'} />
        </div><commit_msg>allow additional setup for base layers<commit_after>/**
* @license AGPL-3.0
* @author aAXEe (https://github.com/aAXEe)
* @author mojoaxel (https://github.com/mojoaxel)
*/
import React, { PropTypes } from 'react'
import { connect } from 'react-redux'
import { FormattedMessage } from 'react-intl'
import { Collapse } from 'react-bootstrap'

import { setLayerVisible } from '../../store/actions'
import { LayerType } from '../../config/chartlayer'
import OsmToggle from '../../components/misc/Toggle'

import LayerProgressBar from './layerProgressBar'

import './featureLayerConfig.scss'

class ConfigList extends React.Component {
  constructor (props) {
    super(props)
    this.currentBaseLayerId = this.currentBaseLayerId.bind(this)
    this.selectBaseLayer = this.selectBaseLayer.bind(this)
  }

  currentBaseLayerId () {
    let id
    this.context.layers.forEach(layer => {
      if (!layer.isBaseLayer) return
      if (this.props.layerVisible[layer.id]) {
        id = layer.id
      }
    }, this)
    return id
  }

  selectBaseLayer (id) {
    let currentBase = this.currentBaseLayerId()
    if (id === currentBase) return  // do not deactivate the current base layer
    if (currentBase) {
      this.props.onChangeLayerVisible(currentBase, false)
    }
    this.props.onChangeLayerVisible(id, true)
  }

  render () {
    return (
      <div>
        <div>
          <FormattedMessage id={'layerlist-baselayer'} />
        </div>
        <ul className='layerList base'>
          {this.context.layers.map(layer => {
            let loadState = this.props.layerLoadState[layer.id] || {loading: 0, loaded: 0}
            let layerVisible = !!this.props.layerVisible[layer.id]
            if (!layer.isBaseLayer) return
            return (
              <li key={'layer_' + layer.id}>
                <LayerProgressBar
                  enabled={layerVisible}
                  loadState={loadState} />
                <OsmToggle
                  checked={layerVisible}
                  label={<FormattedMessage id={layer.nameKey} />}
                  layerId={layer.id}
                  onChange={() => this.selectBaseLayer(layer.id)} />
                <Collapse
                  className='additionalSetup'
                  in={layerVisible}
                  unmountOnExit >
                  <div>
                    {layer.additionalSetup}
                  </div>
                </Collapse>
              </li>
            ) })}
        </ul>
        <div>
          <FormattedMessage id={'layerlist-overlaylayer'} />
        </div>
{'fraction_non_alphanumeric': 0.12862468931234466, 'fraction_numerical': 0.0016570008285004142, 'mean_word_length': 2.1074646074646073, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 41, 'https://': 4, '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': '371476', 'n_tokens_mistral': 1405, 'n_tokens_neox': 1376, 'n_words': 282}