<commit_before>import _ from 'messages'
import map from 'lodash/map'
import React from 'react'
import Icon from 'icon'
import {
  Button,
  DropdownButton,
  ButtonGroup,
  ButtonToolbar,
  MenuItem
} from 'react-bootstrap-4/lib'

const ActionBar = ({ actions, display = 'text' }) => (
  <ButtonToolbar>
    {map(actions, (action, index) =>
      !action.dropdownItems
      ? <Button bsStyle='secondary' key={index} onClick={() => action.handler()} style={{width: '2.3em', fontSize: '1.8em', borderRadius: '15px'}}>
        <Content key={index} display={display} label={action.label} icon={action.icon} />
      </Button>
      : <ButtonGroup bsStyle='secondary' pullRight key={index}>
        <DropdownButton
          key={index}
          id={`dropdown-${index}`}
          pullRight
          bsStyle='secondary'
          onClick={() => action.handler()}
          noCaret
          style={{width: '2.3em', fontSize: '1.8em', borderRadius: '15px'}}
          title={<Content display={display} label={action.label} icon={action.icon} />}
        >
          <MenuItem key={index} eventKey={index} onClick={action.handler}>
            <Content key={index} display='both' label={action.label} icon={action.icon} main />
          </MenuItem>
          {map(action.dropdownItems, ({label, icon, handler}, index) => (
            <MenuItem key={index} eventKey={index} onClick={handler}>
              <Content key={index} display='both' label={label} icon={icon} />
            </MenuItem>
          ))}
        </DropdownButton>
      </ButtonGroup>
    )}
  </ButtonToolbar>
)
ActionBar.propTypes = {
  actions: React.PropTypes.arrayOf(
    React.PropTypes.shape({
      label: React.PropTypes.string.isRequired,
      icon: React.PropTypes.string.isRequired,
      handler: React.PropTypes.func,
      dropdownItems: React.PropTypes.array
    })
  ).isRequired,
  display: React.PropTypes.oneOf(['icon', 'text', 'both'])
}
export default ActionBar

const Content = ({display, icon, label, main}) => (
  <span style={{fontWeight: main && 'bold'}}>
    {icon && (display === 'icon' || display === 'both') ? <Icon icon={icon} /> : null}
    {display === 'both' && <span>&nbsp;&nbsp;</span>}
    {label && (display === 'text' || display === 'both') ? _(label) : null}
  </span>
)
<commit_msg>add tool tip for action bar<commit_after>import _ from 'messages'
import Icon from 'icon'
import map from 'lodash/map'
import React from 'react'
import Tooltip from 'tooltip'
import {
  Button,
  DropdownButton,
  ButtonGroup,
  ButtonToolbar,
  MenuItem
} from 'react-bootstrap-4/lib'

const ActionBar = ({ actions, display = 'text' }) => (
  <ButtonToolbar>
    {map(actions, (action, index) =>
      !action.dropdownItems
      ? <Tooltip content={_(action.label)}><Button bsStyle='secondary' key={index} onClick={() => action.handler()} style={{width: '2.3em', fontSize: '1.8em', borderRadius: '15px'}}>
        <Content key={index} display={display} label={action.label} icon={action.icon} />
      </Button></Tooltip>
      : <ButtonGroup bsStyle='secondary' pullRight key={index}>
        <DropdownButton
          key={index}
          id={`dropdown-${index}`}
          pullRight
          bsStyle='secondary'
          onClick={() => action.handler()}
          noCaret
          style={{width: '2.3em', fontSize: '1.8em', borderRadius: '15px'}}
          title={<Content display={display} label={action.label} icon={action.icon} />}
        >
          <MenuItem key={index} eventKey={index} onClick={action.handler}>
            <Content key={index} display='both' label={action.label} icon={action.icon} main />
          </MenuItem>
          {map(action.dropdownItems, ({label, icon, handler}, index) => (
            <MenuItem key={index} eventKey={index} onClick={handler}>
              <Content key={index} display='both' label={label} icon={icon} />
            </MenuItem>
          ))}
        </DropdownButton>
      </ButtonGroup>
    )}
  </ButtonToolbar>
)
ActionBar.propTypes = {
  actions: React.PropTypes.arrayOf(
    React.PropTypes.shape({
      label: React.PropTypes.string.isRequired,
      icon: React.PropTypes.string.isRequired,
      handler: React.PropTypes.func,
      dropdownItems: React.PropTypes.array
    })
  ).isRequired,
  display: React.PropTypes.oneOf(['icon', 'text', 'both'])
}
export default ActionBar

const Content = ({display, icon, label, main}) => (
  <span style={{fontWeight: main && 'bold'}}>
    {icon && (display === 'icon' || display === 'both') ? <Icon icon={icon} /> : null}
    {display === 'both' && <span>&nbsp;&nbsp;</span>}
    {label && (display === 'text' || display === 'both') ? _(label) : null}
  </span>
)

{'fraction_non_alphanumeric': 0.17682274962582853, 'fraction_numerical': 0.005559119093435963, 'mean_word_length': 3.136162687886826, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 59, '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': '629233', 'n_tokens_mistral': 1417, 'n_tokens_neox': 1426, 'n_words': 310}