Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

AccountCreate updates #3988

Merged
merged 58 commits into from
Jan 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
c185bb8
Add esjify for mocha + ejs
jacogr Dec 28, 2016
7b8e708
First pass through, intl + basic smoketests
jacogr Dec 28, 2016
28579ed
Create store
jacogr Dec 28, 2016
ecb30b4
Update for renames
jacogr Dec 28, 2016
1247ac9
Merge branch 'master' into jg-createacc-cleanup
jacogr Dec 28, 2016
ab2e1d7
Pass store around
jacogr Dec 28, 2016
23122c0
createType into store
jacogr Dec 28, 2016
b9fc318
Move stage into store
jacogr Dec 28, 2016
8b5d029
Update labels
jacogr Dec 28, 2016
88536d5
Merge branch 'master' into jg-createacc-cleanup
jacogr Dec 28, 2016
26d921a
Define stages
jacogr Dec 28, 2016
d7aac87
address into store
jacogr Dec 28, 2016
8374e8d
Add @observer
jacogr Dec 29, 2016
c04c97c
Retrieve name from store
jacogr Dec 29, 2016
18aa984
Store phrase in store
jacogr Dec 29, 2016
c3ea88c
isWindowsPhrase into store
jacogr Dec 29, 2016
3dd861a
Merge branch 'master' into jg-createacc-cleanup
jacogr Dec 29, 2016
7fca950
gethAddresses to store
jacogr Dec 29, 2016
ad4a195
Store manages geth addresses
jacogr Dec 29, 2016
3614b57
passwordHint into store
jacogr Dec 29, 2016
8051e62
Merge branch 'master' into jg-createacc-cleanup
jacogr Dec 29, 2016
4abe154
Fix build
jacogr Dec 29, 2016
bf8a1b5
rawKey into store
jacogr Dec 29, 2016
a013998
import json files
jacogr Dec 29, 2016
b80ed13
Merge branch 'master' into jg-createacc-cleanup
jacogr Dec 30, 2016
d499a2b
name set direct from component
jacogr Dec 30, 2016
ca7788b
No parent change callbacks
jacogr Dec 30, 2016
aa52c4a
canCreate from store
jacogr Dec 30, 2016
eb93c6b
Merge branch 'master' into jg-createacc-cleanup
jacogr Dec 30, 2016
b7f7e7c
createAccounts into store
jacogr Dec 30, 2016
a2ceda7
expand create tests
jacogr Dec 30, 2016
0ab9319
Merge branch 'master' into jg-createacc-cleanup
jacogr Dec 30, 2016
424f4be
Windows phrase testcases
jacogr Dec 30, 2016
7a7492e
Merge branch 'master' into jg-createacc-cleanup
jacogr Jan 3, 2017
e804eba
Properly bind newError
jacogr Jan 3, 2017
4ac7f08
FirstRun use of new CreateAccount
jacogr Jan 3, 2017
7f6943c
Merge branch 'master' into jg-createacc-cleanup
jacogr Jan 10, 2017
232e2a0
Merge branch 'master' into jg-createacc-cleanup
jacogr Jan 12, 2017
092b7a5
Merge branch 'master' into jg-createacc-cleanup
jacogr Jan 16, 2017
3d19c97
Merge branch 'master' into jg-createacc-cleanup
jacogr Jan 19, 2017
f7f1b58
Merge branch 'master' into jg-createacc-cleanup
jacogr Jan 20, 2017
3aabeeb
Merge branch 'master' into jg-createacc-cleanup
jacogr Jan 20, 2017
ded6b13
Add fix & test for selectedAddress match
jacogr Jan 20, 2017
6032eca
Call into store from props
jacogr Jan 20, 2017
053006d
Merge branch 'master' into jg-createacc-cleanup
jacogr Jan 20, 2017
a095d43
onChangeIdentity fix & test
jacogr Jan 20, 2017
f4735f4
Phrase set fix & test
jacogr Jan 20, 2017
d79dc64
Merge branch 'master' into jg-createacc-cleanup
jacogr Jan 20, 2017
525c10e
Merge branch 'master' into jg-createacc-cleanup
jacogr Jan 23, 2017
57438ea
RecoveryPhrase tested manually (issues addressed via tests)
jacogr Jan 23, 2017
8406f79
Hex import manual test (& tests added for errors)
jacogr Jan 23, 2017
50e998d
Merge branch 'master' into jg-createacc-cleanup
jacogr Jan 23, 2017
d429c72
New eslint update fixes
jacogr Jan 23, 2017
ae93f75
Merge branch 'master' into jg-createacc-cleanup
ngotchac Jan 23, 2017
63530e7
Merge branch 'master' into jg-createacc-cleanup
jacogr Jan 23, 2017
97d1907
grumble: set default type from store (with test)
jacogr Jan 23, 2017
47618f7
grumble: pass copy of accounts (observable injection)
jacogr Jan 23, 2017
533f349
grumble: Summary owners can be array or array-like
jacogr Jan 23, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 44 additions & 13 deletions js/src/modals/CreateAccount/AccountDetails/accountDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,54 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

