<commit_before>import React, { PropTypes } from 'react'
import classnames from 'classnames'
import { NavbarButton, NavbarForm } from './'

export default class NavbarEditionWrapper extends React.Component {
  static propTypes = {
    block: PropTypes.object.isRequired,
    mobilization: PropTypes.object.isRequired,
    auth: PropTypes.object.isRequired,
    dispatch: PropTypes.func.isRequired,
    className: PropTypes.string
  }

  constructor(props, context) {
    super(props, context)
    this.state = {
      isEditing: false,
      isMouseOver: false
    }
  }

  onEditButtonClick() {
    this.setState({
      isEditing: true,
      isMouseOver: false
    })
  }

  handleCloseForm() {
    this.setState({isEditing: false})
  }

  onMouseOver() {
    this.setState({isMouseOver: true})
  }

  onMouseOut() {
    this.setState({isMouseOver: false})
  }

  renderEditingButtons() {
    const editingButtonsClassName = classnames(
      'absolute z1 right-align full-width top-0',
      { hide: this.state && !this.state.isMouseOver }
    )

    return (
      <div className='relative'>
        <div className={editingButtonsClassName}>
          <button
            className='button white bg-darken-4 circle'
            style={{width: '25px', height: '25px', padding: 0}}
            onClick={::this.onEditButtonClick}>
            <i className='fa fa-pencil' />
          </button>
        </div>
      </div>
    )
  }

  blockName(block) {
    return block.name || `Bloco ${block.position}`
  }

  renderNavbarButton() {
    const { block, className } = this.props

    return (
      <div className='inline-block' onMouseOver={::this.onMouseOver} onMouseOut={::this.onMouseOut}>
        <NavbarButton
          targetId={'block-' + block.id}
          scrollableId='blocks-list'
          className={className}>
          {this.blockName(block)}
        </NavbarButton>
        {this.props.editable && this.renderEditingButtons()}
      </div>
    )
  }

  renderNavbarForm() {
    const { block } = this.props

    return (
      <NavbarForm
        {...this.props}
        defaultValue={this.blockName(block)}
        handleCloseForm={::this.handleCloseForm}
      />
    )<commit_msg>[#102391610] do some refactoring in NavbarEditionWrapper<commit_after>import React, { PropTypes } from 'react'
import classnames from 'classnames'
import { NavbarButton, NavbarForm } from './'

export default class NavbarEditionWrapper extends React.Component {
  static propTypes = {
    block: PropTypes.object.isRequired,
    mobilization: PropTypes.object.isRequired,
    auth: PropTypes.object.isRequired,
    dispatch: PropTypes.func.isRequired,
    className: PropTypes.string
  }

  constructor(props, context) {
    super(props, context)
    this.state = {
      isEditing: false,
      isMouseOver: false
    }
  }

  handleEditButtonClick() {
    this.setState({
      isEditing: true,
      isMouseOver: false
    })
  }

  handleCloseForm() {
    this.setState({isEditing: false})
  }

  handleMouseOver() {
    this.setState({isMouseOver: true})
  }

  handleMouseOut() {
    this.setState({isMouseOver: false})
  }

  renderEditingButtons() {
    const buttonsWrapperClassName = classnames(
      'absolute z1 right-align full-width top-0',
      { hide: this.state && !this.state.isMouseOver }
    )

    const editingButtonsStyle = {
      width: '25px',
      height: '25px',
      padding: 0,
      marginLeft: '2px'
    }

    const editingButtonsClassName = 'button white bg-darken-4 circle'

    return (
      <div className='relative'>
        <div className={buttonsWrapperClassName}>
          <button
            className={editingButtonsClassName}
            style={editingButtonsStyle}
            onClick={::this.handleEditButtonClick}>
            <i className='fa fa-pencil' />
          </button>
        </div>
      </div>
    )
  }

  blockName(block) {
    return block.name || `Bloco ${block.position}`
  }

  renderNavbarButton() {
    const { block, className } = this.props

    return (
      <div
        className='inline-block'
        onMouseOver={::this.handleMouseOver}
        onMouseOut={::this.handleMouseOut}>
        <NavbarButton
          targetId={'block-' + block.id}
          scrollableId='blocks-list'
          className={className}>
          {this.blockName(block)}
        </NavbarButton>
        {this.props.editable && this.renderEditingButtons()}
      </div>
    )
  }

  renderNavbarForm() {
    const { block } = this.props

    return (
      <NavbarForm
        {...this.props}
        defaultValue={this.blockName(block)}
        handleCloseForm={::this.handleCloseForm}
      />
    )
{'fraction_non_alphanumeric': 0.12376662376662377, 'fraction_numerical': 0.005577005577005577, 'mean_word_length': 2.5325757575757577, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, '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': '2004554', 'n_tokens_mistral': 1416, 'n_tokens_neox': 1411, 'n_words': 261}