1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-23 11:46:13 +02:00
metamask-extension/ui/app/pages/settings/alerts-tab/alerts-tab.js
Brad Decker d5a539e0e5
remove old tooltip component and styles (#9250)
The old tooltip component was only used in two places. Removing those usages
was simple and straight forward. So, instead of colocating the old tooltip
styles with the deprecated tooltip component, I removed all old styles and
made tooltip-v2 now simply 'tooltip' and removed the deprecated component.
2020-08-18 11:13:55 -05:00

72 lines
1.9 KiB
JavaScript

import React from 'react'
import PropTypes from 'prop-types'
import { useDispatch, useSelector } from 'react-redux'
import { ALERT_TYPES } from '../../../../../app/scripts/controllers/alert'
import Tooltip from '../../../components/ui/tooltip'
import ToggleButton from '../../../components/ui/toggle-button'
import { setAlertEnabledness } from '../../../store/actions'
import { getAlertEnabledness } from '../../../ducks/metamask/metamask'
import { useI18nContext } from '../../../hooks/useI18nContext'
const AlertSettingsEntry = ({ alertId, description, title }) => {
const t = useI18nContext()
const dispatch = useDispatch()
const isEnabled = useSelector((state) => getAlertEnabledness(state)[alertId])
return (
<>
<span>
{ title }
</span>
<Tooltip
position="top"
title={description}
wrapperClassName="alerts-tab__description"
>
<i className="fa fa-info-circle" />
</Tooltip>
<ToggleButton
offLabel={t('off')}
onLabel={t('on')}
onToggle={() => dispatch(setAlertEnabledness(alertId, !isEnabled))}
value={isEnabled}
/>
</>
)
}
AlertSettingsEntry.propTypes = {
alertId: PropTypes.string.isRequired,
description: PropTypes.string.isRequired,
title: PropTypes.string.isRequired,
}
const AlertsTab = () => {
const t = useI18nContext()
const alertConfig = {
[ALERT_TYPES.unconnectedAccount]: {
title: t('alertSettingsUnconnectedAccount'),
description: t('alertSettingsUnconnectedAccountDescription'),
},
}
return (
<div className="alerts-tab__body">
{
Object.entries(alertConfig).map(([alertId, { title, description }]) => (
<AlertSettingsEntry
alertId={alertId}
description={description}
key={alertId}
title={title}
/>
))
}
</div>
)
}
export default AlertsTab