2019-03-25 17:13:23 +01:00
|
|
|
import React, { PureComponent } from 'react'
|
|
|
|
import PropTypes from 'prop-types'
|
2019-07-08 19:58:35 +02:00
|
|
|
import ToggleButton from '../../../components/ui/toggle-button'
|
2019-03-25 17:13:23 +01:00
|
|
|
import { REVEAL_SEED_ROUTE } from '../../../helpers/constants/routes'
|
|
|
|
import Button from '../../../components/ui/button'
|
|
|
|
|
|
|
|
export default class SecurityTab extends PureComponent {
|
|
|
|
static contextTypes = {
|
|
|
|
t: PropTypes.func,
|
|
|
|
metricsEvent: PropTypes.func,
|
|
|
|
}
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
warning: PropTypes.string,
|
|
|
|
history: PropTypes.object,
|
2020-02-27 07:29:41 +01:00
|
|
|
participateInMetaMetrics: PropTypes.bool.isRequired,
|
|
|
|
setParticipateInMetaMetrics: PropTypes.func.isRequired,
|
|
|
|
showIncomingTransactions: PropTypes.bool.isRequired,
|
|
|
|
setShowIncomingTransactionsFeatureFlag: PropTypes.func.isRequired,
|
|
|
|
setUsePhishDetect: PropTypes.func.isRequired,
|
|
|
|
usePhishDetect: PropTypes.bool.isRequired,
|
2019-03-25 17:13:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
renderSeedWords () {
|
|
|
|
const { t } = this.context
|
|
|
|
const { history } = this.props
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="settings-page__content-row">
|
|
|
|
<div className="settings-page__content-item">
|
|
|
|
<span>{ t('revealSeedWords') }</span>
|
|
|
|
</div>
|
|
|
|
<div className="settings-page__content-item">
|
|
|
|
<div className="settings-page__content-item-col">
|
|
|
|
<Button
|
2019-04-16 21:35:22 +02:00
|
|
|
type="danger"
|
2019-03-25 17:13:23 +01:00
|
|
|
large
|
2020-02-15 21:34:12 +01:00
|
|
|
onClick={(event) => {
|
2019-03-25 17:13:23 +01:00
|
|
|
event.preventDefault()
|
|
|
|
this.context.metricsEvent({
|
|
|
|
eventOpts: {
|
|
|
|
category: 'Settings',
|
|
|
|
action: 'Reveal Seed Phrase',
|
|
|
|
name: 'Reveal Seed Phrase',
|
|
|
|
},
|
|
|
|
})
|
|
|
|
history.push(REVEAL_SEED_ROUTE)
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{ t('revealSeedWords') }
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
renderMetaMetricsOptIn () {
|
|
|
|
const { t } = this.context
|
|
|
|
const { participateInMetaMetrics, setParticipateInMetaMetrics } = this.props
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="settings-page__content-row">
|
|
|
|
<div className="settings-page__content-item">
|
|
|
|
<span>{ t('participateInMetaMetrics') }</span>
|
|
|
|
<div className="settings-page__content-description">
|
|
|
|
<span>{ t('participateInMetaMetricsDescription') }</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="settings-page__content-item">
|
|
|
|
<div className="settings-page__content-item-col">
|
|
|
|
<ToggleButton
|
|
|
|
value={participateInMetaMetrics}
|
2020-02-15 21:34:12 +01:00
|
|
|
onToggle={(value) => setParticipateInMetaMetrics(!value)}
|
2019-07-08 19:58:35 +02:00
|
|
|
offLabel={t('off')}
|
|
|
|
onLabel={t('on')}
|
2019-03-25 17:13:23 +01:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2019-08-21 20:42:14 +02:00
|
|
|
renderIncomingTransactionsOptIn () {
|
|
|
|
const { t } = this.context
|
|
|
|
const { showIncomingTransactions, setShowIncomingTransactionsFeatureFlag } = this.props
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="settings-page__content-row">
|
|
|
|
<div className="settings-page__content-item">
|
|
|
|
<span>{ t('showIncomingTransactions') }</span>
|
|
|
|
<div className="settings-page__content-description">
|
|
|
|
{ t('showIncomingTransactionsDescription') }
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="settings-page__content-item">
|
|
|
|
<div className="settings-page__content-item-col">
|
|
|
|
<ToggleButton
|
|
|
|
value={showIncomingTransactions}
|
2020-02-15 21:34:12 +01:00
|
|
|
onToggle={(value) => setShowIncomingTransactionsFeatureFlag(!value)}
|
2019-08-21 20:42:14 +02:00
|
|
|
offLabel={t('off')}
|
|
|
|
onLabel={t('on')}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2020-02-27 07:29:41 +01:00
|
|
|
renderPhishingDetectionToggle () {
|
|
|
|
const { t } = this.context
|
|
|
|
const { usePhishDetect, setUsePhishDetect } = this.props
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="settings-page__content-row">
|
|
|
|
<div className="settings-page__content-item">
|
|
|
|
<span>{ t('usePhishingDetection') }</span>
|
|
|
|
<div className="settings-page__content-description">
|
|
|
|
{ t('usePhishingDetectionDescription') }
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="settings-page__content-item">
|
|
|
|
<div className="settings-page__content-item-col">
|
|
|
|
<ToggleButton
|
|
|
|
value={usePhishDetect}
|
|
|
|
onToggle={(value) => setUsePhishDetect(!value)}
|
|
|
|
offLabel={t('off')}
|
|
|
|
onLabel={t('on')}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2020-05-08 02:55:25 +02:00
|
|
|
render () {
|
2019-03-25 17:13:23 +01:00
|
|
|
const { warning } = this.props
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="settings-page__body">
|
|
|
|
{ warning && <div className="settings-tab__error">{ warning }</div> }
|
|
|
|
{ this.renderSeedWords() }
|
2019-08-21 20:42:14 +02:00
|
|
|
{ this.renderIncomingTransactionsOptIn() }
|
2020-02-27 07:29:41 +01:00
|
|
|
{ this.renderPhishingDetectionToggle() }
|
2019-03-25 17:13:23 +01:00
|
|
|
{ this.renderMetaMetricsOptIn() }
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|