mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
49a525b9f8
* Add `react/no-unused-prop-types` rule All detected unused prop types have been removed. I have attempted to ensure these props are no longer passed in either. * Update handling of props to avoid false positive lint errors These cases were detected by `react/no-unused-prop-types` as being unused props, even though they were used. These minor adjustments prevent them from being flagged as errors. * Update unit tests Many of these tests were just checking that specific props were passed from containers or to a child component. These were deleted, as I can't imagine how they'd be useful. * Disable `react/no-unused-prop-types` in `componentWillReceiveProps The rule `react/no-unused-prop-types` doesn't seem to be detecting props used within `UNSAFE_componentWillReceiveProps`. The two cases have been disabled temporarily until we can replace these unsafe lifecycle functions.
125 lines
3.8 KiB
JavaScript
125 lines
3.8 KiB
JavaScript
import React, { PureComponent } from 'react'
|
|
import PropTypes from 'prop-types'
|
|
import ToggleButton from '../../../components/ui/toggle-button'
|
|
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,
|
|
participateInMetaMetrics: PropTypes.bool,
|
|
setParticipateInMetaMetrics: PropTypes.func,
|
|
showIncomingTransactions: PropTypes.bool,
|
|
setShowIncomingTransactionsFeatureFlag: PropTypes.func,
|
|
}
|
|
|
|
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
|
|
type="danger"
|
|
large
|
|
onClick={event => {
|
|
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}
|
|
onToggle={value => setParticipateInMetaMetrics(!value)}
|
|
offLabel={t('off')}
|
|
onLabel={t('on')}
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
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}
|
|
onToggle={value => setShowIncomingTransactionsFeatureFlag(!value)}
|
|
offLabel={t('off')}
|
|
onLabel={t('on')}
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
renderContent () {
|
|
const { warning } = this.props
|
|
|
|
return (
|
|
<div className="settings-page__body">
|
|
{ warning && <div className="settings-tab__error">{ warning }</div> }
|
|
{ this.renderSeedWords() }
|
|
{ this.renderIncomingTransactionsOptIn() }
|
|
{ this.renderMetaMetricsOptIn() }
|
|
</div>
|
|
)
|
|
}
|
|
|
|
render () {
|
|
return this.renderContent()
|
|
}
|
|
}
|