import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; import ToggleButton from '../../../components/ui/toggle-button'; export default class ExperimentalTab extends PureComponent { static contextTypes = { t: PropTypes.func, metricsEvent: PropTypes.func, }; static propTypes = { useTokenDetection: PropTypes.bool, setUseTokenDetection: PropTypes.func, useCollectibleDetection: PropTypes.bool, setUseCollectibleDetection: PropTypes.func, setOpenSeaEnabled: PropTypes.func, openSeaEnabled: PropTypes.bool, eip1559V2Enabled: PropTypes.bool, setEIP1559V2Enabled: PropTypes.func, }; renderTokenDetectionToggle() { const { t } = this.context; const { useTokenDetection, setUseTokenDetection } = this.props; return (
{t('useTokenDetection')}
{t('useTokenDetectionDescription')}
{ this.context.metricsEvent({ eventOpts: { category: 'Settings', action: 'Token Detection', name: 'Token Detection', }, }); setUseTokenDetection(!value); }} offLabel={t('off')} onLabel={t('on')} />
); } renderCollectibleDetectionToggle() { if (!process.env.COLLECTIBLES_V1) { return null; } const { t } = this.context; const { useCollectibleDetection, setUseCollectibleDetection, openSeaEnabled, setOpenSeaEnabled, } = this.props; return (
{t('useCollectibleDetection')}
{t('useCollectibleDetectionDescription')}
{ this.context.metricsEvent({ eventOpts: { category: 'Settings', action: 'Collectible Detection', name: 'Collectible Detection', }, }); if (!value && !openSeaEnabled) { setOpenSeaEnabled(!value); } setUseCollectibleDetection(!value); }} offLabel={t('off')} onLabel={t('on')} />
); } renderOpenSeaEnabledToggle() { if (!process.env.COLLECTIBLES_V1) { return null; } const { t } = this.context; const { openSeaEnabled, setOpenSeaEnabled, useCollectibleDetection, setUseCollectibleDetection, } = this.props; return (
{t('enableOpenSeaAPI')}
{t('enableOpenSeaAPIDescription')}
{ this.context.metricsEvent({ eventOpts: { category: 'Settings', action: 'Enabled/Disable OpenSea', name: 'Enabled/Disable OpenSea', }, }); // value is positive when being toggled off if (value && useCollectibleDetection) { setUseCollectibleDetection(false); } setOpenSeaEnabled(!value); }} offLabel={t('off')} onLabel={t('on')} />
); } renderEIP1559V2EnabledToggle() { const { t } = this.context; const { eip1559V2Enabled, setEIP1559V2Enabled } = this.props; return (
{t('enableEIP1559V2')}
{t('enableEIP1559V2Description', [ {t('learnMoreUpperCase')} , ])}
{ this.context.metricsEvent({ eventOpts: { category: 'Settings', action: 'Enabled/Disable OpenSea', name: 'Enabled/Disable OpenSea', }, }); setEIP1559V2Enabled(!value); }} offLabel={t('off')} onLabel={t('on')} />
); } render() { return (
{this.renderTokenDetectionToggle()} {this.renderOpenSeaEnabledToggle()} {this.renderCollectibleDetectionToggle()} {this.renderEIP1559V2EnabledToggle()}
); } }