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.
65 lines
1.9 KiB
65 lines
1.9 KiB
4 years ago
|
import { connect } from 'react-redux';
|
||
5 years ago
|
import {
|
||
|
getAccountToConnectToActiveTab,
|
||
|
getOrderedConnectedAccountsForActiveTab,
|
||
|
getPermissionsForActiveTab,
|
||
|
getSelectedAddress,
|
||
4 years ago
|
} from '../../selectors';
|
||
|
import { isExtensionUrl } from '../../helpers/utils/util';
|
||
4 years ago
|
import {
|
||
|
addPermittedAccount,
|
||
|
removePermittedAccount,
|
||
|
setSelectedAddress,
|
||
4 years ago
|
} from '../../store/actions';
|
||
|
import { getMostRecentOverviewPage } from '../../ducks/history/history';
|
||
|
import ConnectedAccounts from './connected-accounts.component';
|
||
5 years ago
|
|
||
|
const mapStateToProps = (state) => {
|
||
4 years ago
|
const { activeTab } = state;
|
||
|
const accountToConnect = getAccountToConnectToActiveTab(state);
|
||
|
const connectedAccounts = getOrderedConnectedAccountsForActiveTab(state);
|
||
|
const permissions = getPermissionsForActiveTab(state);
|
||
|
const selectedAddress = getSelectedAddress(state);
|
||
5 years ago
|
|
||
4 years ago
|
const isActiveTabExtension = isExtensionUrl(activeTab);
|
||
5 years ago
|
return {
|
||
|
accountToConnect,
|
||
5 years ago
|
isActiveTabExtension,
|
||
5 years ago
|
activeTabOrigin: activeTab.origin,
|
||
|
connectedAccounts,
|
||
5 years ago
|
mostRecentOverviewPage: getMostRecentOverviewPage(state),
|
||
5 years ago
|
permissions,
|
||
|
selectedAddress,
|
||
4 years ago
|
};
|
||
|
};
|
||
5 years ago
|
|
||
|
const mapDispatchToProps = (dispatch) => {
|
||
|
return {
|
||
4 years ago
|
addPermittedAccount: (origin, address) =>
|
||
|
dispatch(addPermittedAccount(origin, address)),
|
||
|
removePermittedAccount: (origin, address) =>
|
||
|
dispatch(removePermittedAccount(origin, address)),
|
||
5 years ago
|
setSelectedAddress: (address) => dispatch(setSelectedAddress(address)),
|
||
4 years ago
|
};
|
||
|
};
|
||
5 years ago
|
|
||
|
const mergeProps = (stateProps, dispatchProps, ownProps) => {
|
||
4 years ago
|
const { activeTabOrigin } = stateProps;
|
||
5 years ago
|
|
||
|
return {
|
||
|
...ownProps,
|
||
|
...stateProps,
|
||
|
...dispatchProps,
|
||
4 years ago
|
connectAccount: (address) =>
|
||
|
dispatchProps.addPermittedAccount(activeTabOrigin, address),
|
||
|
removePermittedAccount: (address) =>
|
||
|
dispatchProps.removePermittedAccount(activeTabOrigin, address),
|
||
4 years ago
|
};
|
||
|
};
|
||
5 years ago
|
|
||
4 years ago
|
export default connect(
|
||
|
mapStateToProps,
|
||
|
mapDispatchToProps,
|
||
|
mergeProps,
|
||
4 years ago
|
)(ConnectedAccounts);
|