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';
|
|
|
|
import React, { Component, PropTypes } from 'react';
|
|
|
|
import { FormattedMessage } from 'react-intl';
|
|
|
|
|
2017-05-12 12:06:16 +02:00
|
|
|
import { AccountCard, Portal, SelectionList } from '@parity/ui';
|
2016-12-27 16:23:41 +01:00
|
|
|
|
|
|
|
@observer
|
2017-06-14 17:12:13 +02:00
|
|
|
export default class DappAccounts extends Component {
|
2016-12-27 16:23:41 +01:00
|
|
|
static propTypes = {
|
2017-02-22 10:42:42 +01:00
|
|
|
permissionStore: PropTypes.object.isRequired
|
2016-12-27 16:23:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
render () {
|
2017-02-22 10:42:42 +01:00
|
|
|
const { permissionStore } = this.props;
|
2016-12-27 16:23:41 +01:00
|
|
|
|
2017-02-22 10:42:42 +01:00
|
|
|
if (!permissionStore.modalOpen) {
|
2016-12-27 16:23:41 +01:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2017-01-31 17:04:41 +01:00
|
|
|
<Portal
|
2017-02-22 10:42:42 +01:00
|
|
|
onClose={ permissionStore.closeModal }
|
2017-01-31 17:04:41 +01:00
|
|
|
open
|
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
|
|
|
|
items={ permissionStore.accounts }
|
|
|
|
noStretch
|
|
|
|
onDefaultClick={ this.onMakeDefault }
|
|
|
|
onSelectClick={ this.onSelect }
|
|
|
|
renderItem={ this.renderAccount }
|
|
|
|
/>
|
2017-01-31 17:04:41 +01:00
|
|
|
</Portal>
|
2016-12-27 16:23:41 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-02-24 14:37:56 +01:00
|
|
|
onMakeDefault = (account) => {
|
|
|
|
this.props.permissionStore.setDefaultAccount(account.address);
|
|
|
|
}
|
2017-01-31 17:04:41 +01:00
|
|
|
|
2017-02-24 14:37:56 +01:00
|
|
|
onSelect = (account) => {
|
|
|
|
this.props.permissionStore.selectAccount(account.address);
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|