Fix wallet view (#6597)

* Add safe fail for empty logs

* Filter transactions

* Add more logging

* Fix Wallet Creation and wallet tx list

* Remove logs

* Prevent selecting twice same wallet owner

* Fix tests

* Remove unused props

* Remove unused props
This commit is contained in:
Nicolas Gotchac
2017-10-09 13:11:18 +02:00
committed by Arkadiy Paronyan
parent 65ca2f9a07
commit 8d1964bc3b
17 changed files with 221 additions and 82 deletions

View File

@@ -14,6 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
import { eq } from 'lodash';
import React, { Component, PropTypes } from 'react';
import ReactDOM from 'react-dom';
import { connect } from 'react-redux';
@@ -93,6 +94,18 @@ class AddressSelect extends Component {
}
componentWillReceiveProps (nextProps) {
if (!eq(Object.keys(this.props.accounts), Object.keys(nextProps.accounts))) {
return this.setValues(nextProps);
}
if (!eq(Object.keys(this.props.contacts), Object.keys(nextProps.contacts))) {
return this.setValues(nextProps);
}
if (!eq(Object.keys(this.props.contracts), Object.keys(nextProps.contracts))) {
return this.setValues(nextProps);
}
if (this.store.values && this.store.values.length > 0) {
return;
}

View File

@@ -165,7 +165,8 @@ export default class AddressSelectStore {
const contactsN = Object.keys(contacts).length;
if (accountsN + contractsN + contactsN === 0) {
return;
this.initValues = [];
return this.handleChange();
}
this.initValues = [

View File

@@ -14,6 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
import { pick } from 'lodash';
import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
@@ -28,6 +29,7 @@ class InputAddressSelect extends Component {
contracts: PropTypes.object.isRequired,
allowCopy: PropTypes.bool,
allowedValues: PropTypes.array,
className: PropTypes.string,
error: nodeOrStringProptype(),
hint: nodeOrStringProptype(),
@@ -38,16 +40,33 @@ class InputAddressSelect extends Component {
};
render () {
const { accounts, allowCopy, className, contacts, contracts, label, hint, error, value, onChange, readOnly } = this.props;
const { accounts, allowCopy, allowedValues, className, contacts, contracts, label, hint, error, value, onChange, readOnly } = this.props;
// Add the currently selected value to the list
// of allowed values, if any given
const nextAllowedValues = allowedValues
? [].concat(allowedValues, value || [])
: null;
const filteredAccounts = nextAllowedValues
? pick(accounts, nextAllowedValues)
: accounts;
const filteredContacts = nextAllowedValues
? pick(contacts, nextAllowedValues)
: accounts;
const filteredContracts = nextAllowedValues
? pick(contracts, nextAllowedValues)
: accounts;
return (
<AddressSelect
allowCopy={ allowCopy }
allowInput
accounts={ accounts }
accounts={ filteredAccounts }
className={ className }
contacts={ contacts }
contracts={ contracts }
contacts={ filteredContacts }
contracts={ filteredContracts }
error={ error }
hint={ hint }
label={ label }

View File

@@ -40,8 +40,8 @@ export default class TypedInput extends Component {
PropTypes.string
]).isRequired,
accounts: PropTypes.object,
allowCopy: PropTypes.bool,
allowedValues: PropTypes.array,
className: PropTypes.string,
error: PropTypes.any,
hint: nodeOrStringProptype(),
@@ -97,7 +97,7 @@ export default class TypedInput extends Component {
const { type } = param;
if (type === ABI_TYPES.ARRAY) {
const { accounts, className, label } = this.props;
const { allowedValues, className, label } = this.props;
const { subtype, length } = param;
const value = this.getValue() || param.default;
@@ -113,8 +113,8 @@ export default class TypedInput extends Component {
return (
<TypedInput
accounts={ accounts }
allowCopy={ allowCopy }
allowedValues={ allowedValues }
className={ className }
key={ `${subtype.type}_${index}` }
onChange={ onChange }
@@ -340,13 +340,13 @@ export default class TypedInput extends Component {
}
renderAddress () {
const { accounts, allowCopy, className, label, error, hint, readOnly } = this.props;
const { allowCopy, allowedValues, className, label, error, hint, readOnly } = this.props;
const value = this.getValue();
return (
<InputAddressSelect
allowCopy={ allowCopy }
accounts={ accounts }
allowedValues={ allowedValues }
className={ className }
error={ error }
hint={ hint }