Newer
Older
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
//
import { AccountCard, Clickable, Header } from 'fether-ui';
import { chainId$, withoutLoading } from '@parity/light.js';
import light from '@parity/light.js-react';
import Feedback from './Feedback';
import withAccountsInfo from '../../utils/withAccountsInfo';
@light({
chainId: () => chainId$().pipe(withoutLoading())
})
@observer
class AccountsList extends Component {
handleClick = ({
currentTarget: {
dataset: { address }
}
}) => {
const { accountsInfo, chainId } = this.props;
const accountsList = Object.keys(accountsInfo).filter(
key =>
!accountsInfo[key].chainId ||
accountsInfo[key].chainId === parseInt(chainId, 10)
Luke Schoen
committed
const accountsListLength = accountsList && accountsList.length;
<Clickable
className='icon -new'
onClick={this.handleCreateAccount}
/>
Luke Schoen
committed
title={<h1>Accounts</h1>}
Luke Schoen
committed
{accountsListLength ? (
key={address}
data-address={address} // Using data- to avoid creating a new item Component
onClick={this.handleClick}
>
<AccountCard
address={address}
className='-clickable'
type={accountsInfo[address].type}
name={accountsInfo[address].name || '(no name)'}
Luke Schoen
committed
screen='accounts'
) : (
<p className='create-hint'>
Nothing here yet!
<br />
<br />
Click the + icon to add a new account.
</p>
)}
Luke Schoen
committed
<div className='footer-feedback'>
Luke Schoen
committed
<Feedback accountsListLength={accountsListLength} />
Luke Schoen
committed
</div>
</nav>
</div>
);
}
}
export default AccountsList;