show certifications in accounts list

This commit is contained in:
Jannis R 2016-12-09 00:34:28 +01:00
parent 5862f2a9eb
commit a84cd9143f
No known key found for this signature in database
GPG Key ID: 0FE83946296A88A5
2 changed files with 53 additions and 4 deletions

View File

@ -15,13 +15,16 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
import React, { Component, PropTypes } from 'react'; import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { Container } from '~/ui'; import { Container } from '~/ui';
import { fetchCertifiers, fetchCertifications } from '~/redux/providers/certifications/actions';
import Summary from '../Summary'; import Summary from '../Summary';
import styles from './list.css'; import styles from './list.css';
export default class List extends Component { class List extends Component {
static propTypes = { static propTypes = {
accounts: PropTypes.object, accounts: PropTypes.object,
walletsOwners: PropTypes.object, walletsOwners: PropTypes.object,
@ -31,7 +34,11 @@ export default class List extends Component {
empty: PropTypes.bool, empty: PropTypes.bool,
order: PropTypes.string, order: PropTypes.string,
orderFallback: PropTypes.string, orderFallback: PropTypes.string,
handleAddSearchToken: PropTypes.func certifications: PropTypes.object.isRequired,
handleAddSearchToken: PropTypes.func,
fetchCertifiers: PropTypes.func.isRequired,
fetchCertifications: PropTypes.func.isRequired
}; };
render () { render () {
@ -42,6 +49,14 @@ export default class List extends Component {
); );
} }
componentWillMount () {
const { fetchCertifiers, accounts, fetchCertifications } = this.props;
fetchCertifiers();
for (let address in accounts) {
fetchCertifications(address);
}
}
renderAccounts () { renderAccounts () {
const { accounts, balances, link, empty, handleAddSearchToken, walletsOwners } = this.props; const { accounts, balances, link, empty, handleAddSearchToken, walletsOwners } = this.props;
@ -72,7 +87,9 @@ export default class List extends Component {
account={ account } account={ account }
balance={ balance } balance={ balance }
owners={ owners } owners={ owners }
handleAddSearchToken={ handleAddSearchToken } /> handleAddSearchToken={ handleAddSearchToken }
showCertifications
/>
</div> </div>
); );
}); });
@ -207,3 +224,20 @@ export default class List extends Component {
}); });
} }
} }
function mapStateToProps (state) {
const { certifications } = state;
return { certifications };
}
function mapDispatchToProps (dispatch) {
return bindActionCreators({
fetchCertifiers,
fetchCertifications
}, dispatch);
}
export default connect(
mapStateToProps,
mapDispatchToProps
)(List);

View File

@ -20,6 +20,7 @@ import { isEqual } from 'lodash';
import ReactTooltip from 'react-tooltip'; import ReactTooltip from 'react-tooltip';
import { Balance, Container, ContainerTitle, IdentityIcon, IdentityName, Tags, Input } from '~/ui'; import { Balance, Container, ContainerTitle, IdentityIcon, IdentityName, Tags, Input } from '~/ui';
import Certifications from '~/ui/Certifications';
import { nullableProptype } from '~/util/proptypes'; import { nullableProptype } from '~/util/proptypes';
import styles from '../accounts.css'; import styles from '../accounts.css';
@ -35,12 +36,14 @@ export default class Summary extends Component {
link: PropTypes.string, link: PropTypes.string,
name: PropTypes.string, name: PropTypes.string,
noLink: PropTypes.bool, noLink: PropTypes.bool,
showCertifications: PropTypes.bool,
handleAddSearchToken: PropTypes.func, handleAddSearchToken: PropTypes.func,
owners: nullableProptype(PropTypes.array) owners: nullableProptype(PropTypes.array)
}; };
static defaultProps = { static defaultProps = {
noLink: false noLink: false,
showCertifications: false
}; };
shouldComponentUpdate (nextProps) { shouldComponentUpdate (nextProps) {
@ -107,6 +110,7 @@ export default class Summary extends Component {
{ this.renderOwners() } { this.renderOwners() }
{ this.renderBalance() } { this.renderBalance() }
{ this.renderCertifications() }
</Container> </Container>
); );
} }
@ -172,4 +176,15 @@ export default class Summary extends Component {
<Balance balance={ balance } /> <Balance balance={ balance } />
); );
} }
renderCertifications () {
const { showCertifications, account } = this.props;
if (!showCertifications) {
return null;
}
return (
<Certifications account={ account.address } />
);
}
} }