1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-30 08:09:15 +01:00
metamask-extension/ui/components/app/nft-options/nft-options.js
Nidhi Kumari 33cc8d587a
NFT: Replaced all the instances of collectibles with NFTs (#17741)
* replaced all the instances of collectibles with nfts

* updated actions

* updated e2e seeder

* updated confirm Approve test

* updated test dapp change

* updated test dapp change

* nit fix

* nit fix

* updated casing and snapshots

* updated casinG

* added migrations

* updated ,igration

* updated 078.test

* updated tests for 078 migration

* updated migration

* updated 078 index.js
2023-02-17 00:53:29 +05:30

65 lines
1.8 KiB
JavaScript

import React, { useContext, useRef, useState } from 'react';
import PropTypes from 'prop-types';
import { I18nContext } from '../../../contexts/i18n';
import { Menu, MenuItem } from '../../ui/menu';
import { ButtonIcon, ICON_NAMES } from '../../component-library';
import { Color } from '../../../helpers/constants/design-system';
const NftOptions = ({ onRemove, onViewOnOpensea }) => {
const t = useContext(I18nContext);
const [nftOptionsOpen, setNftOptionsOpen] = useState(false);
const ref = useRef(false);
return (
<div ref={ref}>
<ButtonIcon
iconName={ICON_NAMES.MORE_VERTICAL}
className="nft-options__button"
data-testid="nft-options__button"
onClick={() => setNftOptionsOpen(true)}
color={Color.textDefault}
ariaLabel={t('nftOptions')}
/>
{nftOptionsOpen ? (
<Menu
data-testid="close-nft-options-menu"
anchorElement={ref.current}
onHide={() => setNftOptionsOpen(false)}
>
{onViewOnOpensea ? (
<MenuItem
iconName={ICON_NAMES.EXPORT}
data-testid="nft-options__view-on-opensea"
onClick={() => {
setNftOptionsOpen(false);
onViewOnOpensea();
}}
>
{t('viewOnOpensea')}
</MenuItem>
) : null}
<MenuItem
iconName={ICON_NAMES.TRASH}
data-testid="nft-item-remove"
onClick={() => {
setNftOptionsOpen(false);
onRemove();
}}
>
{t('removeNFT')}
</MenuItem>
</Menu>
) : null}
</div>
);
};
NftOptions.propTypes = {
onRemove: PropTypes.func.isRequired,
onViewOnOpensea: PropTypes.func,
};
export default NftOptions;