mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-04 23:14:56 +01:00
14efbf1eea
* Add ipfs gateway and collectible state to mock-state.json * Add collectible-default-image test with snapshot and testids * Add Collectible Details test, snapshot, and test-ids * Add Collectible Options tests and test-ids * Add Collectible Items test and test-ids. * Add more tests to Add Collectible component * Update Security Tab snapshot with ipfs gateway state value * Add data-testid to Menu component for menu background * Lint * Bump coverage targets * Remove commented import --------- Co-authored-by: David Walsh <davidwalsh83@gmail.com>
62 lines
1.8 KiB
JavaScript
62 lines
1.8 KiB
JavaScript
import React, { useContext, useState } from 'react';
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { I18nContext } from '../../../contexts/i18n';
|
|
import { Menu, MenuItem } from '../../ui/menu';
|
|
import { ICON_NAMES } from '../../component-library';
|
|
|
|
const CollectibleOptions = ({ onRemove, onViewOnOpensea }) => {
|
|
const t = useContext(I18nContext);
|
|
const [collectibleOptionsButtonElement, setCollectibleOptionsButtonElement] =
|
|
useState(null);
|
|
const [collectibleOptionsOpen, setCollectibleOptionsOpen] = useState(false);
|
|
|
|
return (
|
|
<>
|
|
<button
|
|
className="fas fa-ellipsis-v collectible-options__button"
|
|
data-testid="collectible-options__button"
|
|
onClick={() => setCollectibleOptionsOpen(true)}
|
|
ref={setCollectibleOptionsButtonElement}
|
|
/>
|
|
{collectibleOptionsOpen ? (
|
|
<Menu
|
|
anchorElement={collectibleOptionsButtonElement}
|
|
data-testid="close-collectible-options-menu"
|
|
onHide={() => setCollectibleOptionsOpen(false)}
|
|
>
|
|
{onViewOnOpensea ? (
|
|
<MenuItem
|
|
iconName={ICON_NAMES.EXPORT}
|
|
data-testid="collectible-options__view-on-opensea"
|
|
onClick={() => {
|
|
setCollectibleOptionsOpen(false);
|
|
onViewOnOpensea();
|
|
}}
|
|
>
|
|
{t('viewOnOpensea')}
|
|
</MenuItem>
|
|
) : null}
|
|
<MenuItem
|
|
iconName={ICON_NAMES.TRASH}
|
|
data-testid="collectible-item-remove"
|
|
onClick={() => {
|
|
setCollectibleOptionsOpen(false);
|
|
onRemove();
|
|
}}
|
|
>
|
|
{t('removeNFT')}
|
|
</MenuItem>
|
|
</Menu>
|
|
) : null}
|
|
</>
|
|
);
|
|
};
|
|
|
|
CollectibleOptions.propTypes = {
|
|
onRemove: PropTypes.func.isRequired,
|
|
onViewOnOpensea: PropTypes.func,
|
|
};
|
|
|
|
export default CollectibleOptions;
|