<commit_before>import React, { Component, PropTypes } from 'react'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { Link } from 'react-router'

import Alert from '../components/Alert'
import InputGroup from '../components/InputGroup'
import { KeychainActions } from '../store/keychain'
import { decrypt } from '../utils/keychain-utils'

function mapStateToProps(state) {
  return {
    encryptedMnemonic: state.keychain.encryptedMnemonic
  }
}

class BackupPage extends Component {
  static propTypes = {
    encryptedMnemonic: PropTypes.string.isRequired
  }

  constructor(props) {
    super(props)

    this.state = {
      decryptedMnemonic: null,
      password: '',
      alerts: []
    }

    this.onChange = this.onChange.bind(this)
    this.decryptBackupPhrase = this.decryptBackupPhrase.bind(this)
    this.updateAlert = this.updateAlert.bind(this)
  }

  onChange(event) {
    if (event.target.name === 'password') {
      this.setState({
        password: event.target.value
      })
    }
  }

  updateAlert(alertStatus, alertMessage) {
    this.setState({
      alerts: [{ status: alertStatus, message: alertMessage }]
    })
  }

  decryptBackupPhrase() {
    const password = this.state.password,
          dataBuffer = new Buffer(this.props.encryptedMnemonic, 'hex')
    decrypt(dataBuffer, password, (err, plaintextBuffer) => {
      if (!err) {
        this.setState({
          decryptedMnemonic: plaintextBuffer.toString(),
          alertStatus: null,
          alertMessage: null
        })
      } else {
        this.updateAlert('danger', 'Invalid password')
      }
    })
  }

  render() {
    return (<commit_msg>fix bug in alerts on backup phrase decryption page<commit_after>import React, { Component, PropTypes } from 'react'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { Link } from 'react-router'

import Alert from '../components/Alert'
import InputGroup from '../components/InputGroup'
import { KeychainActions } from '../store/keychain'
import { decrypt } from '../utils/keychain-utils'

function mapStateToProps(state) {
  return {
    encryptedMnemonic: state.keychain.encryptedMnemonic
  }
}

class BackupPage extends Component {
  static propTypes = {
    encryptedMnemonic: PropTypes.string.isRequired
  }

  constructor(props) {
    super(props)

    this.state = {
      decryptedMnemonic: null,
      password: '',
      alerts: []
    }

    this.onChange = this.onChange.bind(this)
    this.decryptBackupPhrase = this.decryptBackupPhrase.bind(this)
    this.updateAlert = this.updateAlert.bind(this)
  }

  onChange(event) {
    if (event.target.name === 'password') {
      this.setState({
        password: event.target.value
      })
    }
  }

  updateAlert(alertStatus, alertMessage) {
    this.setState({
      alerts: [{ status: alertStatus, message: alertMessage }]
    })
  }

  decryptBackupPhrase() {
    const password = <PASSWORD>,
          dataBuffer = new Buffer(this.props.encryptedMnemonic, 'hex')
    decrypt(dataBuffer, password, (err, plaintextBuffer) => {
      if (!err) {
        this.updateAlert('success', 'Backup phrase decrypted')
        this.setState({
          decryptedMnemonic: plaintextBuffer.toString()
        })
      } else {
        this.updateAlert('danger', 'Invalid password')
      }
    })
  }

  render() {
    return (
{'fraction_non_alphanumeric': 0.12190812720848057, 'fraction_numerical': 0.0, 'mean_word_length': 2.9870892018779345, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, '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': '3706740', 'n_tokens_mistral': 1053, 'n_tokens_neox': 1033, 'n_words': 212}