<commit_before>React = require 'react'
R = require 'ramda'
S = require('string')
ReactBootstrap = require 'react-bootstrap'
{Modal, Button, ButtonToolbar} = ReactBootstrap

module.exports = React.createClass

  mapOption: (description, optionKey)->
    humanized = S(optionKey).humanize().s
    clickHandler = R.useWith @selectOption, R.always(optionKey)

    <div className="loadOption">
      <Button bsStyle="default" onClick={clickHandler}>
        {humanized}
      </Button>
      <span className="loadDescription">
        {description}
      </span>
    </div>

  selectOption: (optionKey) ->
    @hideModal()
    @props.onChange(optionKey)

  hideModal: ->
    React.render(<span/>, @refs.loadContainer.getDOMNode())

  showModal: ->
    modalContent =
      <div className="loadOptions">
        {R.mapObjIndexed(@mapOption)(@props.options)}
      </div>
    modalInstance = (
        <div id="loadModal" className="static-modal">
          <Modal title="Load an example"
            bsStyle="primary"
            backdrop={true}
            animation={true}
            container={@refs.loadContainer}
            onRequestHide={@hideModal}>
            <div className="modal-body">
              {modalContent}
            </div>
          </Modal>
        </div>
      )
    React.render(modalInstance, @refs.loadContainer.getDOMNode())

  render: ->
    <span id="loadArea">
      <Button bsStyle="primary" id="loadButton" onClick={@showModal}>
        Load
      </Button>
      <span id="loadContainer" ref="loadContainer"/>
    </span>
<commit_msg>Fix closing loading modal<commit_after>React = require 'react'
R = require 'ramda'
S = require('string')
ReactBootstrap = require 'react-bootstrap'
{Modal, Button, ButtonToolbar} = ReactBootstrap

module.exports = React.createClass

  mapOption: (description, optionKey)->
    humanized = S(optionKey).humanize().s
    clickHandler = R.useWith @selectOption, R.always(optionKey)

    <div className="loadOption">
      <Button bsStyle="default" onClick={clickHandler}>
        {humanized}
      </Button>
      <span className="loadDescription">
        {description}
      </span>
    </div>

  selectOption: (optionKey) ->
    @props.onChange(optionKey)
    @hideModal()

  hideModal: ->
    React.render(<span/>, @refs.loadContainer.getDOMNode())

  hideModalWithTimeout: ->
    setTimeout @hideModal

  showModal: ->
    modalContent =
      <div className="loadOptions">
        {R.mapObjIndexed(@mapOption)(@props.options)}
      </div>
    modalInstance = (
        <div id="loadModal" className="static-modal">
          <Modal title="Load an example"
            bsStyle="primary"
            backdrop={true}
            animation={true}
            container={@refs.loadContainer}
            onRequestHide={@hideModalWithTimeout}>
            <div className="modal-body">
              {modalContent}
            </div>
          </Modal>
        </div>
      )
    React.render(modalInstance, @refs.loadContainer.getDOMNode())

  render: ->
    <span id="loadArea">
      <Button bsStyle="primary" id="loadButton" onClick={@showModal}>
        Load
      </Button>
      <span id="loadContainer" ref="loadContainer"/>
    </span>

{'fraction_non_alphanumeric': 0.13969441845961958, 'fraction_numerical': 0.0, 'mean_word_length': 2.6873563218390806, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 54, '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': '1788001', 'n_tokens_mistral': 941, 'n_tokens_neox': 924, 'n_words': 176}