1 import React from 'react'
8 } from 'features/shared/components'
9 import componentClassNames from 'utility/componentClassNames'
11 class Show extends BaseShow {
14 this.submitWithErrors = this.submitWithErrors.bind(this)
17 submitExportFileWithErrors(data, item) {
18 return new Promise((resolve, reject) => {
21 'password': data.exportsPassword
23 this.props.exportKey(arg, item.alias)
24 .catch((err) => reject({_error: err.message}))
28 submitWithErrors(data, xpub) {
29 return new Promise((resolve, reject) => {
32 'old_password': data.oldPassword,
33 'new_password': data.newPassword
35 this.props.submitForm(arg)
36 .catch((err) => reject({_error: err.message}))
41 const item = this.props.item
42 const lang = this.props.lang
44 fields: { exportsPassword, oldPassword, newPassword, repeatPassword },
52 {lang === 'zh' ? '密钥' : 'Keys '}
53 <code>{item.alias ? item.alias : item.id}</code>
56 view = <div className={componentClassNames(this)}>
65 title={lang === 'zh' ? '详情' : 'Details'}
67 {label: 'Alias', value: item.alias},
68 {label: 'xpubs', value: item.xpub},
73 <h5>Export private key</h5>
74 <form onSubmit={handleSubmit(value => this.submitExportFileWithErrors(value, item))}>
77 placeholder='Please entered the password.'
78 fieldProps={exportsPassword}
80 <button type='submit' className='btn btn-primary' disabled={submitting}>
81 { lang === 'zh' ? '导出私钥' : 'Export private key' }</button>
84 <h5>Reset password</h5>
85 <form onSubmit={handleSubmit(value => this.submitWithErrors(value, item.xpub))}>
87 title = 'Old Password'
88 placeholder='Please entered the old password.'
89 fieldProps={oldPassword}
92 title = 'New Password'
93 placeholder='Please entered the new password.'
94 fieldProps={newPassword}
97 title = 'Repeat Password'
98 placeholder='Please repeated the new password.'
99 fieldProps={repeatPassword}
102 <button type='submit' className='btn btn-primary' disabled={submitting}>
109 return this.renderIfFound(view)
115 import {connect} from 'react-redux'
116 import actions from 'actions'
117 import {reduxForm} from 'redux-form'
119 const mapStateToProps = (state, ownProps) => ({
120 item: state.key.items[ownProps.params.id],
121 lang: state.core.lang
124 const mapDispatchToProps = ( dispatch ) => ({
125 fetchItem: (id) => dispatch(actions.key.fetchItems({id: `${id}`})),
126 exportKey: (item, fileName) => dispatch(actions.key.createExport(item, fileName)),
127 submitForm: (params) => dispatch(actions.key.submitResetForm(params))
131 export default connect(
135 form: 'ResetPassword',
136 fields: ['exportsPassword', 'oldPassword', 'newPassword', 'repeatPassword' ],