1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 10:30:04 +01:00
metamask-extension/ui/pages/swaps/awaiting-swap/view-on-ether-scan-link/view-on-ether-scan-link.js
Akintayo A. Olusegun 08dff86be0
Add target object word to "View on Etherscan" links (#12100)
* Add target object word to "View on Etherscan" links
Fix for: #9476

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Fix Swap tests checking for View $1 at or View $1 on

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Linter Fixes

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Fix  ui/hooks/useTransactionDisplayData.test.js expected result should
be May 13, 2020

Update Jest snapshot for view on etherscan test

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Add description of the variables in messages.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* 1. localize all of the blockExplorerViewAction values
2. Apply this nit. https://github.com/MetaMask/metamask-extension/pull/12100#discussion_r708343532

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Lint fixes.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Fix locale value not used on GUI error lint error.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Reverted this commit, on circle ci, the date is May 12.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Add description to link block explore actions to where it's used.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Fix missing messages.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
2021-09-24 21:14:07 +04:00

51 lines
1.5 KiB
JavaScript

import React, { useContext } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { I18nContext } from '../../../../contexts/i18n';
import { useNewMetricEvent } from '../../../../hooks/useMetricEvent';
import { getURLHostName } from '../../../../helpers/utils/util';
export default function ViewOnEtherScanLink({
txHash,
blockExplorerUrl,
isCustomBlockExplorerUrl,
}) {
const t = useContext(I18nContext);
const blockExplorerLinkClickedEvent = useNewMetricEvent({
category: 'Swaps',
event: 'Clicked Block Explorer Link',
properties: {
link_type: 'Transaction Block Explorer',
action: 'Swap Transaction',
block_explorer_domain: getURLHostName(blockExplorerUrl),
},
});
return (
<div
className={classnames('awaiting-swap__view-on-etherscan', {
'awaiting-swap__view-on-etherscan--visible': txHash,
'awaiting-swap__view-on-etherscan--invisible': !txHash,
})}
onClick={() => {
blockExplorerLinkClickedEvent();
global.platform.openTab({ url: blockExplorerUrl });
}}
>
{isCustomBlockExplorerUrl
? t('viewOnCustomBlockExplorer', [
t('blockExplorerSwapAction'),
getURLHostName(blockExplorerUrl),
])
: t('viewOnEtherscan', [t('blockExplorerSwapAction')])}
</div>
);
}
ViewOnEtherScanLink.propTypes = {
txHash: PropTypes.string,
blockExplorerUrl: PropTypes.string,
isCustomBlockExplorerUrl: PropTypes.bool,
};