<commit_before>import { Button, Callout, Classes, Dialog, FormGroup, InputGroup, Intent } from '@blueprintjs/core'
import { NLU } from 'botpress/sdk'
import _ from 'lodash'
import React, { FC, useEffect, useState } from 'react'

interface Props {
  isOpen: boolean
  toggle: () => void
  onSubmit: (sanitizedName: string, rawName: string) => void
  title: string
  originalName?: string
  intents?: NLU.IntentDefinition[]
}

const sanitizeName = (text: string) =>
  text
    .toLowerCase()
    .replace(/\s|\t|\n/g, '-')
    .replace(/[^a-z0-9-_.]/g, '')

const NameModal: FC<Props> = props => {
  const [name, setName] = useState('')

  useEffect(() => {
    props.originalName ? setName(props.originalName) : setName('')
  }, [props.isOpen])

  const submit = async e => {
    e.preventDefault()
    props.onSubmit(sanitizeName(name), name)
    closeModal()
  }

  const closeModal = () => {
    setName('')
    props.toggle()
  }

  const alreadyExists = !!(props.intents || []).find(x => x.name === sanitizeName(name))

  return (
    <Dialog
      isOpen={props.isOpen}
      onClose={closeModal}
      transitionDuration={0}
      icon="add"
      title={<span style={{ textTransform: 'capitalize' }}>{props.title}</span>}
    >
      <form onSubmit={submit}>
        <div className={Classes.DIALOG_BODY}>
          <FormGroup label="Intent Name">
            <InputGroup
              id="input-name"<commit_msg>fixed e2e test<commit_after>import { Button, Callout, Classes, Dialog, FormGroup, InputGroup, Intent } from '@blueprintjs/core'
import { NLU } from 'botpress/sdk'
import _ from 'lodash'
import React, { FC, useEffect, useState } from 'react'

interface Props {
  isOpen: boolean
  toggle: () => void
  onSubmit: (sanitizedName: string, rawName: string) => void
  title: string
  originalName?: string
  intents?: NLU.IntentDefinition[]
}

const sanitizeName = (text: string) =>
  text
    .replace(/\s|\t|\n/g, '-')
    .toLowerCase()
    .replace(/[^a-z0-9-_.]/g, '')

const NameModal: FC<Props> = props => {
  const [name, setName] = useState('')

  useEffect(() => {
    props.originalName ? setName(props.originalName) : setName('')
  }, [props.isOpen])

  const submit = async e => {
    e.preventDefault()
    props.onSubmit(sanitizeName(name), name)
    closeModal()
  }

  const closeModal = () => {
    setName('')
    props.toggle()
  }

  const alreadyExists = !!(props.intents || []).find(x => x.name === sanitizeName(name))

  return (
    <Dialog
      isOpen={props.isOpen}
      onClose={closeModal}
      transitionDuration={0}
      icon="add"
      title={<span style={{ textTransform: 'capitalize' }}>{props.title}</span>}
    >
      <form onSubmit={submit}>
        <div className={Classes.DIALOG_BODY}>
          <FormGroup label="Intent Name">
            <InputGroup
              id="input-intent-name"
{'fraction_non_alphanumeric': 0.16549543218552354, 'fraction_numerical': 0.002459592410400562, 'mean_word_length': 3.2115384615384617, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 33, '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': '7143174', 'n_tokens_mistral': 943, 'n_tokens_neox': 934, 'n_words': 203}