import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; import ToggleButton from '../../../components/ui/toggle-button'; import { getNumberOfSettingsInSection, handleSettingsRefs, } from '../../../helpers/utils/settings-search'; import { MetaMetricsEventCategory } from '../../../../shared/constants/metametrics'; import Typography from '../../../components/ui/typography/typography'; import { Text } from '../../../components/component-library'; import { FONT_WEIGHT, TextColor, TypographyVariant, } from '../../../helpers/constants/design-system'; ///: BEGIN:ONLY_INCLUDE_IN(desktop) import DesktopEnableButton from '../../../components/app/desktop-enable-button'; ///: END:ONLY_INCLUDE_IN export default class ExperimentalTab extends PureComponent { static contextTypes = { t: PropTypes.func, trackEvent: PropTypes.func, }; static propTypes = { useNftDetection: PropTypes.bool, setUseNftDetection: PropTypes.func, setOpenSeaEnabled: PropTypes.func, openSeaEnabled: PropTypes.bool, transactionSecurityCheckEnabled: PropTypes.bool, setTransactionSecurityCheckEnabled: PropTypes.func, }; settingsRefs = Array( getNumberOfSettingsInSection( this.context.t, this.context.t('experimental'), ), ) .fill(undefined) .map(() => { return React.createRef(); }); componentDidUpdate() { const { t } = this.context; handleSettingsRefs(t, t('experimental'), this.settingsRefs); } componentDidMount() { const { t } = this.context; handleSettingsRefs(t, t('experimental'), this.settingsRefs); } renderOpenSeaEnabledToggle() { const { t } = this.context; const { openSeaEnabled, setOpenSeaEnabled, useNftDetection, setUseNftDetection, } = this.props; return ( <>
{t('enableOpenSeaAPI')}
{t('enableOpenSeaAPIDescription')}
{ this.context.trackEvent({ category: MetaMetricsEventCategory.Settings, event: 'Enabled/Disable OpenSea', properties: { action: 'Enabled/Disable OpenSea', legacy_event: true, }, }); // value is positive when being toggled off if (value && useNftDetection) { setUseNftDetection(false); } setOpenSeaEnabled(!value); }} offLabel={t('off')} onLabel={t('on')} />
{t('useNftDetection')}
{t('useNftDetectionDescription')}
  • {t('useNftDetectionDescriptionLine2')}
  • {t('useNftDetectionDescriptionLine3')}
  • {t('useNftDetectionDescriptionLine4')}
{t('useNftDetectionDescriptionLine5')}
{ this.context.trackEvent({ category: MetaMetricsEventCategory.Settings, event: 'NFT Detected', properties: { action: 'NFT Detected', legacy_event: true, }, }); if (!value && !openSeaEnabled) { setOpenSeaEnabled(!value); } setUseNftDetection(!value); }} offLabel={t('off')} onLabel={t('on')} />
); } renderTransactionSecurityCheckToggle() { const { t } = this.context; const { transactionSecurityCheckEnabled, setTransactionSecurityCheckEnabled, } = this.props; return ( <> {t('privacy')}
{t('transactionSecurityCheck')}
{t('transactionSecurityCheckDescription')} {t('selectProvider')}
{t('openSea')} { this.context.trackEvent({ category: MetaMetricsEventCategory.Settings, event: 'Enabled/Disable TransactionSecurityCheck', properties: { action: 'Enabled/Disable TransactionSecurityCheck', legacy_event: true, }, }); setTransactionSecurityCheckEnabled(!value); }} />
{t('thisServiceIsExperimental', [ {t('termsOfUse')} , ])} {t('moreComingSoon')}
); } ///: BEGIN:ONLY_INCLUDE_IN(desktop) renderDesktopEnableButton() { const { t } = this.context; return (
{t('desktopEnableButtonDescription')}
); } ///: END:ONLY_INCLUDE_IN render() { return (
{this.renderTransactionSecurityCheckToggle()} {this.renderOpenSeaEnabledToggle()} { ///: BEGIN:ONLY_INCLUDE_IN(desktop) this.renderDesktopEnableButton() ///: END:ONLY_INCLUDE_IN }
); } }