diff --git a/js/src/modals/AddAddress/addAddress.js b/js/src/modals/AddAddress/addAddress.js
index 177223290..437b87663 100644
--- a/js/src/modals/AddAddress/addAddress.js
+++ b/js/src/modals/AddAddress/addAddress.js
@@ -14,31 +14,29 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see .
-import React, { Component, PropTypes } from 'react';
import ContentAdd from 'material-ui/svg-icons/content/add';
import ContentClear from 'material-ui/svg-icons/content/clear';
+import { observer } from 'mobx-react';
+import React, { Component, PropTypes } from 'react';
+import { FormattedMessage } from 'react-intl';
-import { Button, Modal, Form, Input, InputAddress } from '~/ui';
-import { ERRORS, validateAddress, validateName } from '~/util/validation';
+import { Button, Form, Input, InputAddress, Modal } from '~/ui';
+import Store from './store';
+
+@observer
export default class AddAddress extends Component {
static contextTypes = {
api: PropTypes.object.isRequired
}
static propTypes = {
- contacts: PropTypes.object.isRequired,
address: PropTypes.string,
- onClose: PropTypes.func
+ contacts: PropTypes.object.isRequired,
+ onClose: PropTypes.func.isRequired
};
- state = {
- address: '',
- addressError: ERRORS.invalidAddress,
- name: '',
- nameError: ERRORS.invalidName,
- description: ''
- };
+ store = new Store(this.context.api, this.props.contacts);
componentWillMount () {
if (this.props.address) {
@@ -49,109 +47,113 @@ export default class AddAddress extends Component {
render () {
return (
+ title={
+
+ }
+ visible>
{ this.renderFields() }
);
}
renderDialogActions () {
- const { addressError, nameError } = this.state;
- const hasError = !!(addressError || nameError);
+ const { hasError } = this.store;
return ([
}
- label='Cancel'
- onClick={ this.onClose } />,
+ label={
+
+ }
+ onClick={ this.onClose }
+ ref='closeButton' />,
}
- label='Save Address'
disabled={ hasError }
- onClick={ this.onAdd } />
+ icon={ }
+ label={
+
+ }
+ onClick={ this.onAdd }
+ ref='addButton' />
]);
}
renderFields () {
- const { address, addressError, description, name, nameError } = this.state;
+ const { address, addressError, description, name, nameError } = this.store;
return (
diff --git a/js/src/ui/Form/InputAddress/inputAddress.js b/js/src/ui/Form/InputAddress/inputAddress.js
index 1f062382a..e2a0707d5 100644
--- a/js/src/ui/Form/InputAddress/inputAddress.js
+++ b/js/src/ui/Form/InputAddress/inputAddress.js
@@ -18,28 +18,30 @@ import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
-import Input from '../Input';
-import IdentityIcon from '../../IdentityIcon';
import util from '~/api/util';
+import { nodeOrStringProptype } from '~/util/proptypes';
+
+import IdentityIcon from '../../IdentityIcon';
+import Input from '../Input';
import styles from './inputAddress.css';
class InputAddress extends Component {
static propTypes = {
+ accountsInfo: PropTypes.object,
+ allowCopy: PropTypes.bool,
className: PropTypes.string,
disabled: PropTypes.bool,
error: PropTypes.string,
- label: PropTypes.string,
- hint: PropTypes.string,
- value: PropTypes.string,
- accountsInfo: PropTypes.object,
- tokens: PropTypes.object,
- text: PropTypes.bool,
+ hideUnderline: PropTypes.bool,
+ hint: nodeOrStringProptype(),
+ label: nodeOrStringProptype(),
onChange: PropTypes.func,
onSubmit: PropTypes.func,
- hideUnderline: PropTypes.bool,
- allowCopy: PropTypes.bool,
- small: PropTypes.bool
+ small: PropTypes.bool,
+ text: PropTypes.bool,
+ tokens: PropTypes.object,
+ value: PropTypes.string
};
static defaultProps = {
@@ -49,8 +51,8 @@ class InputAddress extends Component {
};
render () {
- const { className, disabled, error, label, hint, value, text } = this.props;
- const { small, allowCopy, hideUnderline, onSubmit, accountsInfo, tokens } = this.props;
+ const { className, disabled, error, hint, label, text, value } = this.props;
+ const { accountsInfo, allowCopy, hideUnderline, onSubmit, small, tokens } = this.props;
const account = accountsInfo[value] || tokens[value];
@@ -68,17 +70,20 @@ class InputAddress extends Component {
return (
+ value={
+ text && account
+ ? account.name
+ : value
+ } />
{ icon }
);
@@ -128,8 +133,8 @@ class InputAddress extends Component {
}
function mapStateToProps (state) {
- const { accountsInfo } = state.personal;
const { tokens } = state.balances;
+ const { accountsInfo } = state.personal;
return {
accountsInfo,
diff --git a/js/src/ui/Modal/modal.js b/js/src/ui/Modal/modal.js
index fd8e67aad..f72c3ffb1 100644
--- a/js/src/ui/Modal/modal.js
+++ b/js/src/ui/Modal/modal.js
@@ -42,11 +42,11 @@ class Modal extends Component {
className: PropTypes.string,
compact: PropTypes.bool,
current: PropTypes.number,
- waiting: PropTypes.array,
+ settings: PropTypes.object.isRequired,
steps: PropTypes.array,
title: nodeOrStringProptype(),
visible: PropTypes.bool.isRequired,
- settings: PropTypes.object.isRequired
+ waiting: PropTypes.array
}
render () {
@@ -55,23 +55,23 @@ class Modal extends Component {
const contentStyle = muiTheme.parity.getBackgroundStyle(null, settings.backgroundSeed);
const header = (
+ title={ title }
+ waiting={ waiting } />
);
const classes = `${styles.dialog} ${className}`;
return (
diff --git a/js/test/mocha.config.js b/js/test/mocha.config.js
index e90c91ebf..3201cd4ac 100644
--- a/js/test/mocha.config.js
+++ b/js/test/mocha.config.js
@@ -15,11 +15,13 @@
// along with Parity. If not, see
.
import 'isomorphic-fetch';
+import 'mock-local-storage';
import es6Promise from 'es6-promise';
es6Promise.polyfill();
-import 'mock-local-storage';
+import injectTapEventPlugin from 'react-tap-event-plugin';
+injectTapEventPlugin();
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';