1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/ui/components/app/account-menu/account-menu.container.js
Albert Olivé ebc887021e
[MMI] Added code fences for account menu (#17965)
* Added code fences for account menu

* updates test and messages json

* clean up

* icons

* icons color correct

* icon size fix

* icon size fix

* adds mmi entries and updates to the new IconName

* clean up

* lint

* clean up

* prettier

* prettier

* camel case

---------

Co-authored-by: Antonio Regadas <antonio.regadas@consensys.net>
Co-authored-by: António Regadas <apregadas@gmail.com>
2023-05-17 16:58:00 +02:00

82 lines
2.3 KiB
JavaScript

import { connect } from 'react-redux';
import { compose } from 'redux';
import { withRouter } from 'react-router-dom';
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
import {
getMmiPortfolioEnabled,
getMmiPortfolioUrl,
getCustodyAccountDetails,
} from '../../../selectors/institutional/selectors';
///: END:ONLY_INCLUDE_IN
import {
toggleAccountMenu,
setSelectedAccount,
lockMetamask,
hideWarning,
} from '../../../store/actions';
import {
getAddressConnectedSubjectMap,
getMetaMaskAccountsOrdered,
getMetaMaskKeyrings,
getOriginOfCurrentTab,
getSelectedAddress,
///: BEGIN:ONLY_INCLUDE_IN(snaps)
getUnreadNotificationsCount,
///: END:ONLY_INCLUDE_IN
} from '../../../selectors';
import AccountMenu from './account-menu.component';
/**
* The min amount of accounts to show search field
*/
const SHOW_SEARCH_ACCOUNTS_MIN_COUNT = 5;
function mapStateToProps(state) {
const {
metamask: { isAccountMenuOpen },
} = state;
const accounts = getMetaMaskAccountsOrdered(state);
const origin = getOriginOfCurrentTab(state);
const selectedAddress = getSelectedAddress(state);
///: BEGIN:ONLY_INCLUDE_IN(snaps)
const unreadNotificationsCount = getUnreadNotificationsCount(state);
///: END:ONLY_INCLUDE_IN
return {
isAccountMenuOpen,
addressConnectedSubjectMap: getAddressConnectedSubjectMap(state),
originOfCurrentTab: origin,
selectedAddress,
keyrings: getMetaMaskKeyrings(state),
accounts,
shouldShowAccountsSearch: accounts.length >= SHOW_SEARCH_ACCOUNTS_MIN_COUNT,
///: BEGIN:ONLY_INCLUDE_IN(snaps)
unreadNotificationsCount,
///: END:ONLY_INCLUDE_IN
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
mmiPortfolioUrl: getMmiPortfolioUrl(state),
mmiPortfolioEnabled: getMmiPortfolioEnabled(state),
custodyAccountDetails: getCustodyAccountDetails(state),
///: END:ONLY_INCLUDE_IN
};
}
function mapDispatchToProps(dispatch) {
return {
toggleAccountMenu: () => dispatch(toggleAccountMenu()),
setSelectedAccount: (address) => {
dispatch(setSelectedAccount(address));
dispatch(toggleAccountMenu());
},
lockMetamask: () => {
dispatch(lockMetamask());
dispatch(hideWarning());
dispatch(toggleAccountMenu());
},
};
}
export default compose(
withRouter,
connect(mapStateToProps, mapDispatchToProps),
)(AccountMenu);