<commit_before>// @flow

import React, {Component} from 'react'
import {Alert, Checkbox, Form, FormControl, ControlLabel} from 'react-bootstrap'
import Rcslider from 'rc-slider'

import {updateEditSetting} from '../../actions/active'
import {CLICK_OPTIONS} from '../../util'
import toSentenceCase from '../../../common/util/to-sentence-case'
import type {EditSettingsState} from '../../../types/reducers'

type Props = {
  editSettings: EditSettingsState,
  patternSegment: number,
  updateEditSetting: typeof updateEditSetting
}

type State = {
  open: boolean
}

const STOP_INTERVALS = {
  '100': '100m',
  '400': <strong>400m</strong>,
  '800': '800m',
  '1600': '1600m'
}

export default class EditSettings extends Component<Props, State> {
  state = {
    open: false
  }

  _formatSliderTip = (value: number) =>
    `${value}m (${Math.round(value * 0.000621371 * 100) / 100}mi)`

  _onCheckboxChange = (evt: SyntheticInputEvent<HTMLInputElement>) =>
    this.props.updateEditSetting({
      setting: evt.target.name,
      value: evt.target.checked
    })

  _onClickEdit = () => this.setState({open: !this.state.open})

  _onSelectChange = (evt: SyntheticInputEvent<HTMLInputElement>) =>
    this.props.updateEditSetting({
      setting: evt.target.name,
      value: evt.target.value
    })

  _onSliderChange = (value: number) =>
    this.props.updateEditSetting({
      setting: 'stopInterval',
      value
    })

  render () {
    // Edit Settings passed in are present
    const {editSettings, patternSegment, updateEditSetting} = this.props
    const {
      editGeometry,
      followStreets,
      onMapClick,
      stopInterval
    } = editSettings
    const SETTINGS = [
      {type: 'followStreets', label: 'Snap to streets'},
      {type: 'avoidMotorways', label: 'Avoid motorways in routing'},
      {type: 'hideStopHandles', label: 'Hide stop handles'},
      {type: 'hideInactiveSegments', label: 'Hide inactive segments'},
      {type: 'showStops', label: 'Show stops'},
      {type: 'showTooltips', label: 'Show tooltips'}
    ]
    if (!editGeometry) return null
    const noSegmentIsActive = !patternSegment && patternSegment !== 0
    return (
      <div>
        {SETTINGS.map((s, i) => (
          <Checkbox
            checked={editSettings[s.type]}
            key={s.type}<commit_msg>refactor(EditSettings): Change "motorway" to "highway" in checkbox desc.<commit_after>// @flow

import React, {Component} from 'react'
import {Alert, Checkbox, Form, FormControl, ControlLabel} from 'react-bootstrap'
import Rcslider from 'rc-slider'

import {updateEditSetting} from '../../actions/active'
import {CLICK_OPTIONS} from '../../util'
import toSentenceCase from '../../../common/util/to-sentence-case'
import type {EditSettingsState} from '../../../types/reducers'

type Props = {
  editSettings: EditSettingsState,
  patternSegment: number,
  updateEditSetting: typeof updateEditSetting
}

type State = {
  open: boolean
}

const STOP_INTERVALS = {
  '100': '100m',
  '400': <strong>400m</strong>,
  '800': '800m',
  '1600': '1600m'
}

export default class EditSettings extends Component<Props, State> {
  state = {
    open: false
  }

  _formatSliderTip = (value: number) =>
    `${value}m (${Math.round(value * 0.000621371 * 100) / 100}mi)`

  _onCheckboxChange = (evt: SyntheticInputEvent<HTMLInputElement>) =>
    this.props.updateEditSetting({
      setting: evt.target.name,
      value: evt.target.checked
    })

  _onClickEdit = () => this.setState({open: !this.state.open})

  _onSelectChange = (evt: SyntheticInputEvent<HTMLInputElement>) =>
    this.props.updateEditSetting({
      setting: evt.target.name,
      value: evt.target.value
    })

  _onSliderChange = (value: number) =>
    this.props.updateEditSetting({
      setting: 'stopInterval',
      value
    })

  render () {
    // Edit Settings passed in are present
    const {editSettings, patternSegment, updateEditSetting} = this.props
    const {
      editGeometry,
      followStreets,
      onMapClick,
      stopInterval
    } = editSettings
    const SETTINGS = [
      {type: 'followStreets', label: 'Snap to streets'},
      {type: 'avoidMotorways', label: 'Avoid highways in routing'},
      {type: 'hideStopHandles', label: 'Hide stop handles'},
      {type: 'hideInactiveSegments', label: 'Hide inactive segments'},
      {type: 'showStops', label: 'Show stops'},
      {type: 'showTooltips', label: 'Show tooltips'}
    ]
    if (!editGeometry) return null
    const noSegmentIsActive = !patternSegment && patternSegment !== 0
    return (
      <div>
        {SETTINGS.map((s, i) => (
          <Checkbox
            checked={editSettings[s.type]}
            key={s.type}
{'fraction_non_alphanumeric': 0.14194373401534527, 'fraction_numerical': 0.018329070758738276, 'mean_word_length': 3.293687099725526, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 27, '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': '5891272', 'n_tokens_mistral': 1535, 'n_tokens_neox': 1468, 'n_words': 354}