<commit_before>const { connect } = require('react-redux')
const React = require('react')
const FilterSuggester = require('../FilterSuggester')
const hookUpStickyNav = require('../hookUpStickyNav')

class NewFilter extends React.Component {
  constructor() {
    super()
    this.state = { valueHasError: false }
  }

  save(event) {
    event.preventDefault()
    const form = event.target
    const query = form.filterValue.value.trim()
    if (query.length < 1) {
      this.setState({ valueHasError: true })
      return
    }
    this.setState({ valueHasError: false })

    let name = form.filterKey.value.trim()
    if (name.length < 1) {
      name = query
    }

    const filter = { name, query }
    this.props.dispatch({ type: 'FILTERS_UPDATE', filter })
    this.props.dispatch({ type: 'FILTERS_SELECT', filter })
    this.props.cancel() // Not really canceled, it will force the task list to show
  }

  cancel(event) {
    event.preventDefault()
    this.props.cancel()
  }

  render() {
    let valueClass = 'input'
    if (this.state.valueHasError) {
      valueClass += ' is-danger'
    }
    return (
      <div>
        <nav className="nav secondary-nav" id="new-filter-top-navigation">
          <div className="nav-left"><commit_msg>Grab tasks for new filters<commit_after>const { connect } = require('react-redux')
const React = require('react')
const HelperActions = require('../../models/HelperActions')
const FilterSuggester = require('../FilterSuggester')
const hookUpStickyNav = require('../hookUpStickyNav')

class NewFilter extends React.Component {
  constructor() {
    super()
    this.state = { valueHasError: false }
  }

  save(event) {
    event.preventDefault()
    const form = event.target
    const query = form.filterValue.value.trim()
    if (query.length < 1) {
      this.setState({ valueHasError: true })
      return
    }
    this.setState({ valueHasError: false })

    let name = form.filterKey.value.trim()
    if (name.length < 1) {
      name = query
    }

    const filter = { name, query }
    this.props.dispatch({ type: 'FILTERS_UPDATE', filter })
    this.props.dispatch({ type: 'FILTERS_SELECT', filter })
    HelperActions.updateTasks(this.props.dispatch, filter)
    this.props.cancel() // Not really canceled, it will force the task list to show
  }

  cancel(event) {
    event.preventDefault()
    this.props.cancel()
  }

  render() {
    let valueClass = 'input'
    if (this.state.valueHasError) {
      valueClass += ' is-danger'
    }
    return (
      <div>
        <nav className="nav secondary-nav" id="new-filter-top-navigation">
          <div className="nav-left">
{'fraction_non_alphanumeric': 0.13636363636363635, 'fraction_numerical': 0.0015151515151515152, 'mean_word_length': 2.9476831091180866, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 9, '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': '511012', 'n_tokens_mistral': 814, 'n_tokens_neox': 798, 'n_words': 188}