mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-30 08:09:15 +01:00
f5e86d0351
* fix error with color variable - fix rebase * clean list search & fuse threshold decreased * update search-icon , fix tests * nice to have highlighting text & cleaning * unit test on settings & search input ui up on expanded view * fix color variable in alert scss * setting search input padding right up * fix dom warning * util/search test added & Dom element warning fix * renaming files * fix color text in settings search * settings search highlight text refacto & fix ui * fix settings-search test & renaming * Fix styling on search field for edge cases, update components and e2e E2E tests update for search feature Update components from class to functional component # Fix storybook for search box Fix styling Fix unit tests fix: remove z-index Fix unit tests Co-authored-by: amerkadicE <amer.kadic@endava.com>
86 lines
2.5 KiB
JavaScript
86 lines
2.5 KiB
JavaScript
import React, { useEffect, useRef } from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { useSelector } from 'react-redux';
|
|
|
|
import { ALERT_TYPES } from '../../../../shared/constants/alerts';
|
|
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';
|
|
import { handleHooksSettingsRefs } from '../../../helpers/utils/settings-search';
|
|
|
|
const AlertSettingsEntry = ({ alertId, description, title, alertIndex }) => {
|
|
const t = useI18nContext();
|
|
const settingsRefs = useRef(alertIndex);
|
|
|
|
useEffect(() => {
|
|
handleHooksSettingsRefs(t, t('alerts'), settingsRefs, alertIndex);
|
|
}, [settingsRefs, t, alertIndex]);
|
|
|
|
const isEnabled = useSelector((state) => getAlertEnabledness(state)[alertId]);
|
|
|
|
return (
|
|
<>
|
|
<div ref={settingsRefs} className="alerts-tab__item">
|
|
<span>{title}</span>
|
|
<div className="alerts-tab__description-container">
|
|
<Tooltip
|
|
position="top"
|
|
title={description}
|
|
wrapperClassName="alerts-tab__description"
|
|
>
|
|
<i className="fa fa-info-circle" />
|
|
</Tooltip>
|
|
<ToggleButton
|
|
offLabel={t('off')}
|
|
onLabel={t('on')}
|
|
onToggle={() => setAlertEnabledness(alertId, !isEnabled)}
|
|
value={isEnabled}
|
|
/>
|
|
</div>
|
|
</div>
|
|
</>
|
|
);
|
|
};
|
|
|
|
AlertSettingsEntry.propTypes = {
|
|
alertId: PropTypes.string.isRequired,
|
|
description: PropTypes.string.isRequired,
|
|
title: PropTypes.string.isRequired,
|
|
alertIndex: PropTypes.number.isRequired,
|
|
};
|
|
|
|
const AlertsTab = () => {
|
|
const t = useI18nContext();
|
|
|
|
const alertConfig = {
|
|
[ALERT_TYPES.unconnectedAccount]: {
|
|
title: t('alertSettingsUnconnectedAccount'),
|
|
description: t('alertSettingsUnconnectedAccountDescription'),
|
|
},
|
|
[ALERT_TYPES.web3ShimUsage]: {
|
|
title: t('alertSettingsWeb3ShimUsage'),
|
|
description: t('alertSettingsWeb3ShimUsageDescription'),
|
|
},
|
|
};
|
|
|
|
return (
|
|
<div className="alerts-tab__body">
|
|
{Object.entries(alertConfig).map(
|
|
([alertId, { title, description }], index) => (
|
|
<AlertSettingsEntry
|
|
alertId={alertId}
|
|
description={description}
|
|
key={alertId}
|
|
title={title}
|
|
alertIndex={index}
|
|
/>
|
|
),
|
|
)}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default AlertsTab;
|