You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
2.5 KiB
81 lines
2.5 KiB
4 years ago
|
import PropTypes from 'prop-types';
|
||
|
import React, { PureComponent } from 'react';
|
||
|
import Popover from '../../components/ui/popover';
|
||
|
import ConnectedAccountsList from '../../components/app/connected-accounts-list';
|
||
|
import ConnectedAccountsPermissions from '../../components/app/connected-accounts-permissions';
|
||
5 years ago
|
|
||
|
export default class ConnectedAccounts extends PureComponent {
|
||
|
static contextTypes = {
|
||
|
t: PropTypes.func.isRequired,
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
|
static defaultProps = {
|
||
|
accountToConnect: null,
|
||
|
permissions: undefined,
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
|
static propTypes = {
|
||
|
accountToConnect: PropTypes.object,
|
||
|
activeTabOrigin: PropTypes.string.isRequired,
|
||
5 years ago
|
connectAccount: PropTypes.func.isRequired,
|
||
5 years ago
|
connectedAccounts: PropTypes.array.isRequired,
|
||
5 years ago
|
mostRecentOverviewPage: PropTypes.string.isRequired,
|
||
5 years ago
|
permissions: PropTypes.array,
|
||
5 years ago
|
isActiveTabExtension: PropTypes.bool.isRequired,
|
||
5 years ago
|
selectedAddress: PropTypes.string.isRequired,
|
||
|
removePermittedAccount: PropTypes.func.isRequired,
|
||
|
setSelectedAddress: PropTypes.func.isRequired,
|
||
|
history: PropTypes.object.isRequired,
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
4 years ago
|
render() {
|
||
5 years ago
|
const {
|
||
|
accountToConnect,
|
||
|
activeTabOrigin,
|
||
5 years ago
|
isActiveTabExtension,
|
||
5 years ago
|
connectAccount,
|
||
5 years ago
|
connectedAccounts,
|
||
|
history,
|
||
5 years ago
|
mostRecentOverviewPage,
|
||
5 years ago
|
permissions,
|
||
|
selectedAddress,
|
||
|
removePermittedAccount,
|
||
|
setSelectedAddress,
|
||
4 years ago
|
} = this.props;
|
||
|
const { t } = this.context;
|
||
5 years ago
|
|
||
4 years ago
|
const connectedAccountsDescription =
|
||
|
connectedAccounts.length > 1
|
||
|
? t('connectedAccountsDescriptionPlural', [connectedAccounts.length])
|
||
4 years ago
|
: t('connectedAccountsDescriptionSingular');
|
||
5 years ago
|
|
||
|
return (
|
||
|
<Popover
|
||
4 years ago
|
title={
|
||
|
isActiveTabExtension
|
||
|
? t('currentExtension')
|
||
|
: new URL(activeTabOrigin).host
|
||
|
}
|
||
|
subtitle={
|
||
|
connectedAccounts.length
|
||
|
? connectedAccountsDescription
|
||
|
: t('connectedAccountsEmptyDescription')
|
||
|
}
|
||
5 years ago
|
onClose={() => history.push(mostRecentOverviewPage)}
|
||
5 years ago
|
footerClassName="connected-accounts__footer"
|
||
5 years ago
|
footer={<ConnectedAccountsPermissions permissions={permissions} />}
|
||
5 years ago
|
>
|
||
|
<ConnectedAccountsList
|
||
|
accountToConnect={accountToConnect}
|
||
5 years ago
|
connectAccount={connectAccount}
|
||
5 years ago
|
connectedAccounts={connectedAccounts}
|
||
|
selectedAddress={selectedAddress}
|
||
|
removePermittedAccount={removePermittedAccount}
|
||
|
setSelectedAddress={setSelectedAddress}
|
||
5 years ago
|
shouldRenderListOptions
|
||
5 years ago
|
/>
|
||
|
</Popover>
|
||
4 years ago
|
);
|
||
5 years ago
|
}
|
||
|
}
|