<commit_before>import PropTypes from 'prop-types'
import React from 'react'
import _omit from 'lodash/omit'
import {OLD_ACTION_TYPE, ACTION_GROUP_TYPE, modeFitsScopes} from '../actions'
import ActionGroup from './ActionGroup'
import SingleAction from './SingleAction'

const Action = ({definition, onClick, ids, entity, mode}) => {
  if (!modeFitsScopes(mode, definition.scopes)) return null

  if (definition.type === OLD_ACTION_TYPE) return null
  const ActionType = definition.type === ACTION_GROUP_TYPE ? ActionGroup : SingleAction

  return (
    <span className="action">
      <ActionType
        definition={definition}
        onClick={definition => {
          onClick(_omit(definition, ['label']), entity, ids)
        }}
      />
    </span>
  )
}

Action.propTypes = {
  definition: PropTypes.object.isRequired,
  ids: PropTypes.array,
  entity: PropTypes.string,
  onClick: PropTypes.func.isRequired,
  mode: PropTypes.string
}

export default Action<commit_msg>refactor(tocco-util): adjust action proptypes<commit_after>import PropTypes from 'prop-types'
import React from 'react'
import _omit from 'lodash/omit'
import {OLD_ACTION_TYPE, ACTION_GROUP_TYPE, modeFitsScopes} from '../actions'
import ActionGroup from './ActionGroup'
import SingleAction from './SingleAction'

const Action = ({definition, onClick, ids, entity, mode}) => {
  if (!modeFitsScopes(mode, definition.scopes)) return null

  if (definition.type === OLD_ACTION_TYPE) return null
  const ActionType = definition.type === ACTION_GROUP_TYPE ? ActionGroup : SingleAction

  return (
    <span className="action">
      <ActionType
        definition={definition}
        onClick={definition => {
          onClick(_omit(definition, ['label']), entity, ids)
        }}
      />
    </span>
  )
}

Action.propTypes = {
  definition: PropTypes.shape({
    type: PropTypes.string,
    useLabel: PropTypes.string,
    icon: PropTypes.string,
    label: PropTypes.string,
    config: PropTypes.object
  }).isRequired,
  ids: PropTypes.array,
  entity: PropTypes.string,
  onClick: PropTypes.func.isRequired,
  mode: PropTypes.string
}

export default Action
{'fraction_non_alphanumeric': 0.11797752808988764, 'fraction_numerical': 0.0, 'mean_word_length': 4.004683840749414, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, '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': '5102510', 'n_tokens_mistral': 617, 'n_tokens_neox': 627, 'n_words': 161}