on master help sign in
WIP commit -- squash me.
e8a6470Jared Tobin
src/components/UploadButton.jsnew file+31
@@ -0,0 +1,31 @@
1+import React from 'react';
2+
3+class UploadButton extends React.Component {
4+ constructor(props) {
5+ super(props);
6+ this.onChange = this.onChange.bind(this);
7+ }
8+
9+ onChange() {
10+ this.props.onChange(this.input);
11+ }
12+
13+ render() {
14+ return (
15+ <label className={this.props.className}>
16+ <input
17+ className={'hidden'}
18+ accept={'.txt'}
19+ ref={(ref) => { this.input = ref; }}
20+ onChange={this.onChange}
21+ disabled={this.props.disabled}
22+ type="file"
23+ />
24+ {this.props.children}
25+ </label>
26+ );
27+ }
28+}
29+
30+export default UploadButton;
31+
src/views/Keystore.js+38−12
@@ -7,6 +7,7 @@ import { Row, Col, H1, Form } from '../components/Base'
7
7
8import { ROUTE_NAMES } from '../lib/router'
8import { ROUTE_NAMES } from '../lib/router'
9import { EthereumWallet } from '../lib/wallet'
9import { EthereumWallet } from '../lib/wallet'
10+import UploadButton from '../components/UploadButton'
10
11
11class Keystore extends React.Component {
12class Keystore extends React.Component {
12
13
@@ -45,10 +46,41 @@ class Keystore extends React.Component {
45 }
46 }
46 }
47 }
47
48
49+ handleKeystoreUpload = (event) => {
50+ const file = event.files.item(0)
51+ const reader = new FileReader()
52+
53+ reader.readAsText(file)
54+
55+ console.log(reader.readyState)
56+
57+ // const loop = arg =>
58+ // arg.readyState === 2
59+ // ? arg.result
60+ // : loop(arg)
61+
62+ // const keystore = loop(reader)
63+ // this.setState({ keystore })
64+ }
65+
48 render() {
66 render() {
49 const { pushRoute, popRoute, wallet } = this.props
67 const { pushRoute, popRoute, wallet } = this.props
50 const { keystore, password } = this.state
68 const { keystore, password } = this.state
51
69
70+ const keystoreInput =
71+ <Input
72+ className='pt-8 mt-8'
73+ prop-size='md'
74+ prop-format='innerLabel'
75+ type='text'
76+ name='keystore'
77+ onChange={ this.handleKeystoreInput }
78+ value={ keystore }
79+ autocomplete='off'
80+ autoFocus>
81+ <InnerLabel>{'Keystore File'}</InnerLabel>
82+ </Input>
83+
52 return (
84 return (
53 <Row>
85 <Row>
54 <Col className={'measure-md'}>
86 <Col className={'measure-md'}>
@@ -60,18 +92,12 @@ class Keystore extends React.Component {
60 that below.` }
92 that below.` }
61 </InputCaption>
93 </InputCaption>
62
94
63− <Input
95+ <UploadButton
64− className='pt-8 mt-8'
96+ className={ `btn btn-primary table mt-4` }
65− prop-size='md'
97+ onChange={ this.handleKeystoreUpload }
66− prop-format='innerLabel'
98+ >
67− type='text'
99+ { 'Upload Keystore file' }
68− name='keystore'
100+ </UploadButton>
69− onChange={ this.handleKeystoreInput }
70− value={ keystore }
71− autocomplete='off'
72− autoFocus>
73− <InnerLabel>{'Keystore File'}</InnerLabel>
74− </Input>
75
101
76 <Input
102 <Input
77 className='pt-8 mt-8'
103 className='pt-8 mt-8'