import { observer } from 'mobx-react';
import React, { Component, PropTypes } from 'react';
import { FormattedMessage } from 'react-intl';

import { Form, Input, InputAddress } from '~/ui';

@observer
export default class AccountDetails extends Component {
static propTypes = {
address: PropTypes.string,
name: PropTypes.string,
phrase: PropTypes.string
store: PropTypes.object.isRequired
}

render () {
const { address, name } = this.props;
const { address, name } = this.props.store;

return (
<Form>
<Input
readOnly
allowCopy
hint='a descriptive name for the account'
label='account name'
hint={
<FormattedMessage
id='createAccount.accountDetails.name.hint'
defaultMessage='a descriptive name for the account'
/>
}
label={
<FormattedMessage
id='createAccount.accountDetails.name.label'
defaultMessage='account name'
/>
}
readOnly
value={ name }
/>
<InputAddress
disabled
hint='the network address for the account'
label='address'
hint={
<FormattedMessage
id='createAccount.accountDetails.address.hint'
defaultMessage='the network address for the account'
/>
}
label={
<FormattedMessage
id='createAccount.accountDetails.address.label'
defaultMessage='address'
/>
}
value={ address }
/>
{ this.renderPhrase() }
Expand All @@ -49,18 +70,28 @@ export default class AccountDetails extends Component {
}

renderPhrase () {
const { phrase } = this.props;
const { phrase } = this.props.store;

if (!phrase) {
return null;
}

return (
<Input
readOnly
allowCopy
hint='the account recovery phrase'
label='owner recovery phrase (keep private and secure, it allows full and unlimited access to the account)'
hint={
<FormattedMessage
id='createAccount.accountDetails.phrase.hint'
defaultMessage='the account recovery phrase'
/>
}
label={
<FormattedMessage
id='createAccount.accountDetails.phrase.label'
defaultMessage='owner recovery phrase (keep private and secure, it allows full and unlimited access to the account)'
/>
}
readOnly
value={ phrase }
/>
);
Expand Down
42 changes: 42 additions & 0 deletions js/src/modals/CreateAccount/AccountDetails/accountDetails.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity.

// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

import { shallow } from 'enzyme';
import React from 'react';

import { createStore } from '../createAccount.test.js';

import AccountDetails from './';

let component;
let store;

function render () {
store = createStore();
component = shallow(
<AccountDetails
store={ store }
/>
);

return component;
}

describe('modals/CreateAccount/AccountDetails', () => {
it('renders with defaults', () => {
expect(render()).to.be.ok;
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
/* You should have received a copy of the GNU General Public License
/* along with Parity. If not, see <http://www.gnu.org/licenses/>.
*/

.address {
color: #999;
padding-top: 1em;
line-height: 1.618em;
padding-left: 2em;
padding-top: 1em;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,46 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

import { observer } from 'mobx-react';
import React, { Component, PropTypes } from 'react';
import { FormattedMessage } from 'react-intl';

import styles from './accountDetailsGeth.css';

@observer
export default class AccountDetailsGeth extends Component {
static propTypes = {
addresses: PropTypes.array
store: PropTypes.object.isRequired
}

render () {
const { addresses } = this.props;

const formatted = addresses.map((address, idx) => {
const comma = !idx ? '' : ((idx === addresses.length - 1) ? ' & ' : ', ');

return `${comma}${address}`;
}).join('');
const { gethAddresses } = this.props.store;

return (
<div>
<div>You have imported { addresses.length } addresses from the Geth keystore:</div>
<div className={ styles.address }>{ formatted }</div>
<div>
<FormattedMessage
id='createAccount.accountDetailsGeth.imported'
defaultMessage='You have imported {number} addresses from the Geth keystore:'
values={ {
number: gethAddresses.length
} }
/>
</div>
<div className={ styles.address }>
{ this.formatAddresses(gethAddresses) }
</div>
</div>
);
}

formatAddresses (addresses) {
return addresses.map((address, index) => {
const comma = !index
? ''
: ((index === addresses.length - 1) ? ' & ' : ', ');

return `${comma}${address}`;
}).join('');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity.

// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

import { shallow } from 'enzyme';
import React from 'react';

import { createStore } from '../createAccount.test.js';

import AccountDetailsGeth from './';

let component;
let store;

function render () {
store = createStore();
component = shallow(
<AccountDetailsGeth
store={ store }
/>
);

return component;
}

describe('modals/CreateAccount/AccountDetailsGeth', () => {
it('renders with defaults', () => {
expect(render()).to.be.ok;
});

describe('utility', () => {
describe('formatAddresses', () => {
let instance;

beforeEach(() => {
instance = component.instance();
});

it('renders a single item', () => {
expect(instance.formatAddresses(['one'])).to.equal('one');
});

it('renders multiple items', () => {
expect(instance.formatAddresses(['one', 'two', 'three'])).to.equal('one, two & three');
});
});
});
});
59 changes: 46 additions & 13 deletions js/src/modals/CreateAccount/CreationType/creationType.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,50 +14,81 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

import { observer } from 'mobx-react';
import React, { Component, PropTypes } from 'react';
import { FormattedMessage } from 'react-intl';
import { RadioButton, RadioButtonGroup } from 'material-ui/RadioButton';

import styles from '../createAccount.css';

@observer
export default class CreationType extends Component {
static propTypes = {
onChange: PropTypes.func.isRequired
}

componentWillMount () {
this.props.onChange('fromNew');
store: PropTypes.object.isRequired
}

render () {
const { createType } = this.props.store;

return (
<div className={ styles.spaced }>
<RadioButtonGroup
defaultSelected='fromNew'
defaultSelected={ createType }
name='creationType'
onChange={ this.onChange }
>
<RadioButton
label='Create new account manually'
label={
<FormattedMessage
id='createAccount.creationType.fromNew.label'
defaultMessage='Create new account manually'
/>
}
value='fromNew'
/>
<RadioButton
label='Recover account from recovery phrase'
label={
<FormattedMessage
id='createAccount.creationType.fromPhrase.label'
defaultMessage='Recover account from recovery phrase'
/>
}
value='fromPhrase'
/>
<RadioButton
label='Import accounts from Geth keystore'
label={
<FormattedMessage
id='createAccount.creationType.fromGeth.label'
defaultMessage='Import accounts from Geth keystore'
/>
}
value='fromGeth'
/>
<RadioButton
label='Import account from a backup JSON file'
label={
<FormattedMessage
id='createAccount.creationType.fromJSON.label'
defaultMessage='Import account from a backup JSON file'
/>
}
value='fromJSON'
/>
<RadioButton
label='Import account from an Ethereum pre-sale wallet'
label={
<FormattedMessage
id='createAccount.creationType.fromPresale.label'
defaultMessage='Import account from an Ethereum pre-sale wallet'
/>
}
value='fromPresale'
/>
<RadioButton
label='Import raw private key'
label={
<FormattedMessage
id='createAccount.creationType.fromRaw.label'
defaultMessage='Import raw private key'
/>
}
value='fromRaw'
/>
</RadioButtonGroup>
Expand All @@ -66,6 +97,8 @@ export default class CreationType extends Component {
}

onChange = (event) => {
this.props.onChange(event.target.value);
const { store } = this.props;

store.setCreateType(event.target.value);
}
}
Loading