1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-26 12:29:06 +01:00
metamask-extension/ui/components/multichain/multichain-import-token-link/multichain-import-token-link.js
Nidhi Kumari fcfb8a8938
UX: Multichain: Added TokenList Component (#17859)
* added redesign storybook

* updated token list

* updated css

* fixed lint error

* updated the new token list component

* fixed redesign folder error

* reverted changes in settings.json

* updated redesign to multichain

* added feature flag

* reverted settings.json

* added detect token banner

* added button componeny

* fixed lint errors

* removed settings

* fixed lint errors

* added stories for multichain

* updated no token found string

* updated lint error

* updated padding values

* updated padding values

* updated tabs with role button

* updated hover state

* updated components with multichain

* fixed lint errors

* updated multichain import token link

* updated a tag

* updated fixes

* updated onClick to handleClick

* updated setShowDetectedTokens proptype

* updated multichain tokenlist with item suffix

* updated tests

* updated tests

* updated token list css

* updated snapshot

* updated text

* reverted story

* added story for multichain token list

* updated story

* updated tooltip

* updated the new token list component

* fixed redesign folder error

* added feature flag

* reverted unused setting change

* removed token list

* fixed lint error

* updated status

* updated tooltip

* updated token-list-item changes

* updated actionbutton click for detect token banner

* updated snapshot

* updated symbol

* updated styles

* updated eth decimal and token url

* updated snapshot

* updated scripts

* updated snapshots
2023-03-23 15:38:33 +05:30

88 lines
2.7 KiB
JavaScript

import React, { useContext } from 'react';
import { useSelector } from 'react-redux';
import { useHistory } from 'react-router-dom';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import Box from '../../ui/box/box';
import { ButtonLink, ICON_NAMES } from '../../component-library';
import {
AlignItems,
DISPLAY,
Size,
} from '../../../helpers/constants/design-system';
import { useI18nContext } from '../../../hooks/useI18nContext';
import { IMPORT_TOKEN_ROUTE } from '../../../helpers/constants/routes';
import { detectNewTokens } from '../../../store/actions';
import { MetaMetricsContext } from '../../../contexts/metametrics';
import { EVENT, EVENT_NAMES } from '../../../../shared/constants/metametrics';
import {
getIsTokenDetectionSupported,
getIsTokenDetectionInactiveOnMainnet,
} from '../../../selectors';
export const MultichainImportTokenLink = ({ className, ...props }) => {
const trackEvent = useContext(MetaMetricsContext);
const t = useI18nContext();
const history = useHistory();
const isTokenDetectionSupported = useSelector(getIsTokenDetectionSupported);
const isTokenDetectionInactiveOnMainnet = useSelector(
getIsTokenDetectionInactiveOnMainnet,
);
const isTokenDetectionAvailable =
isTokenDetectionSupported ||
isTokenDetectionInactiveOnMainnet ||
Boolean(process.env.IN_TEST);
return (
<Box
className={classnames('multichain-import-token-link', className)}
{...props}
>
<Box display={DISPLAY.FLEX} alignItems={AlignItems.center}>
<ButtonLink
size={Size.MD}
data-testid="import-token-button"
startIconName={ICON_NAMES.ADD}
onClick={() => {
history.push(IMPORT_TOKEN_ROUTE);
trackEvent({
event: EVENT_NAMES.TOKEN_IMPORT_BUTTON_CLICKED,
category: EVENT.CATEGORIES.NAVIGATION,
properties: {
location: 'Home',
},
});
}}
>
{isTokenDetectionAvailable
? t('importTokensCamelCase')
: t('importTokensCamelCase').charAt(0).toUpperCase() +
t('importTokensCamelCase').slice(1)}
</ButtonLink>
</Box>
<Box
display={DISPLAY.FLEX}
alignItems={AlignItems.center}
paddingBottom={4}
paddingTop={4}
>
<ButtonLink
startIconName={ICON_NAMES.REFRESH}
data-testid="refresh-list-button"
onClick={() => detectNewTokens()}
>
{t('refreshList')}
</ButtonLink>
</Box>
</Box>
);
};
MultichainImportTokenLink.propTypes = {
/**
* An additional className to apply to the TokenList.
*/
className: PropTypes.string,
};