2017-01-25 18:51:41 +01:00
|
|
|
// Copyright 2015-2017 Parity Technologies (UK) Ltd.
|
2016-12-27 16:23:41 +01:00
|
|
|
// 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 { observer } from 'mobx-react';
|
2017-07-17 18:37:33 +02:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2016-12-27 16:23:41 +01:00
|
|
|
import { FormattedMessage } from 'react-intl';
|
|
|
|
|
2017-07-10 17:03:16 +02:00
|
|
|
import { AccountCard, Page, SelectionList } from '@parity/ui';
|
|
|
|
|
|
|
|
import Store from './store';
|
2016-12-27 16:23:41 +01:00
|
|
|
|
|
|
|
@observer
|
2017-07-10 17:03:16 +02:00
|
|
|
export default class DappAccounts extends Component {
|
|
|
|
static contextTypes = {
|
|
|
|
api: PropTypes.object.isRequired
|
2016-12-27 16:23:41 +01:00
|
|
|
};
|
|
|
|
|
2017-07-10 17:03:16 +02:00
|
|
|
store = new Store(this.context.api);
|
2016-12-27 16:23:41 +01:00
|
|
|
|
2017-07-10 17:03:16 +02:00
|
|
|
render () {
|
2016-12-27 16:23:41 +01:00
|
|
|
return (
|
2017-07-10 17:03:16 +02:00
|
|
|
<Page
|
2017-02-03 22:44:43 +01:00
|
|
|
title={
|
|
|
|
<FormattedMessage
|
2017-06-14 17:12:13 +02:00
|
|
|
id='dapps.accounts.label'
|
2017-02-03 22:44:43 +01:00
|
|
|
defaultMessage='visible dapp accounts'
|
|
|
|
/>
|
|
|
|
}
|
2017-01-31 17:04:41 +01:00
|
|
|
>
|
2017-02-24 14:37:56 +01:00
|
|
|
<SelectionList
|
2017-07-10 17:03:16 +02:00
|
|
|
items={ this.store.accounts }
|
2017-02-24 14:37:56 +01:00
|
|
|
noStretch
|
|
|
|
onDefaultClick={ this.onMakeDefault }
|
|
|
|
onSelectClick={ this.onSelect }
|
|
|
|
renderItem={ this.renderAccount }
|
|
|
|
/>
|
2017-07-10 17:03:16 +02:00
|
|
|
</Page>
|
2016-12-27 16:23:41 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-02-24 14:37:56 +01:00
|
|
|
onMakeDefault = (account) => {
|
2017-07-10 17:03:16 +02:00
|
|
|
this.store.setDefaultAccount(account.address);
|
2017-02-24 14:37:56 +01:00
|
|
|
}
|
2017-01-31 17:04:41 +01:00
|
|
|
|
2017-02-24 14:37:56 +01:00
|
|
|
onSelect = (account) => {
|
2017-07-10 17:03:16 +02:00
|
|
|
this.store.selectAccount(account.address);
|
2017-02-24 14:37:56 +01:00
|
|
|
}
|
2017-01-31 17:04:41 +01:00
|
|
|
|
2017-02-24 14:37:56 +01:00
|
|
|
renderAccount = (account) => {
|
2017-01-31 17:04:41 +01:00
|
|
|
return (
|
2017-02-24 14:37:56 +01:00
|
|
|
<AccountCard
|
|
|
|
account={ account }
|
|
|
|
/>
|
2017-01-31 17:04:41 +01:00
|
|
|
);
|
2016-12-27 16:23:41 +01:00
|
|
|
}
|
|
|
|
}
|