<commit_before>import React, { useEffect, useState } from 'react'
import PropTypes from 'prop-types'
import { withTranslation } from 'react-i18next'
import Button from '../../../components/button/Button'
import { Modal, ModalActions, ModalBody } from '../../../components/modal/Modal'
import { connect } from 'redux-bundler-react'
import Radio from '../../../components/radio/Radio'
import './PublishModal.css'

const PublishModal = ({ t, tReady, onCancel, onSubmit, file, ipnsKeys, className, doFetchIpnsKeys, ...props }) => {
  const [selectedKey, setSelectedKey] = useState('')

  const handlePublish = () => {
    onSubmit(selectedKey)
  }

  useEffect(() => {
    doFetchIpnsKeys()
  }, [doFetchIpnsKeys])

  return (
    <Modal {...props} className={className} onCancel={onCancel} >
      <ModalBody title={t('publishModal.title')}>
        <p>{t('publishModal.toPublish')} <span className='f6 monospace'>{file.cid.toString()}</span></p>

        <div className="publishModalKeys">
          { ipnsKeys.map(({ name }) => (
            <button className="flex items-center pa1 hoverable-button" key={name} onClick={() => setSelectedKey(name)}>
              <Radio className='pv3 pl3 pr1 flex-none' checked={name === selectedKey} label={name} style={{ pointerEvents: 'none' }} />
            </button>
          ))}
        </div>
      </ModalBody>

      <ModalActions>
        <Button className='ma2 tc' bg='bg-gray' onClick={onCancel}>{t('app:actions.cancel')}</Button>
        <Button className='ma2 tc' bg='bg-teal' onClick={handlePublish}>{t('app:actions.publish')}</Button>
      </ModalActions>
    </Modal>
  )
}

PublishModal.propTypes = {
  onCancel: PropTypes.func.isRequired,
  onSubmit: PropTypes.func.isRequired,
  t: PropTypes.func.isRequired,
  file: PropTypes.object,<commit_msg>fix: disable button when no option is selected<commit_after>import React, { useEffect, useState } from 'react'
import PropTypes from 'prop-types'
import { withTranslation } from 'react-i18next'
import Button from '../../../components/button/Button'
import { Modal, ModalActions, ModalBody } from '../../../components/modal/Modal'
import { connect } from 'redux-bundler-react'
import Radio from '../../../components/radio/Radio'
import './PublishModal.css'

const PublishModal = ({ t, tReady, onCancel, onSubmit, file, ipnsKeys, className, doFetchIpnsKeys, ...props }) => {
  const [selectedKey, setSelectedKey] = useState('')

  const handlePublish = () => {
    onSubmit(selectedKey)
  }

  useEffect(() => {
    doFetchIpnsKeys()
  }, [doFetchIpnsKeys])

  return (
    <Modal {...props} className={className} onCancel={onCancel} >
      <ModalBody title={t('publishModal.title')}>
        <p>{t('publishModal.toPublish')} <span className='f6 monospace'>{file.cid.toString()}</span></p>

        <div className="publishModalKeys">
          { ipnsKeys.map(({ name }) => (
            <button className="flex items-center pa1 hoverable-button" key={name} onClick={() => setSelectedKey(name)}>
              <Radio className='pv3 pl3 pr1 flex-none' checked={name === selectedKey} label={name} style={{ pointerEvents: 'none' }} />
            </button>
          ))}
        </div>
      </ModalBody>

      <ModalActions>
        <Button className='ma2 tc' bg='bg-gray' onClick={onCancel}>{t('app:actions.cancel')}</Button>
        <Button className='ma2 tc' bg='bg-teal' disabled={selectedKey === ''} onClick={handlePublish}>{t('app:actions.publish')}</Button>
      </ModalActions>
    </Modal>
  )
}

PublishModal.propTypes = {
  onCancel: PropTypes.func.isRequired,
  onSubmit: PropTypes.func.isRequired,
  t: PropTypes.func.isRequired,
  file: PropTypes.object,
{'fraction_non_alphanumeric': 0.1736167893158899, 'fraction_numerical': 0.004905968928863451, 'mean_word_length': 3.604767879548306, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 51, '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': '7142075', 'n_tokens_mistral': 1114, 'n_tokens_neox': 1137, 'n_words': 235}