<commit_before>import React, { PropTypes } from 'react'
import classnames from 'classnames'

// Global module dependencies
import { DropdownMenu, DropdownMenuItem } from '~components/dropdown-menu'

const displayDropDownMenu = ({ state, props }) => {
  return (
    state.hasMouseOver &&
    !state.editingBackground &&
    !state.editingWidget &&
    !props.blockIsRequest &&
    props.editable
  )
}

const BlockDropdownMenu = ({ state, props, onChange }) => {
  const {
    canMoveUp,
    canMoveDown,
    mobilization,
    block,
    blocks
  } = props

  return (
    <DropdownMenu
      wrapperClassName={classnames(
        'm1 absolute bottom-0 right-0 z2',
        {'display-none': !displayDropdownMenu({ state, props })}
      )}
      menuClassName='bg-darken-4 rounded white right-0 top-0 mr4'
      buttonClassName='btn bg-darken-4 white rounded'
      icon='cog'
    >
      <DropdownMenuItem
        onClick={() => {
          onChange({ editingBackground: true })
          props.setEditionMode(true)
        }}
        className="btn"
      >
        <span>
          <i className='fa fa-picture-o' /> Alterar fundo
        </span>
      </DropdownMenuItem>
      <DropdownMenuItem
        onClick={() => {
          // onChange({ loading: true })
          props.blockUpdate({
            mobilization,
            block: { ...block, hidden: !block.hidden }
          })
        }}
        className='btn'>
        <span>
          <i className={classnames('fa', (block.hidden ? 'fa-eye' : 'fa-eye-slash'))} />
          {(block.hidden ? ' Mostrar' : ' Esconder')}
        </span>
      </DropdownMenuItem>
      <DropdownMenuItem
        onClick={() => {
          if (window.confirm('Você tem certeza que quer remover este bloco?')) {
            // onChange({ loading: true })
            props.blockDestroy({ mobilization, block })
          }
        }}
        className='btn'>
        <span>
          <i className='fa fa-trash' /> Remover
        </span>
      </DropdownMenuItem>
      <DropdownMenuItem
        disabled={!canMoveUp}
        onClick={() => {
          // onChange({ loading: true })
          props.blockMove('up', { mobilization, block, blocks })
        }}
        className='btn'>
        <span>
          <i className='fa fa-chevron-up' /> Mover para cima
        </span>
      </DropdownMenuItem>
      <DropdownMenuItem
        disabled={!canMoveDown}
        onClick={() => {
          // onChange({ loading: true })
          props.blockMove('down', { mobilization, block, blocks })
        }}
        className='btn'>
        <span>
          <i className='fa fa-chevron-down' /> Mover para baixo
        </span>
      </DropdownMenuItem>
    </DropdownMenu>
  )
}

BlockDropdownMenu.propTypes = {
  state: PropTypes.shape({
    hasMouseOver: PropTypes.bool,
    editingBackground: PropTypes.bool,
    editingWidget: PropTypes.bool,
  }),
  props: PropTypes.shape({
    editable: PropTypes.bool,
    dispatch: PropTypes.func,
    canMoveUp: PropTypes.bool,
    canMoveDown: PropTypes.bool,
    mobilization: PropTypes.object,
    blocks: PropTypes.array,
    blockIsRequest: PropTypes.bool,
    block: PropTypes.shape({
      hidden: PropTypes.bool
    })
  }),
  onChange: PropTypes.func
}

export default BlockDropdownMenu<commit_msg>Fix unscoped function use insde BlockDropdownMenu component #348<commit_after>import React, { PropTypes } from 'react'
import classnames from 'classnames'

// Global module dependencies
import { DropdownMenu, DropdownMenuItem } from '~components/dropdown-menu'

const BlockDropdownMenu = ({ state, props, onChange }) => {
  const {
    canMoveUp,
    canMoveDown,
    mobilization,
    block,
    blocks
  } = props

  return (
    <DropdownMenu
      wrapperClassName={classnames(
        'm1 absolute bottom-0 right-0 z2',
        {'display-none': !(
          state.hasMouseOver &&
          !state.editingBackground &&
          !state.editingWidget &&
          !props.blockIsRequest &&
          props.editable
        )}
      )}
      menuClassName='bg-darken-4 rounded white right-0 top-0 mr4'
      buttonClassName='btn bg-darken-4 white rounded'
      icon='cog'
    >
      <DropdownMenuItem
        onClick={() => {
          onChange({ editingBackground: true })
          props.setEditionMode(true)
        }}
        className='btn'
      >
        <span>
          <i className='fa fa-picture-o' /> Alterar fundo
        </span>
      </DropdownMenuItem>
      <DropdownMenuItem
        onClick={() => {
          // onChange({ loading: true })
          props.blockUpdate({
            mobilization,
            block: { ...block, hidden: !block.hidden }
          })
        }}
        className='btn'>
        <span>
          <i className={classnames('fa', (block.hidden ? 'fa-eye' : 'fa-eye-slash'))} />
          {(block.hidden ? ' Mostrar' : ' Esconder')}
        </span>
      </DropdownMenuItem>
      <DropdownMenuItem
        onClick={() => {
          if (window.confirm('Você tem certeza que quer remover este bloco?')) {
            // onChange({ loading: true })
            props.blockDestroy({ mobilization, block })
          }
        }}
        className='btn'>
        <span>
          <i className='fa fa-trash' /> Remover
        </span>
      </DropdownMenuItem>
      <DropdownMenuItem
        disabled={!canMoveUp}
        onClick={() => {
          // onChange({ loading: true })
          props.blockMove('up', { mobilization, block, blocks })
        }}
        className='btn'>
        <span>
          <i className='fa fa-chevron-up' /> Mover para cima
        </span>
      </DropdownMenuItem>
      <DropdownMenuItem
        disabled={!canMoveDown}
        onClick={() => {
          // onChange({ loading: true })
          props.blockMove('down', { mobilization, block, blocks })
        }}
        className='btn'>
        <span>
          <i className='fa fa-chevron-down' /> Mover para baixo
        </span>
      </DropdownMenuItem>
    </DropdownMenu>
  )
}

BlockDropdownMenu.propTypes = {
  state: PropTypes.shape({
    hasMouseOver: PropTypes.bool,
    editingBackground: PropTypes.bool,
    editingWidget: PropTypes.bool
  }),
  props: PropTypes.shape({
    editable: PropTypes.bool,
    dispatch: PropTypes.func,
    canMoveUp: PropTypes.bool,
    canMoveDown: PropTypes.bool,
    mobilization: PropTypes.object,
    blocks: PropTypes.array,
    blockIsRequest: PropTypes.bool,
    block: PropTypes.shape({
      hidden: PropTypes.bool
    })
  }),
  onChange: PropTypes.func
}

export default BlockDropdownMenu
{'fraction_non_alphanumeric': 0.13151478207863457, 'fraction_numerical': 0.0032002438281011885, 'mean_word_length': 2.1104265402843603, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 70, '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': '5105743', 'n_tokens_mistral': 1874, 'n_tokens_neox': 1919, 'n_words': 398}