1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 18:00:18 +01:00
metamask-extension/ui/pages/home/home.component.js

1015 lines
34 KiB
JavaScript
Raw Normal View History

import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { Redirect, Route } from 'react-router-dom';
import {
///: BEGIN:ONLY_INCLUDE_IN(build-main)
MetaMetricsContextProp,
///: END:ONLY_INCLUDE_IN
MetaMetricsEventCategory,
MetaMetricsEventName,
} from '../../../shared/constants/metametrics';
import AssetList from '../../components/app/asset-list';
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
import NftsTab from '../../components/app/nfts-tab';
import TermsOfUsePopup from '../../components/app/terms-of-use-popup';
import RecoveryPhraseReminder from '../../components/app/recovery-phrase-reminder';
///: END:ONLY_INCLUDE_IN
import HomeNotification from '../../components/app/home-notification';
import MultipleNotifications from '../../components/app/multiple-notifications';
import TransactionList from '../../components/app/transaction-list';
import Popover from '../../components/ui/popover';
import Button from '../../components/ui/button';
import ConnectedSites from '../connected-sites';
import ConnectedAccounts from '../connected-accounts';
import { Tabs, Tab } from '../../components/ui/tabs';
import { EthOverview } from '../../components/app/wallet-overview';
Whats new popup (#10583) * Add 'What's New' notification popup * Move selectors from shared/notifications into ui/ directory * Use keys for localized message in whats new notifications objects, to ensure notifications will be translated. * Remove unused swaps intro popup locale messages * Fix keys of whats new notification locales * Remove notifications messages and descriptions from comment in shared/notifications * Move notifcationActionFunctions to shared/notifications and make it stateless * Get notification data from constants instead of state in whats-new-popup * Code cleanup * Fix build quote reference to swapsEthToken, broken during rebase * Rename notificationFilters to notificationToExclude to clarify its purpose * Documentation for getSortedNotificationsToShow * Move notification action functions from shared/ to whats-new-popup.js * Stop setting swapsWelcomeMessageHasBeenShown to state in app-state controller * Update e2e tests for whats new popup changes * Updating migration files * Addressing feedback part 1 * Addressing feedback part 2 * Remove unnecessary div in whats-new-popup * Change getNotificationsToExclude to getNotificationsToInclude for use in the getSortedNotificationsToShow selector * Delete intro-popup directory and test files * Lint fix * Add notifiction state to address-entry fixture * Use two separate functions for rendering first and subsequent notifications in the whats-new-popup * Ensure that string literals are passed to t for whats new popup text * Update import-ui fixtures to include notificaiton controller state * Remove unnecessary, accidental change confirm-approve * Remove swaps notification in favour of mobile swaps as first notifcation and TBD 3rd notification * Update whats-new-popup to use intersection observer api to detect if notification has been seen * Add notifications to send-edit and threebox e2e test fixtures * Update ui/app/selectors/selectors.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Update ui/app/selectors/selectors.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Clean up locale code for whats-new-popup notifications * Disconnect observers in whats-new-popup when their callback is first called * Add test case for migration 58 for when the AppStateController does not exist * Rename popover components containerRef to popoverWrapRef * Fix messages.json * Update notification messages and images * Rename popoverWrapRef -> popoverRef in whats-new-popup and popover.component * Only create one observer, and only after images have loaded, in whats-new-popup * Set width and height on whats-new-popup image, instead of setting state on img load * Update ui/app/components/app/whats-new-popup/whats-new-popup.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Code clean up in whats new popup re: notification rendering and action functions * Code cleanup in render notification functions of whats-new-popup * Update ui/app/components/app/whats-new-popup/whats-new-popup.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * lint fix * Update and localize notification dates * Clean up date code in shred/notifications/index.js Co-authored-by: ryanml <ryanlanese@gmail.com> Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-04-28 18:51:41 +02:00
import WhatsNewPopup from '../../components/app/whats-new-popup';
import ActionableMessage from '../../components/ui/actionable-message/actionable-message';
import {
FontWeight,
Display,
TextColor,
TextVariant,
///: BEGIN:ONLY_INCLUDE_IN(build-main)
Size,
///: END:ONLY_INCLUDE_IN
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-mmi)
JustifyContent,
///: END:ONLY_INCLUDE_IN
} from '../../helpers/constants/design-system';
import { SECOND } from '../../../shared/constants/time';
2023-02-27 17:42:02 +01:00
import {
ButtonIcon,
ButtonIconSize,
IconName,
Box,
///: BEGIN:ONLY_INCLUDE_IN(build-main)
ButtonLink,
///: END:ONLY_INCLUDE_IN
Text,
} from '../../components/component-library';
2018-09-27 20:19:09 +02:00
import {
ASSET_ROUTE,
RESTORE_VAULT_ROUTE,
CONFIRM_TRANSACTION_ROUTE,
2018-08-28 20:20:30 +02:00
CONFIRM_ADD_SUGGESTED_TOKEN_ROUTE,
CONFIRM_ADD_SUGGESTED_NFT_ROUTE,
Connect distinct accounts per site (#7004) * add PermissionsController remove provider approval controller integrate rpc-cap create PermissionsController move provider approval functionality to permissions controller add permissions approval ui, settings page add permissions activity and history move some functionality to metamask-inpage-provider rename siteMetadata -> domainMetadata add accountsChange notification to inpage provider move functionality to inpage provider update inpage provider Remove 'Connections' settings page (#7369) add hooks for exposing accounts in settings rename unused messages in non-English locales Add external extension id to metadata (#7396) update inpage provider, rpc-cap add eth_requestAccounts handling to background prevent notifying connections if extension is locked update inpage provider Fix lint errors add migration review fixes transaction controller review updates removed unused messages * Login Per Site UI (#7368) * LoginPerSite original UI changes to keep * First commit * Get necessary connected tab info for redirect and icon display for permissioned sites * Fix up designs and add missing features * Some lint fixes * More lint fixes * Ensures the tx controller + tx-state-manager orders transactions in the order they are received * Code cleanup for LoginPerSite-ui * Update e2e tests to use new connection flow * Fix display of connect screen and app header after login when connect request present * Update metamask-responsive-ui.spec for new item in accounts dropdown * Fix approve container by replacing approvedOrigins with domainMetaData * Adds test/e2e/permissions.spec.js * Correctly handle cancellation of a permissions request * Redirect to home after disconnecting all sites / cancelling all permissions * Fix display of site icons in menu * Fix height of permissions page container * Remove unused locale messages * Set default values for openExternalTabs and tabIdOrigins in account-menu.container * More code cleanup for LoginPerSite-ui * Use extensions api to close tab in permissions-connect * Remove unnecessary change in domIsReady() in contentscript * Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller. * Adds getOriginOfCurrentTab selector * Adds IconWithFallback component and substitutes for appropriate cases * Add and utilize font mixins * Remove unused method in disconnect-all.container.js * Simplify buttonSizeLarge code in page-container-footer.component.js * Add and utilize getAccountsWithLabels selector * Remove console.log in ui/app/store/actions.js * Change last connected time format to yyyy-M-d * Fix css associated with IconWithFallback change * Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes * Code cleanup for LoginPerSite-ui * Use reusable function for modifying openNonMetamaskTabsIDs in background.js * Enables automatic switching to connected account when connected domain is open * Prevent exploit of tabIdOriginMap in background.js * Remove unneeded code from contentscript.js * Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs * Design and styling fixes for LoginPerSite-ui * Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts * Front end changes to support display of lastConnected time in connected and permissions screens * Fix lint errors * Refactor structure of permissionsHistory * Fix default values and object modifications for domain and permissionsHistory related data * Fix connecting to new accounts from modal * Replace retweet.svg with connect-white.svg * Fix signature-request.spec * Update metamask-inpage-provider version * Fix permissions e2e tests * Remove unneeded delay from test/e2e/signature-request.spec.js * Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec * Use requestAccountTabIds strategy for determining tab id that opened a given window * Improve default values for permissions requests * Add some message descriptions to app/_locales/en/messages.json * Code clean up in permission controller * Stopped deep cloning object in mapObjectValues * Bump metamask-inpage-provider version * Add missing description in app/_locales/en/messages.json * Return promises from queryTabs and switchToTab of extension.js * Remove unused getAllPermissions function * Use default props in icon-with-fallback.component.js * Stop passing to permissions controller * Delete no longer used clear-approved-origins modal code * Remove duplicate imports in ui/app/components/app/index.scss * Use URL instead of regex in getOriginFromUrl() * Add runtime error checking to platform, promise based extension.tab methods * Support permission requests from external extensions * Improve font size and colour of the domain origin on the permission confirmation screen * Add support for toggling permissions * Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions * Remove unused code from LoginPerSite-ui branch * Ensure modal closes on Enter press for new-account-modal.component.js * Lint fix * fixup! Login Per Site UI (#7368) * Some code cleanup for LoginPerSite * Adds UX for connecting to dapps via the connected sites screen (#7593) * Adds UX for connecting to dapps via the connected sites screen * Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask * Delete unused permissions controller methods * Fixes two small bugs in the LoginPerSite ui (#7595) * Restore `providerRequest` message translations (#7600) This message was removed, but it was replaced with a very similar message called `likeToConnect`. The only difference is that the new message has "MetaMask" in it. Preserving these messages without "MetaMask" is probably better than deleting them, so these messages have all been restored and renamed to `likeToConnect`. * Login per site no sitemetadata fix (#7610) * Support connected sites for which we have no site metadata. * Change property containing subtitle info often populated by origin to a more accurate of purpose name * Lint fix * Improve disconnection modal messages (#7612) * Improve disconnectAccountModalDescription and disconnectAllModalDescription messages * Update disconnectAccountModalDescription app/_locales/en/messages.json Co-Authored-By: Mark Stacey <markjstacey@gmail.com> * Improve disconnectAccount modal message clarity * Adds cancel button to the account selection screen of the permissions request flow (#7613) * Fix eth_accounts permission language & selectability (#7614) * fix eth_accounts language & selectability * fix MetaMask capitalization in all messages * Close sidebar when opening connected sites (#7611) The 'Connected Sites' button in the accounts details now closes the sidebar, if it is open. This was accomplished by pulling the click handler for that button up to the wallet view component, where another button already followed a similar pattern of closing the sidebar. It seemed confusing to me that one handler was in the `AccountsDetails` container component, and one was handed down from above, so I added PropTypes to the container component. I'm not sure that the WalletView component is the best place for this logic, but I've put it there for now to be consistent with the add token button. * Reject permissions request upon tab close (#7618) Permissions requests are now rejected when the page is closed. This only applies to the full-screen view, as that is the view permission requests should be handled in. The case where the user deals with the request through a different view is handled in #7617 * Handle tab update failure (#7619) `extension.tabs.update` can sometimes fail if the user interacts with the tabs directly around the same time. The redirect flow has been updated to ensure that the permissions tab is still closed in that case. The user is on their own to find the dapp tab again in that case. * Login per site tab popup fixes (#7617) * Handle redirect in response to state update in permissions-connect * Ensure origin is available to permissions-connect subcomponents during redirect * Hide app bar whenever on redirect route * Improvements to handling of redirects in permissions-connect * Ensure permission request id change handling only happens when page is not null * Lint fix * Decouple confirm transaction screen from the selected address (#7622) * Avoid race condtion that could prevent contextual account switching (#7623) There was a race condition in the logic responsible for switching the selected account based upon the active tab. It was asynchronously querying the active tab, then assuming it had been retrieved later. The active tab info itself was already in the redux store in another spot, one that is guaranteed to be set before the UI renders. The race condition was avoided by deleting the duplicate state, and using the other active tab state. * Only redirect back to dapp if current tab is active (#7621) The "redirect back to dapp" behaviour can be disruptive when the permissions connect tab is not active. The purpose of the redirect was to maintain context between the dapp and the permissions request, but if the user has already moved to another tab, that no longer applies. * Fix JSX style lint errors * Remove unused state
2019-12-03 18:35:56 +01:00
CONNECT_ROUTE,
CONNECTED_ROUTE,
2020-05-15 20:53:52 +02:00
CONNECTED_ACCOUNTS_ROUTE,
2020-10-06 20:28:38 +02:00
AWAITING_SWAP_ROUTE,
BUILD_QUOTE_ROUTE,
VIEW_QUOTE_ROUTE,
2021-02-22 17:20:42 +01:00
CONFIRMATION_V_NEXT_ROUTE,
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
ONBOARDING_SECURE_YOUR_WALLET_ROUTE,
///: END:ONLY_INCLUDE_IN
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
CONFIRM_ADD_CUSTODIAN_TOKEN,
INTERACTIVE_REPLACEMENT_TOKEN_PAGE,
///: END:ONLY_INCLUDE_IN
} from '../../helpers/constants/routes';
import ZENDESK_URLS from '../../helpers/constants/zendesk-url';
///: BEGIN:ONLY_INCLUDE_IN(build-main)
import { SUPPORT_LINK } from '../../../shared/lib/ui-utils';
///: END:ONLY_INCLUDE_IN
///: BEGIN:ONLY_INCLUDE_IN(build-beta)
import BetaHomeFooter from './beta/beta-home-footer.component';
///: END:ONLY_INCLUDE_IN
///: BEGIN:ONLY_INCLUDE_IN(build-flask)
import FlaskHomeFooter from './flask/flask-home-footer.component';
///: END:ONLY_INCLUDE_IN
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
import InstitutionalHomeFooter from './institutional/institutional-home-footer';
///: END:ONLY_INCLUDE_IN
function shouldCloseNotificationPopup({
isNotification,
totalUnapprovedCount,
hasApprovalFlows,
isSigningQRHardwareTransaction,
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
waitForConfirmDeepLinkDialog,
institutionalConnectRequests,
///: END:ONLY_INCLUDE_IN
}) {
let shouldCLose =
isNotification &&
totalUnapprovedCount === 0 &&
!hasApprovalFlows &&
!isSigningQRHardwareTransaction;
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
shouldCLose &&=
// MMI User must be shown a deeplink
!waitForConfirmDeepLinkDialog &&
// MMI User is connecting to custodian
institutionalConnectRequests.length === 0;
///: END:ONLY_INCLUDE_IN
return shouldCLose;
}
export default class Home extends PureComponent {
static contextTypes = {
t: PropTypes.func,
trackEvent: PropTypes.func,
};
static propTypes = {
history: PropTypes.object,
forgottenPassword: PropTypes.bool,
hasTransactionPendingApprovals: PropTypes.bool.isRequired,
hasWatchTokenPendingApprovals: PropTypes.bool,
hasWatchNftPendingApprovals: PropTypes.bool,
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
shouldShowSeedPhraseReminder: PropTypes.bool.isRequired,
isPopup: PropTypes.bool,
connectedStatusPopoverHasBeenShown: PropTypes.bool,
showRecoveryPhraseReminder: PropTypes.bool.isRequired,
showTermsOfUsePopup: PropTypes.bool.isRequired,
seedPhraseBackedUp: (props) => {
if (
props.seedPhraseBackedUp !== null &&
typeof props.seedPhraseBackedUp !== 'boolean'
) {
throw new Error(
`seedPhraseBackedUp is required to be null or boolean. Received ${props.seedPhraseBackedUp}`,
);
}
},
///: END:ONLY_INCLUDE_IN
isNotification: PropTypes.bool.isRequired,
firstPermissionsRequestId: PropTypes.string,
// This prop is used in the `shouldCloseNotificationPopup` function
// eslint-disable-next-line react/no-unused-prop-types
totalUnapprovedCount: PropTypes.number.isRequired,
setConnectedStatusPopoverHasBeenShown: PropTypes.func,
defaultHomeActiveTabName: PropTypes.string,
firstTimeFlowType: PropTypes.string,
completedOnboarding: PropTypes.bool,
2020-05-25 21:01:28 +02:00
onTabClick: PropTypes.func.isRequired,
2020-10-06 20:28:38 +02:00
haveSwapsQuotes: PropTypes.bool.isRequired,
showAwaitingSwapScreen: PropTypes.bool.isRequired,
swapsFetchParams: PropTypes.object,
location: PropTypes.object,
shouldShowWeb3ShimUsageNotification: PropTypes.bool.isRequired,
setWeb3ShimUsageAlertDismissed: PropTypes.func.isRequired,
originOfCurrentTab: PropTypes.string,
disableWeb3ShimUsageAlert: PropTypes.func.isRequired,
pendingConfirmations: PropTypes.arrayOf(PropTypes.object).isRequired,
hasApprovalFlows: PropTypes.bool.isRequired,
infuraBlocked: PropTypes.bool.isRequired,
Whats new popup (#10583) * Add 'What's New' notification popup * Move selectors from shared/notifications into ui/ directory * Use keys for localized message in whats new notifications objects, to ensure notifications will be translated. * Remove unused swaps intro popup locale messages * Fix keys of whats new notification locales * Remove notifications messages and descriptions from comment in shared/notifications * Move notifcationActionFunctions to shared/notifications and make it stateless * Get notification data from constants instead of state in whats-new-popup * Code cleanup * Fix build quote reference to swapsEthToken, broken during rebase * Rename notificationFilters to notificationToExclude to clarify its purpose * Documentation for getSortedNotificationsToShow * Move notification action functions from shared/ to whats-new-popup.js * Stop setting swapsWelcomeMessageHasBeenShown to state in app-state controller * Update e2e tests for whats new popup changes * Updating migration files * Addressing feedback part 1 * Addressing feedback part 2 * Remove unnecessary div in whats-new-popup * Change getNotificationsToExclude to getNotificationsToInclude for use in the getSortedNotificationsToShow selector * Delete intro-popup directory and test files * Lint fix * Add notifiction state to address-entry fixture * Use two separate functions for rendering first and subsequent notifications in the whats-new-popup * Ensure that string literals are passed to t for whats new popup text * Update import-ui fixtures to include notificaiton controller state * Remove unnecessary, accidental change confirm-approve * Remove swaps notification in favour of mobile swaps as first notifcation and TBD 3rd notification * Update whats-new-popup to use intersection observer api to detect if notification has been seen * Add notifications to send-edit and threebox e2e test fixtures * Update ui/app/selectors/selectors.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Update ui/app/selectors/selectors.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Clean up locale code for whats-new-popup notifications * Disconnect observers in whats-new-popup when their callback is first called * Add test case for migration 58 for when the AppStateController does not exist * Rename popover components containerRef to popoverWrapRef * Fix messages.json * Update notification messages and images * Rename popoverWrapRef -> popoverRef in whats-new-popup and popover.component * Only create one observer, and only after images have loaded, in whats-new-popup * Set width and height on whats-new-popup image, instead of setting state on img load * Update ui/app/components/app/whats-new-popup/whats-new-popup.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Code clean up in whats new popup re: notification rendering and action functions * Code cleanup in render notification functions of whats-new-popup * Update ui/app/components/app/whats-new-popup/whats-new-popup.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * lint fix * Update and localize notification dates * Clean up date code in shred/notifications/index.js Co-authored-by: ryanml <ryanlanese@gmail.com> Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-04-28 18:51:41 +02:00
showWhatsNewPopup: PropTypes.bool.isRequired,
hideWhatsNewPopup: PropTypes.func.isRequired,
announcementsToShow: PropTypes.bool.isRequired,
///: BEGIN:ONLY_INCLUDE_IN(snaps)
errorsToShow: PropTypes.object.isRequired,
shouldShowErrors: PropTypes.bool.isRequired,
removeSnapError: PropTypes.func.isRequired,
///: END:ONLY_INCLUDE_IN
setRecoveryPhraseReminderHasBeenShown: PropTypes.func.isRequired,
setRecoveryPhraseReminderLastShown: PropTypes.func.isRequired,
setTermsOfUseLastAgreed: PropTypes.func.isRequired,
showOutdatedBrowserWarning: PropTypes.bool.isRequired,
setOutdatedBrowserWarningLastShown: PropTypes.func.isRequired,
newNetworkAddedName: PropTypes.string,
// This prop is used in the `shouldCloseNotificationPopup` function
// eslint-disable-next-line react/no-unused-prop-types
isSigningQRHardwareTransaction: PropTypes.bool.isRequired,
newNftAddedMessage: PropTypes.string,
setNewNftAddedMessage: PropTypes.func.isRequired,
removeNftMessage: PropTypes.string,
setRemoveNftMessage: PropTypes.func.isRequired,
closeNotificationPopup: PropTypes.func.isRequired,
2022-05-09 19:47:06 +02:00
newTokensImported: PropTypes.string,
setNewTokensImported: PropTypes.func.isRequired,
newNetworkAddedConfigurationId: PropTypes.string,
clearNewNetworkAdded: PropTypes.func,
setActiveNetwork: PropTypes.func,
onboardedInThisUISession: PropTypes.bool,
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
institutionalConnectRequests: PropTypes.arrayOf(PropTypes.object),
mmiPortfolioEnabled: PropTypes.bool,
mmiPortfolioUrl: PropTypes.string,
modalOpen: PropTypes.bool,
setWaitForConfirmDeepLinkDialog: PropTypes.func,
waitForConfirmDeepLinkDialog: PropTypes.bool,
///: END:ONLY_INCLUDE_IN
};
state = {
canShowBlockageNotification: true,
notificationClosing: false,
redirecting: false,
};
constructor(props) {
super(props);
const {
closeNotificationPopup,
firstPermissionsRequestId,
haveSwapsQuotes,
isNotification,
showAwaitingSwapScreen,
hasWatchTokenPendingApprovals,
hasWatchNftPendingApprovals,
swapsFetchParams,
hasTransactionPendingApprovals,
location,
} = this.props;
const stayOnHomePage = Boolean(location?.state?.stayOnHomePage);
if (shouldCloseNotificationPopup(props)) {
this.state.notificationClosing = true;
closeNotificationPopup();
} else if (
firstPermissionsRequestId ||
hasTransactionPendingApprovals ||
hasWatchTokenPendingApprovals ||
hasWatchNftPendingApprovals ||
(!isNotification &&
!stayOnHomePage &&
(showAwaitingSwapScreen || haveSwapsQuotes || swapsFetchParams))
) {
this.state.redirecting = true;
}
}
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
checkInstitutionalConnectRequest() {
const { history, institutionalConnectRequests } = this.props;
if (
institutionalConnectRequests &&
institutionalConnectRequests.length > 0 &&
institutionalConnectRequests[0].feature === 'custodian'
) {
if (
institutionalConnectRequests[0].method ===
'metamaskinstitutional_reauthenticate'
) {
history.push(INTERACTIVE_REPLACEMENT_TOKEN_PAGE);
} else if (
institutionalConnectRequests[0].method ===
'metamaskinstitutional_authenticate'
) {
history.push(CONFIRM_ADD_CUSTODIAN_TOKEN);
}
}
}
shouldCloseCurrentWindow() {
const {
isNotification,
modalOpen,
totalUnapprovedCount,
institutionalConnectRequests,
waitForConfirmDeepLinkDialog,
} = this.props;
if (
isNotification &&
totalUnapprovedCount === 0 &&
institutionalConnectRequests.length === 0 &&
!waitForConfirmDeepLinkDialog &&
!modalOpen
) {
global.platform.closeCurrentWindow();
}
}
///: END:ONLY_INCLUDE_IN
checkStatusAndNavigate() {
2018-08-28 20:20:30 +02:00
const {
firstPermissionsRequestId,
2018-08-28 20:20:30 +02:00
history,
isNotification,
hasTransactionPendingApprovals,
hasWatchTokenPendingApprovals,
hasWatchNftPendingApprovals,
2020-10-06 20:28:38 +02:00
haveSwapsQuotes,
showAwaitingSwapScreen,
swapsFetchParams,
location,
pendingConfirmations,
hasApprovalFlows,
} = this.props;
const stayOnHomePage = Boolean(location?.state?.stayOnHomePage);
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
this.shouldCloseCurrentWindow();
///: END:ONLY_INCLUDE_IN
const canRedirect = !isNotification && !stayOnHomePage;
if (canRedirect && showAwaitingSwapScreen) {
history.push(AWAITING_SWAP_ROUTE);
} else if (canRedirect && haveSwapsQuotes) {
history.push(VIEW_QUOTE_ROUTE);
} else if (canRedirect && swapsFetchParams) {
history.push(BUILD_QUOTE_ROUTE);
} else if (firstPermissionsRequestId) {
history.push(`${CONNECT_ROUTE}/${firstPermissionsRequestId}`);
} else if (hasTransactionPendingApprovals) {
history.push(CONFIRM_TRANSACTION_ROUTE);
} else if (hasWatchTokenPendingApprovals) {
history.push(CONFIRM_ADD_SUGGESTED_TOKEN_ROUTE);
} else if (hasWatchNftPendingApprovals) {
history.push(CONFIRM_ADD_SUGGESTED_NFT_ROUTE);
} else if (pendingConfirmations.length > 0 || hasApprovalFlows) {
2021-02-22 17:20:42 +01:00
history.push(CONFIRMATION_V_NEXT_ROUTE);
}
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
this.checkInstitutionalConnectRequest();
///: END:ONLY_INCLUDE_IN
}
componentDidMount() {
this.checkStatusAndNavigate();
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
const { setWaitForConfirmDeepLinkDialog } = this.props;
window.addEventListener('beforeunload', () => {
// If user closes notification window manually, change waitForConfirmDeepLinkDialog to false
setWaitForConfirmDeepLinkDialog(false);
});
///: END:ONLY_INCLUDE_IN
}
static getDerivedStateFromProps(props) {
if (shouldCloseNotificationPopup(props)) {
return { notificationClosing: true };
}
return null;
}
componentDidUpdate(_prevProps, prevState) {
const { closeNotificationPopup, isNotification } = this.props;
const { notificationClosing } = this.state;
if (notificationClosing && !prevState.notificationClosing) {
closeNotificationPopup();
} else if (isNotification) {
this.checkStatusAndNavigate();
3box integration 2.0 (#6972) * Adds threebox controller * Adds threebox approval modal * Fix unit tests and lint after addition of threebox * Correct threebox behaviour after rejecting request for backup; fixes e2e tests. * Update threebox controller for automatic syncing * Ensure frontend locale updates when preferences are changed via direct update within controller * Add toggle in settings for 3box syncing * Update threebox controller for latest 3box version * Delete unnecessary frontend changes for threebox integration * Backing up address book contacts with threebox * Update unit tests for 3box-integration additions * Only enable threebox by default for new wallets * Mock globals for correct unit tests * 3box '1.10.2' -> '^1.10.2' * Correct capilalization on 3Box * Use log.debug instead of console.log in threebox controller * Update yarn.lock * Remove edge build * Split 3box module into background deps js file * extra bundle opts for bg-libs * sync yarn.lock * new3Box logic * Show confirm threebox restore after import * Remove bg-libs.js from manifest file for dev builds * Switch 3Box controller to using the spaces api (instead of the profile api) * Finalize switching to spaces api and only restoring from 3box after import * Update metamask-controller-test.js for threebox controller changes * Make threebox modal style consistent with others and update success button wording * Use mock 3box when in test * Correct 3box modal header * Remove unnecessary property of threebox controller provider * Remove unnecessary method calls after restoration from 3box in the threebox-restore-confirm modal. * Replace setThreeBoxSyncingPermission calls in routes/index.js with turnThreeBoxSyncingOn * Replace erroneous use of with * Replace erroneous use of threeboxSyncing with threeBoxSyncingAllowed in advancted-tab directory * Lint fixes for 3box changes * Log errors encountered when updating 3Box * Remove unnecessary parameter from state update * Add timeout to initial 3Box sync The initial 3Box sync will now timeout after 1 minute. If the timeout is triggered, 3Box is disabled and cannot be re-enabled unless the initial sync does finally finish. If it never finishes, 3Box cannot be enabled unless the extension is reinstalled. The Advanced Settings page was updated to show this option as disabled in that circumstance, with a new discription explaining why it's disabled. The UI here could certainly be improved. Additionally, "on" and "off" labels were added to the toggle to match the other toggles on the Advanced Settings page. * Use non-minified 3Box module We had previously used the minified 3Box module to avoid a build error encountered when `envify` was processing the `libp2p` module (which is used by 3Box). The build would fail because `esprima` (used by `envify`) is incompatible with the object spread/rest operator (which is used in `libp2p`). That issue has been solved by adding a global Babelify transformation specifically for transpiling out the object rest/spread operator from dependencies. It has been targetted to only affect `libp2p` to avoid extending the build time too much. This workaround can be used until a new version of `esprima` is released that includes this bug fix. * Use app key addresses for threebox * Replace use of modal for confirming 3box restoration with a home notification * Adds e2e tests for restoring from threebox * Update eth-keyring-controller to 5.1.0 * Correct parameters passed to getAppKeyAddress in threebox.js * Add prefix to origin passed to getAppKeyAddress in threebox.js * Remove unused locale message. * Prevent CORS errors in firefox e2e tests * Ensure extraneous scripts are excluded from the local test dev build * Move threeBoxLastUpdate state from home.component to redux * Threebox PR code cleanup * Always use first address when initializing threebox * Replace setRestoredFromThreeBox api with setRestoredFromThreeBoxToFalse and setRestoredFromThreeBoxToTrue * Update development/metamaskbot-build-announce.js to include ui-libs and bg-libs in hard coded bundle list * Update test/e2e/threebox.spec.js to use new helpers added with pull #7144 * Make setFeatureFlag available on the ui window during testing * Hide threebox feature behind a feature flag that can only be activated via dev console * Remove unnecessary migration of threebox feature flag * Prevent this.init() call in threebox constructor if feature flag is not turned on * Prevent threebox notification from showing if feature flag is falsy * http://localhost/8889 -> http://localhost/* in gulp manifest:testing tasks
2019-09-16 19:11:01 +02:00
}
}
onRecoveryPhraseReminderClose = () => {
const {
setRecoveryPhraseReminderHasBeenShown,
setRecoveryPhraseReminderLastShown,
} = this.props;
setRecoveryPhraseReminderHasBeenShown(true);
setRecoveryPhraseReminderLastShown(new Date().getTime());
};
onAcceptTermsOfUse = () => {
const { setTermsOfUseLastAgreed } = this.props;
setTermsOfUseLastAgreed(new Date().getTime());
this.context.trackEvent({
category: MetaMetricsEventCategory.Onboarding,
event: MetaMetricsEventName.TermsOfUseAccepted,
properties: {
location: 'Terms Of Use Popover',
},
});
};
///: BEGIN:ONLY_INCLUDE_IN(build-main)
onSupportLinkClick = () => {
this.context.trackEvent(
{
category: MetaMetricsEventCategory.Home,
event: MetaMetricsEventName.SupportLinkClicked,
properties: {
url: SUPPORT_LINK,
},
},
{
contextPropsIntoEventProperties: [MetaMetricsContextProp.PageTitle],
},
);
};
///: END:ONLY_INCLUDE_IN
onOutdatedBrowserWarningClose = () => {
const { setOutdatedBrowserWarningLastShown } = this.props;
setOutdatedBrowserWarningLastShown(new Date().getTime());
};
2020-11-03 00:41:28 +01:00
renderNotifications() {
const { t } = this.context;
const {
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
history,
shouldShowSeedPhraseReminder,
isPopup,
///: END:ONLY_INCLUDE_IN
shouldShowWeb3ShimUsageNotification,
setWeb3ShimUsageAlertDismissed,
originOfCurrentTab,
disableWeb3ShimUsageAlert,
///: BEGIN:ONLY_INCLUDE_IN(snaps)
removeSnapError,
errorsToShow,
shouldShowErrors,
///: END:ONLY_INCLUDE_IN
infuraBlocked,
showOutdatedBrowserWarning,
newNftAddedMessage,
setNewNftAddedMessage,
newNetworkAddedName,
removeNftMessage,
setRemoveNftMessage,
2022-05-09 19:47:06 +02:00
newTokensImported,
setNewTokensImported,
newNetworkAddedConfigurationId,
clearNewNetworkAdded,
setActiveNetwork,
} = this.props;
const onAutoHide = () => {
setNewNftAddedMessage('');
setRemoveNftMessage('');
};
const autoHideDelay = 5 * SECOND;
return (
<MultipleNotifications>
{
///: BEGIN:ONLY_INCLUDE_IN(snaps)
shouldShowErrors
? Object.entries(errorsToShow).map(([errorId, error]) => {
return (
<HomeNotification
classNames={['home__error-message']}
infoText={error.data.snapId}
descriptionText={
<>
<Text
variant={TextVariant.bodyMd}
as="h5"
color={TextColor.textAlternative}
>
{t('somethingWentWrong')}
</Text>
<Text
color={TextColor.textAlternative}
variant={TextVariant.bodySm}
as="h6"
>
{t('snapError', [error.message, error.code])}
</Text>
</>
}
onIgnore={async () => {
await removeSnapError(errorId);
}}
ignoreText="Dismiss"
key="home-error-message"
/>
);
})
: null
///: END:ONLY_INCLUDE_IN
}
{newNftAddedMessage === 'success' ? (
<ActionableMessage
type="success"
className="home__new-network-notification"
autoHideTime={autoHideDelay}
onAutoHide={onAutoHide}
message={
<Box display={Display.InlineFlex}>
<i className="fa fa-check-circle home__new-nft-notification-icon" />
<Text variant={TextVariant.bodySm} as="h6">
{t('newNftAddedMessage')}
</Text>
2023-02-27 17:42:02 +01:00
<ButtonIcon
iconName={IconName.Close}
size={ButtonIconSize.Sm}
2023-02-27 17:42:02 +01:00
ariaLabel={t('close')}
onClick={onAutoHide}
/>
</Box>
}
/>
) : null}
{removeNftMessage === 'success' ? (
<ActionableMessage
type="danger"
className="home__new-network-notification"
autoHideTime={autoHideDelay}
onAutoHide={onAutoHide}
message={
<Box display={Display.InlineFlex}>
<i className="fa fa-check-circle home__new-nft-notification-icon" />
<Text variant={TextVariant.bodySm} as="h6">
{t('removeNftMessage')}
</Text>
2023-02-27 17:42:02 +01:00
<ButtonIcon
iconName={IconName.Close}
size={ButtonIconSize.Sm}
2023-02-27 17:42:02 +01:00
ariaLabel={t('close')}
onClick={onAutoHide}
/>
</Box>
}
/>
) : null}
{newNetworkAddedName ? (
<ActionableMessage
type="success"
className="home__new-network-notification"
message={
<Box display={Display.InlineFlex}>
<i className="fa fa-check-circle home__new-network-notification-icon" />
<Text variant={TextVariant.bodySm} as="h6">
{t('newNetworkAdded', [newNetworkAddedName])}
</Text>
2023-02-27 17:42:02 +01:00
<ButtonIcon
iconName={IconName.Close}
size={ButtonIconSize.Sm}
2023-02-27 17:42:02 +01:00
ariaLabel={t('close')}
onClick={() => clearNewNetworkAdded()}
2023-02-27 17:42:02 +01:00
className="home__new-network-notification-close"
/>
</Box>
}
/>
) : null}
2022-05-09 19:47:06 +02:00
{newTokensImported ? (
<ActionableMessage
type="success"
className="home__new-tokens-imported-notification"
message={
<Box display={Display.InlineFlex}>
2022-05-09 19:47:06 +02:00
<i className="fa fa-check-circle home__new-tokens-imported-notification-icon" />
<Box>
<Text
2022-05-09 19:47:06 +02:00
className="home__new-tokens-imported-notification-title"
variant={TextVariant.bodySmBold}
as="h6"
2022-05-09 19:47:06 +02:00
>
{t('newTokensImportedTitle')}
</Text>
<Text
2022-05-09 19:47:06 +02:00
className="home__new-tokens-imported-notification-message"
variant={TextVariant.bodySm}
as="h6"
2022-05-09 19:47:06 +02:00
>
{t('newTokensImportedMessage', [newTokensImported])}
</Text>
2022-05-09 19:47:06 +02:00
</Box>
2023-02-27 17:42:02 +01:00
<ButtonIcon
iconName={IconName.Close}
size={ButtonIconSize.Sm}
2023-02-27 17:42:02 +01:00
ariaLabel={t('close')}
2022-05-09 19:47:06 +02:00
onClick={() => setNewTokensImported('')}
2023-02-27 17:42:02 +01:00
className="home__new-tokens-imported-notification-close"
2022-05-09 19:47:06 +02:00
/>
</Box>
}
/>
) : null}
{shouldShowWeb3ShimUsageNotification ? (
<HomeNotification
descriptionText={t('web3ShimUsageNotification', [
<span
key="web3ShimUsageNotificationLink"
className="home-notification__text-link"
onClick={() =>
global.platform.openTab({ url: ZENDESK_URLS.LEGACY_WEB3 })
}
>
{t('here')}
</span>,
])}
ignoreText={t('dismiss')}
onIgnore={(disable) => {
setWeb3ShimUsageAlertDismissed(originOfCurrentTab);
if (disable) {
disableWeb3ShimUsageAlert();
}
}}
checkboxText={t('dontShowThisAgain')}
checkboxTooltipText={t('canToggleInSettings')}
key="home-web3ShimUsageNotification"
/>
) : null}
{
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
shouldShowSeedPhraseReminder ? (
<HomeNotification
descriptionText={t('backupApprovalNotice')}
acceptText={t('backupNow')}
onAccept={() => {
const backUpSRPRoute = `${ONBOARDING_SECURE_YOUR_WALLET_ROUTE}/?isFromReminder=true`;
if (isPopup) {
global.platform.openExtensionInBrowser(backUpSRPRoute);
} else {
history.push(backUpSRPRoute);
}
}}
infoText={t('backupApprovalInfo')}
key="home-backupApprovalNotice"
/>
) : null
///: END:ONLY_INCLUDE_IN
}
{infuraBlocked && this.state.canShowBlockageNotification ? (
<HomeNotification
descriptionText={t('infuraBlockedNotification', [
<span
key="infuraBlockedNotificationLink"
className="home-notification__text-link"
onClick={() =>
global.platform.openTab({ url: ZENDESK_URLS.INFURA_BLOCKAGE })
}
>
{t('here')}
</span>,
])}
ignoreText={t('dismiss')}
onIgnore={() => {
this.setState({
canShowBlockageNotification: false,
});
}}
key="home-infuraBlockedNotification"
/>
) : null}
{showOutdatedBrowserWarning ? (
<HomeNotification
descriptionText={t('outdatedBrowserNotification')}
acceptText={t('gotIt')}
onAccept={this.onOutdatedBrowserWarningClose}
key="home-outdatedBrowserNotification"
/>
) : null}
{newNetworkAddedConfigurationId && (
<Popover
className="home__new-network-added"
onClose={() => clearNewNetworkAdded()}
>
<i className="fa fa-check-circle fa-2x home__new-network-added__check-circle" />
<Text
variant={TextVariant.headingSm}
as="h4"
marginTop={5}
marginRight={9}
marginLeft={9}
marginBottom={0}
fontWeight={FontWeight.Bold}
>
{t('networkAddedSuccessfully')}
</Text>
<Box marginTop={8} marginRight={8} marginLeft={8} marginBottom={5}>
<Button
type="primary"
className="home__new-network-added__switch-to-button"
onClick={() => {
setActiveNetwork(newNetworkAddedConfigurationId);
clearNewNetworkAdded();
}}
>
<Text
variant={TextVariant.bodySm}
as="h6"
color={TextColor.primaryInverse}
>
{t('switchToNetwork', [newNetworkAddedName])}
</Text>
</Button>
<Button type="secondary" onClick={() => clearNewNetworkAdded()}>
<Text
variant={TextVariant.bodySm}
as="h6"
color={TextColor.primaryDefault}
>
{t('dismiss')}
</Text>
</Button>
</Box>
</Popover>
)}
</MultipleNotifications>
);
}
renderPopover = () => {
const { setConnectedStatusPopoverHasBeenShown } = this.props;
const { t } = this.context;
return (
<Popover
2020-11-03 00:41:28 +01:00
title={t('whatsThis')}
onClose={setConnectedStatusPopoverHasBeenShown}
className="home__connected-status-popover"
showArrow
CustomBackground={({ onClose }) => {
return (
<div
className="home__connected-status-popover-bg-container"
onClick={onClose}
>
<div className="home__connected-status-popover-bg" />
</div>
);
}}
2020-11-03 00:41:28 +01:00
footer={
<>
<a
href={ZENDESK_URLS.USER_GUIDE_DAPPS}
target="_blank"
rel="noopener noreferrer"
>
{t('learnMoreUpperCase')}
</a>
<Button
type="primary"
onClick={setConnectedStatusPopoverHasBeenShown}
>
2020-11-03 00:41:28 +01:00
{t('dismiss')}
</Button>
</>
2020-11-03 00:41:28 +01:00
}
>
<main className="home__connect-status-text">
2020-11-03 00:41:28 +01:00
<div>{t('metaMaskConnectStatusParagraphOne')}</div>
<div>{t('metaMaskConnectStatusParagraphTwo')}</div>
<div>{t('metaMaskConnectStatusParagraphThree')}</div>
</main>
</Popover>
);
};
2020-11-03 00:41:28 +01:00
render() {
const { t } = this.context;
const {
2020-05-25 21:01:28 +02:00
defaultHomeActiveTabName,
onTabClick,
forgottenPassword,
history,
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
connectedStatusPopoverHasBeenShown,
isPopup,
seedPhraseBackedUp,
showRecoveryPhraseReminder,
showTermsOfUsePopup,
///: END:ONLY_INCLUDE_IN
announcementsToShow,
Whats new popup (#10583) * Add 'What's New' notification popup * Move selectors from shared/notifications into ui/ directory * Use keys for localized message in whats new notifications objects, to ensure notifications will be translated. * Remove unused swaps intro popup locale messages * Fix keys of whats new notification locales * Remove notifications messages and descriptions from comment in shared/notifications * Move notifcationActionFunctions to shared/notifications and make it stateless * Get notification data from constants instead of state in whats-new-popup * Code cleanup * Fix build quote reference to swapsEthToken, broken during rebase * Rename notificationFilters to notificationToExclude to clarify its purpose * Documentation for getSortedNotificationsToShow * Move notification action functions from shared/ to whats-new-popup.js * Stop setting swapsWelcomeMessageHasBeenShown to state in app-state controller * Update e2e tests for whats new popup changes * Updating migration files * Addressing feedback part 1 * Addressing feedback part 2 * Remove unnecessary div in whats-new-popup * Change getNotificationsToExclude to getNotificationsToInclude for use in the getSortedNotificationsToShow selector * Delete intro-popup directory and test files * Lint fix * Add notifiction state to address-entry fixture * Use two separate functions for rendering first and subsequent notifications in the whats-new-popup * Ensure that string literals are passed to t for whats new popup text * Update import-ui fixtures to include notificaiton controller state * Remove unnecessary, accidental change confirm-approve * Remove swaps notification in favour of mobile swaps as first notifcation and TBD 3rd notification * Update whats-new-popup to use intersection observer api to detect if notification has been seen * Add notifications to send-edit and threebox e2e test fixtures * Update ui/app/selectors/selectors.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Update ui/app/selectors/selectors.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Clean up locale code for whats-new-popup notifications * Disconnect observers in whats-new-popup when their callback is first called * Add test case for migration 58 for when the AppStateController does not exist * Rename popover components containerRef to popoverWrapRef * Fix messages.json * Update notification messages and images * Rename popoverWrapRef -> popoverRef in whats-new-popup and popover.component * Only create one observer, and only after images have loaded, in whats-new-popup * Set width and height on whats-new-popup image, instead of setting state on img load * Update ui/app/components/app/whats-new-popup/whats-new-popup.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Code clean up in whats new popup re: notification rendering and action functions * Code cleanup in render notification functions of whats-new-popup * Update ui/app/components/app/whats-new-popup/whats-new-popup.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * lint fix * Update and localize notification dates * Clean up date code in shred/notifications/index.js Co-authored-by: ryanml <ryanlanese@gmail.com> Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-04-28 18:51:41 +02:00
showWhatsNewPopup,
hideWhatsNewPopup,
firstTimeFlowType,
completedOnboarding,
onboardedInThisUISession,
newNetworkAddedConfigurationId,
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
mmiPortfolioEnabled,
mmiPortfolioUrl,
///: END:ONLY_INCLUDE_IN
} = this.props;
if (forgottenPassword) {
return <Redirect to={{ pathname: RESTORE_VAULT_ROUTE }} />;
} else if (this.state.notificationClosing || this.state.redirecting) {
return null;
}
const tabPadding = process.env.MULTICHAIN ? 4 : 0; // TODO: Remove tabPadding and add paddingTop={4} to parent container Box of Tabs
const showWhatsNew =
completedOnboarding &&
(!onboardedInThisUISession || firstTimeFlowType === 'import') &&
announcementsToShow &&
showWhatsNewPopup &&
!process.env.IN_TEST &&
!newNetworkAddedConfigurationId;
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
const showTermsOfUse =
completedOnboarding && !onboardedInThisUISession && showTermsOfUsePopup;
///: END:ONLY_INCLUDE_IN
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
// The style in activity screen for support is different
const activitySupportDisplayStyle =
defaultHomeActiveTabName === 'activity'
? {
justifyContent: JustifyContent.center,
paddingLeft: 0,
marginTop: 4,
marginBottom: 4,
}
: {
justifyContent: JustifyContent.flexStart,
paddingLeft: 4,
marginTop: 0,
marginBottom: 4,
};
///: END:ONLY_INCLUDE_IN
return (
<div className="main-container">
2020-05-15 20:53:52 +02:00
<Route path={CONNECTED_ROUTE} component={ConnectedSites} exact />
2020-11-03 00:41:28 +01:00
<Route
path={CONNECTED_ACCOUNTS_ROUTE}
component={ConnectedAccounts}
exact
/>
<div className="home__container">
{showWhatsNew ? (
<WhatsNewPopup
onClose={hideWhatsNewPopup}
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
mmiPortfolioUrl={mmiPortfolioUrl}
///: END:ONLY_INCLUDE_IN
/>
) : null}
{
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
}
{!showWhatsNew && showRecoveryPhraseReminder ? (
<RecoveryPhraseReminder
hasBackedUp={seedPhraseBackedUp}
onConfirm={this.onRecoveryPhraseReminderClose}
/>
2020-10-06 20:28:38 +02:00
) : null}
{showTermsOfUse ? (
<TermsOfUsePopup onAccept={this.onAcceptTermsOfUse} />
) : null}
2020-11-03 00:41:28 +01:00
{isPopup && !connectedStatusPopoverHasBeenShown
? this.renderPopover()
: null}
{
///: END:ONLY_INCLUDE_IN
}
<div className="home__main-view">
{process.env.MULTICHAIN ? null : (
<div className="home__balance-wrapper">
{
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
<EthOverview showAddress />
///: END:ONLY_INCLUDE_IN
}
{
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
<EthOverview
showAddress
mmiPortfolioEnabled={mmiPortfolioEnabled}
mmiPortfolioUrl={mmiPortfolioUrl}
/>
///: END:ONLY_INCLUDE_IN
}
</div>
)}
<Box style={{ flexGrow: '1' }} paddingTop={tabPadding}>
<Tabs
t={this.context.t}
defaultActiveTabKey={defaultHomeActiveTabName}
onTabClick={(tabName) => {
onTabClick(tabName);
let event;
switch (tabName) {
case 'nfts':
event = MetaMetricsEventName.NftScreenOpened;
break;
case 'activity':
event = MetaMetricsEventName.ActivityScreenOpened;
break;
default:
event = MetaMetricsEventName.TokenScreenOpened;
}
this.context.trackEvent({
category: MetaMetricsEventCategory.Home,
event,
});
}}
tabsClassName="home__tabs"
>
<Tab
activeClassName="home__tab--active"
className="home__tab"
data-testid="home__asset-tab"
name={this.context.t('tokens')}
tabKey="tokens"
>
<Box marginTop={2}>
<AssetList
onClickAsset={(asset) =>
history.push(`${ASSET_ROUTE}/${asset}`)
}
/>
{
///: BEGIN:ONLY_INCLUDE_IN(build-main)
<ButtonLink
size={Size.MD}
startIconName={IconName.MessageQuestion}
data-testid="need-help-link"
href={SUPPORT_LINK}
display={Display.Flex}
justifyContent={JustifyContent.flexStart}
paddingLeft={4}
marginBottom={4}
onClick={this.onSupportLinkClick}
externalLink
>
{t('needHelpLinkText')}
</ButtonLink>
///: END:ONLY_INCLUDE_IN
}
</Box>
</Tab>
<Tab
activeClassName="home__tab--active"
className="home__tab"
data-testid="home__nfts-tab"
name={this.context.t('nfts')}
tabKey="nfts"
>
{
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
<NftsTab />
///: END:ONLY_INCLUDE_IN
}
{
///: BEGIN:ONLY_INCLUDE_IN(build-main)
<ButtonLink
size={Size.MD}
startIconName={IconName.MessageQuestion}
data-testid="need-help-link"
href={SUPPORT_LINK}
display={Display.Flex}
justifyContent={JustifyContent.flexStart}
paddingLeft={4}
marginBottom={4}
onClick={this.onSupportLinkClick}
externalLink
>
{t('needHelpLinkText')}
</ButtonLink>
///: END:ONLY_INCLUDE_IN
}
</Tab>
<Tab
activeClassName="home__tab--active"
className="home__tab"
data-testid="home__activity-tab"
name={t('activity')}
tabKey="activity"
>
<TransactionList />
{
///: BEGIN:ONLY_INCLUDE_IN(build-main)
<ButtonLink
size={Size.MD}
startIconName={IconName.MessageQuestion}
data-testid="need-help-link"
href={SUPPORT_LINK}
display={Display.Flex}
justifyContent={JustifyContent.center}
marginBottom={4}
marginTop={4}
onClick={this.onSupportLinkClick}
externalLink
>
{t('needHelpLinkText')}
</ButtonLink>
///: END:ONLY_INCLUDE_IN
}
</Tab>
</Tabs>
{
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
<InstitutionalHomeFooter
activitySupportDisplayStyle={activitySupportDisplayStyle}
/>
///: END:ONLY_INCLUDE_IN
}
</Box>
{
///: BEGIN:ONLY_INCLUDE_IN(build-beta)
<div className="home__support">
<BetaHomeFooter />
</div>
///: END:ONLY_INCLUDE_IN
}
{
///: BEGIN:ONLY_INCLUDE_IN(build-flask)
<div className="home__support">
<FlaskHomeFooter />
</div>
///: END:ONLY_INCLUDE_IN
}
</div>
2020-11-03 00:41:28 +01:00
{this.renderNotifications()}
</div>
</div>
);
}
}