2021-09-20 18:22:04 +02:00
|
|
|
import React, { PureComponent } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import ToggleButton from '../../../components/ui/toggle-button';
|
2022-02-22 21:58:21 +01:00
|
|
|
import {
|
2022-04-06 22:27:08 +02:00
|
|
|
getNumberOfSettingsInSection,
|
2022-02-22 21:58:21 +01:00
|
|
|
handleSettingsRefs,
|
|
|
|
} from '../../../helpers/utils/settings-search';
|
2022-04-22 18:09:10 +02:00
|
|
|
import { EVENT } from '../../../../shared/constants/metametrics';
|
2023-01-04 22:59:48 +01:00
|
|
|
import Typography from '../../../components/ui/typography/typography';
|
2023-02-02 19:18:25 +01:00
|
|
|
import { Text } from '../../../components/component-library';
|
2023-01-04 22:59:48 +01:00
|
|
|
import {
|
|
|
|
FONT_WEIGHT,
|
2023-02-02 21:15:26 +01:00
|
|
|
TextColor,
|
|
|
|
TypographyVariant,
|
2023-01-04 22:59:48 +01:00
|
|
|
} from '../../../helpers/constants/design-system';
|
2022-03-07 19:53:19 +01:00
|
|
|
|
2021-09-20 18:22:04 +02:00
|
|
|
export default class ExperimentalTab extends PureComponent {
|
|
|
|
static contextTypes = {
|
|
|
|
t: PropTypes.func,
|
2022-03-29 15:46:24 +02:00
|
|
|
trackEvent: PropTypes.func,
|
2021-09-20 18:22:04 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static propTypes = {
|
2022-11-15 19:49:42 +01:00
|
|
|
useNftDetection: PropTypes.bool,
|
|
|
|
setUseNftDetection: PropTypes.func,
|
2021-12-01 05:12:27 +01:00
|
|
|
setOpenSeaEnabled: PropTypes.func,
|
2022-01-11 20:17:56 +01:00
|
|
|
openSeaEnabled: PropTypes.bool,
|
2022-11-17 15:13:02 +01:00
|
|
|
transactionSecurityCheckEnabled: PropTypes.bool,
|
|
|
|
setTransactionSecurityCheckEnabled: PropTypes.func,
|
2021-09-20 18:22:04 +02:00
|
|
|
};
|
|
|
|
|
2022-02-22 21:58:21 +01:00
|
|
|
settingsRefs = Array(
|
2022-04-06 22:27:08 +02:00
|
|
|
getNumberOfSettingsInSection(
|
|
|
|
this.context.t,
|
|
|
|
this.context.t('experimental'),
|
|
|
|
),
|
2022-02-22 21:58:21 +01:00
|
|
|
)
|
|
|
|
.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);
|
|
|
|
}
|
|
|
|
|
2021-12-01 05:12:27 +01:00
|
|
|
renderOpenSeaEnabledToggle() {
|
|
|
|
const { t } = this.context;
|
2022-01-27 18:26:33 +01:00
|
|
|
const {
|
|
|
|
openSeaEnabled,
|
|
|
|
setOpenSeaEnabled,
|
2022-11-15 19:49:42 +01:00
|
|
|
useNftDetection,
|
|
|
|
setUseNftDetection,
|
2022-01-27 18:26:33 +01:00
|
|
|
} = this.props;
|
2021-12-01 05:12:27 +01:00
|
|
|
|
|
|
|
return (
|
2023-01-31 19:50:53 +01:00
|
|
|
<>
|
|
|
|
<div ref={this.settingsRefs[0]} className="settings-page__content-row">
|
|
|
|
<div className="settings-page__content-item">
|
|
|
|
<span>{t('enableOpenSeaAPI')}</span>
|
|
|
|
<div className="settings-page__content-description">
|
|
|
|
{t('enableOpenSeaAPIDescription')}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="settings-page__content-item">
|
|
|
|
<div className="settings-page__content-item-col">
|
|
|
|
<ToggleButton
|
|
|
|
value={openSeaEnabled}
|
|
|
|
onToggle={(value) => {
|
|
|
|
this.context.trackEvent({
|
|
|
|
category: EVENT.CATEGORIES.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')}
|
|
|
|
/>
|
|
|
|
</div>
|
2021-12-01 05:12:27 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-01-31 19:50:53 +01:00
|
|
|
<div ref={this.settingsRefs[1]} className="settings-page__content-row">
|
|
|
|
<div className="settings-page__content-item">
|
|
|
|
<span>{t('useCollectibleDetection')}</span>
|
|
|
|
<div className="settings-page__content-description">
|
2023-02-02 21:15:26 +01:00
|
|
|
<Text color={TextColor.textAlternative}>
|
2023-02-02 19:18:25 +01:00
|
|
|
{t('useCollectibleDetectionDescription')}
|
|
|
|
</Text>
|
2023-01-31 19:50:53 +01:00
|
|
|
<ul className="settings-page__content-unordered-list">
|
2023-02-02 19:18:25 +01:00
|
|
|
<li>{t('useCollectibleDetectionDescriptionLine2')}</li>
|
2023-01-31 19:50:53 +01:00
|
|
|
<li>{t('useCollectibleDetectionDescriptionLine3')}</li>
|
|
|
|
<li>{t('useCollectibleDetectionDescriptionLine4')}</li>
|
|
|
|
</ul>
|
2023-02-02 21:15:26 +01:00
|
|
|
<Text color={TextColor.textAlternative} paddingTop={4}>
|
2023-02-02 19:18:25 +01:00
|
|
|
{t('useCollectibleDetectionDescriptionLine5')}
|
|
|
|
</Text>
|
2023-01-31 19:50:53 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="settings-page__content-item">
|
|
|
|
<div className="settings-page__content-item-col">
|
|
|
|
<ToggleButton
|
|
|
|
value={useNftDetection}
|
|
|
|
onToggle={(value) => {
|
|
|
|
this.context.trackEvent({
|
|
|
|
category: EVENT.CATEGORIES.SETTINGS,
|
|
|
|
event: 'Collectible Detection',
|
|
|
|
properties: {
|
|
|
|
action: 'Collectible Detection',
|
|
|
|
legacy_event: true,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
if (!value && !openSeaEnabled) {
|
|
|
|
setOpenSeaEnabled(!value);
|
|
|
|
}
|
|
|
|
setUseNftDetection(!value);
|
|
|
|
}}
|
|
|
|
offLabel={t('off')}
|
|
|
|
onLabel={t('on')}
|
|
|
|
/>
|
|
|
|
</div>
|
2021-12-01 05:12:27 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-01-31 19:50:53 +01:00
|
|
|
</>
|
2021-12-01 05:12:27 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-11-17 15:13:02 +01:00
|
|
|
renderTransactionSecurityCheckToggle() {
|
|
|
|
const { t } = this.context;
|
|
|
|
|
|
|
|
const {
|
|
|
|
transactionSecurityCheckEnabled,
|
|
|
|
setTransactionSecurityCheckEnabled,
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
return (
|
2023-01-04 22:59:48 +01:00
|
|
|
<>
|
|
|
|
<Typography
|
2023-02-02 21:15:26 +01:00
|
|
|
variant={TypographyVariant.H4}
|
|
|
|
color={TextColor.textAlternative}
|
2023-01-04 22:59:48 +01:00
|
|
|
marginBottom={2}
|
|
|
|
fontWeight={FONT_WEIGHT.BOLD}
|
|
|
|
>
|
|
|
|
{t('privacy')}
|
|
|
|
</Typography>
|
|
|
|
<div
|
|
|
|
ref={this.settingsRefs[1]}
|
|
|
|
className="settings-page__content-row settings-page__content-row-experimental"
|
|
|
|
>
|
|
|
|
<div className="settings-page__content-item">
|
|
|
|
<span>{t('transactionSecurityCheck')}</span>
|
|
|
|
<div className="settings-page__content-description">
|
|
|
|
<Typography
|
2023-02-02 21:15:26 +01:00
|
|
|
variant={TypographyVariant.H6}
|
|
|
|
color={TextColor.textAlternative}
|
2023-01-04 22:59:48 +01:00
|
|
|
>
|
|
|
|
{t('transactionSecurityCheckDescription')}
|
|
|
|
</Typography>
|
|
|
|
<Typography
|
|
|
|
marginTop={3}
|
|
|
|
marginBottom={1}
|
2023-02-02 21:15:26 +01:00
|
|
|
variant={TypographyVariant.H6}
|
|
|
|
color={TextColor.textAlternative}
|
2023-01-04 22:59:48 +01:00
|
|
|
>
|
|
|
|
{t('selectProvider')}
|
|
|
|
</Typography>
|
|
|
|
<div className="settings-page__content-item-col settings-page__content-item-col-open-sea">
|
|
|
|
<Typography
|
2023-02-02 21:15:26 +01:00
|
|
|
variant={TypographyVariant.H5}
|
|
|
|
color={TextColor.textDefault}
|
2023-01-04 22:59:48 +01:00
|
|
|
fontWeight={FONT_WEIGHT.MEDIUM}
|
|
|
|
marginBottom={0}
|
|
|
|
>
|
|
|
|
{t('openSea')}
|
|
|
|
</Typography>
|
|
|
|
<ToggleButton
|
|
|
|
value={transactionSecurityCheckEnabled}
|
|
|
|
onToggle={(value) => {
|
|
|
|
this.context.trackEvent({
|
|
|
|
category: EVENT.CATEGORIES.SETTINGS,
|
|
|
|
event: 'Enabled/Disable TransactionSecurityCheck',
|
|
|
|
properties: {
|
|
|
|
action: 'Enabled/Disable TransactionSecurityCheck',
|
|
|
|
legacy_event: true,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
setTransactionSecurityCheckEnabled(!value);
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<Typography
|
2023-02-02 21:15:26 +01:00
|
|
|
variant={TypographyVariant.H6}
|
|
|
|
color={TextColor.textAlternative}
|
2023-01-04 22:59:48 +01:00
|
|
|
marginTop={0}
|
|
|
|
>
|
|
|
|
{t('thisServiceIsExperimental')}
|
|
|
|
</Typography>
|
|
|
|
<Typography
|
2023-02-02 21:15:26 +01:00
|
|
|
variant={TypographyVariant.H5}
|
|
|
|
color={TextColor.textMuted}
|
2023-01-04 22:59:48 +01:00
|
|
|
fontWeight={FONT_WEIGHT.MEDIUM}
|
|
|
|
marginTop={2}
|
|
|
|
>
|
|
|
|
{t('moreComingSoon')}
|
|
|
|
</Typography>
|
|
|
|
</div>
|
2022-11-17 15:13:02 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-01-04 22:59:48 +01:00
|
|
|
</>
|
2022-11-17 15:13:02 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-09-20 18:22:04 +02:00
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<div className="settings-page__body">
|
2022-12-06 15:43:53 +01:00
|
|
|
{process.env.TRANSACTION_SECURITY_PROVIDER &&
|
|
|
|
this.renderTransactionSecurityCheckToggle()}
|
2023-01-31 19:50:53 +01:00
|
|
|
{process.env.NFTS_V1 && this.renderOpenSeaEnabledToggle()}
|
2021-09-20 18:22:04 +02:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|