Skip to content

Commit

Permalink
Merge branch 'develop' into phishing-warning-metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksandar-mihajlovic authored Feb 6, 2023
2 parents 7197799 + 68ea3a7 commit 72dad73
Show file tree
Hide file tree
Showing 48 changed files with 2,036 additions and 1,207 deletions.
1 change: 0 additions & 1 deletion development/states/navigate-txs.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"appState": {
"shouldClose": false,
"menuOpen": false,
"modal": {
"open": false,
Expand Down
1 change: 0 additions & 1 deletion development/ts-migration-dashboard/files-to-convert.json
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,6 @@
"ui/components/ui/icon/icon-eye.js",
"ui/components/ui/icon/icon-import.js",
"ui/components/ui/icon/icon-plus.js",
"ui/components/ui/icon/icon-speech-bubbles.js",
"ui/components/ui/icon/icon-token-search.js",
"ui/components/ui/icon/icon.stories.js",
"ui/components/ui/icon/info-icon-inverted.component.js",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@
"@types/react": "^16.9.53",
"@types/react-dom": "^17.0.11",
"@types/remote-redux-devtools": "^0.5.5",
"@types/w3c-web-hid": "^1.0.3",
"@types/watchify": "^3.11.1",
"@types/yargs": "^17.0.8",
"@typescript-eslint/eslint-plugin": "^5.30.7",
Expand Down
12 changes: 12 additions & 0 deletions types/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// In order for variables to be considered on the global scope they must be
// declared using var and not const or let, which is why this rule is disabled
/* eslint-disable no-var */

declare class Platform {
openTab: (opts: { url: string }) => void;

closeCurrentWindow: () => void;
}
export declare global {
var platform: Platform;
}
8 changes: 3 additions & 5 deletions ui/components/app/account-menu/account-menu.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {
} from '../../../helpers/constants/routes';
import TextField from '../../ui/text-field';
import IconCheck from '../../ui/icon/icon-check';
import IconSpeechBubbles from '../../ui/icon/icon-speech-bubbles';
import IconConnect from '../../ui/icon/icon-connect';
import IconCog from '../../ui/icon/icon-cog';
import IconPlus from '../../ui/icon/icon-plus';
Expand All @@ -41,6 +40,8 @@ import IconImport from '../../ui/icon/icon-import';
import Button from '../../ui/button';
import SearchIcon from '../../ui/icon/search-icon';
import { SUPPORT_LINK } from '../../../../shared/lib/ui-utils';
import { Icon, ICON_NAMES } from '../../component-library';
import { Color } from '../../../helpers/constants/design-system';
import KeyRingLabel from './keyring-label';

export function AccountMenuItem(props) {
Expand Down Expand Up @@ -460,10 +461,7 @@ export default class AccountMenu extends Component {
global.platform.openTab({ url: supportLink });
}}
icon={
<IconSpeechBubbles
color="var(--color-icon-alternative)"
ariaLabel={supportText}
/>
<Icon name={ICON_NAMES.MESSAGES} color={Color.iconAlternative} />
}
text={supportText}
/>
Expand Down
28 changes: 19 additions & 9 deletions ui/components/app/approve-content-card/approve-content-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default function ApproveContentCard({
data,
userAcknowledgedGasMissing,
renderSimulationFailureWarning,
useCurrencyRateCheck,
}) {
const t = useContext(I18nContext);

Expand Down Expand Up @@ -163,15 +164,20 @@ export default function ApproveContentCard({
alignItems={AlignItems.flexEnd}
textAlign={TEXT_ALIGN.RIGHT}
>
<Box>
<Typography
variant={TypographyVariant.H4}
fontWeight={FONT_WEIGHT.BOLD}
color={TextColor.textDefault}
>
{formatCurrency(fiatTransactionTotal, currentCurrency)}
</Typography>
</Box>
{useCurrencyRateCheck && (
<Box>
<Typography
variant={TypographyVariant.H4}
fontWeight={FONT_WEIGHT.BOLD}
color={TextColor.TEXT_DEFAULT}
>
{formatCurrency(
fiatTransactionTotal,
currentCurrency,
)}
</Typography>
</Box>
)}
<Box>
<Typography
variant={TypographyVariant.H6}
Expand Down Expand Up @@ -320,4 +326,8 @@ ApproveContentCard.propTypes = {
* Render simulation failure warning
*/
renderSimulationFailureWarning: PropTypes.bool,
/**
* Fiat conversion control
*/
useCurrencyRateCheck: PropTypes.bool,
};
20 changes: 10 additions & 10 deletions ui/components/app/flask/copyable/copyable.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import Box from '../../../ui/box';
import IconCopied from '../../../ui/icon/icon-copied';
import IconCopy from '../../../ui/icon/icon-copy';
import Typography from '../../../ui/typography';
import {
AlignItems,
Expand All @@ -13,8 +11,10 @@ import {
TypographyVariant,
BackgroundColor,
TextColor,
Color,
} from '../../../../helpers/constants/design-system';
import { useCopyToClipboard } from '../../../../hooks/useCopyToClipboard';
import { Icon, ICON_NAMES, ICON_SIZES } from '../../../component-library';

export const Copyable = ({ text }) => {
const [copied, handleCopy] = useCopyToClipboard();
Expand Down Expand Up @@ -46,17 +46,17 @@ export const Copyable = ({ text }) => {
marginBottom={1}
>
{copied ? (
<IconCopied
color="var(--color-icon-alternative)"
className="copyable__icon"
size={18}
<Icon
name={ICON_NAMES.COPY_SUCCESS}
size={ICON_SIZES.LG}
color={Color.iconAlternative}
/>
) : (
<IconCopy
className="copyable__icon"
color="var(--color-icon-alternative)"
<Icon
name={ICON_NAMES.COPY}
size={ICON_SIZES.LG}
color={Color.iconAlternative}
onClick={() => handleCopy(text)}
size={18}
/>
)}
</Box>
Expand Down
2 changes: 1 addition & 1 deletion ui/components/app/gas-timing/gas-timing.component.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import mockState from '../../../../test/data/mock-state.json';

import GasTiming from '.';

jest.mock('../../../store/actions.js', () => ({
jest.mock('../../../store/actions.ts', () => ({
getGasFeeTimeEstimate: jest.fn().mockImplementation(() => Promise.resolve()),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jest.mock('react-router-dom', () => {
};
});

jest.mock('../../../store/actions.js', () => ({
jest.mock('../../../store/actions.ts', () => ({
detectNewTokens: jest.fn(),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import AccountDetailsModal from '.';

const mockShowModal = jest.fn();

jest.mock('../../../../store/actions.js', () => {
jest.mock('../../../../store/actions.ts', () => {
return {
showModal: () => mockShowModal,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const mockCreateCancelTransaction = jest.fn();
const mockShowModal = jest.fn();
const mockHideModal = jest.fn();

jest.mock('../../../../store/actions.js', () => {
jest.mock('../../../../store/actions.ts', () => {
return {
createCancelTransaction: () => mockCreateCancelTransaction,
showModal: () => mockShowModal,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { getAccountLink } from '@metamask/etherscan-link';
import { useSelector } from 'react-redux';
import classnames from 'classnames';
import Box from '../../../ui/box';
import IconCopy from '../../../ui/icon/icon-copy';
import IconBlockExplorer from '../../../ui/icon/icon-block-explorer';
import Button from '../../../ui/button/button.component';
import Tooltip from '../../../ui/tooltip/tooltip';
Expand All @@ -22,12 +21,14 @@ import {
BorderStyle,
BorderColor,
TextColor,
Color,
} from '../../../../helpers/constants/design-system';
import { useCopyToClipboard } from '../../../../hooks/useCopyToClipboard';
import UrlIcon from '../../../ui/url-icon/url-icon';
import { getAddressBookEntry } from '../../../../selectors';
import { TokenStandard } from '../../../../../shared/constants/transaction';
import NftCollectionImage from '../../../ui/nft-collection-image/nft-collection-image';
import { ButtonIcon, ICON_NAMES } from '../../../component-library';

export default function ContractDetailsModal({
onClose,
Expand Down Expand Up @@ -146,15 +147,15 @@ export default function ContractDetailsModal({
: t('copyToClipboard')
}
>
<Button
className="contract-details-modal__content__contract__buttons__copy"
type="link"
onClick={() => {
handleCopyTokenAddress(tokenAddress);
}}
>
<IconCopy color="var(--color-icon-muted)" />
</Button>
<ButtonIcon
iconName={
copiedTokenAddress
? ICON_NAMES.COPY_SUCCESS
: ICON_NAMES.COPY
}
onClick={() => handleCopyTokenAddress(tokenAddress)}
color={Color.iconMuted}
/>
</Tooltip>
</Box>
<Box marginTop={5} marginRight={5}>
Expand Down Expand Up @@ -264,15 +265,13 @@ export default function ContractDetailsModal({
: t('copyToClipboard')
}
>
<Button
className="contract-details-modal__content__contract__buttons__copy"
type="link"
onClick={() => {
handleCopyToAddress(toAddress);
}}
>
<IconCopy color="var(--color-icon-muted)" />
</Button>
<ButtonIcon
iconName={
copiedToAddress ? ICON_NAMES.COPY_SUCCESS : ICON_NAMES.COPY
}
onClick={() => handleCopyToAddress(toAddress)}
color={Color.iconMuted}
/>
</Tooltip>
</Box>
<Box marginTop={5} marginRight={5}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { renderWithProvider } from '../../../../test/lib/render-helpers';
import mockState from '../../../../test/data/mock-state.json';
import TransactionListItemDetails from '.';

jest.mock('../../../store/actions.js', () => ({
jest.mock('../../../store/actions.ts', () => ({
tryReverseResolveAddress: () => jest.fn(),
getGasFeeEstimatesAndStartPolling: jest.fn().mockResolvedValue(),
addPollingTokenToAppState: jest.fn(),
Expand Down
14 changes: 5 additions & 9 deletions ui/components/ui/contract-token-values/contract-token-values.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { getAccountLink } from '@metamask/etherscan-link';
import IconCopy from '../icon/icon-copy';
import IconBlockExplorer from '../icon/icon-block-explorer';
import Box from '../box/box';
import Tooltip from '../tooltip/tooltip';
Expand All @@ -18,6 +17,7 @@ import {
} from '../../../helpers/constants/design-system';
import Button from '../button';
import { useCopyToClipboard } from '../../../hooks/useCopyToClipboard';
import { ButtonIcon, ICON_NAMES } from '../../component-library';

export default function ContractTokenValues({
address,
Expand Down Expand Up @@ -52,15 +52,11 @@ export default function ContractTokenValues({
position="top"
title={copied ? t('copiedExclamation') : t('copyToClipboard')}
>
<Button
type="link"
<ButtonIcon
iconName={copied ? ICON_NAMES.COPY_SUCCESS : ICON_NAMES.COPY}
className="contract-token-values__copy-address__button"
onClick={() => {
handleCopy(address);
}}
>
<IconCopy size={24} color="var(--color-icon-muted)" />
</Button>
onClick={() => handleCopy(address)}
/>
</Tooltip>
</Box>
<Box className="contract-token-values__block-explorer">
Expand Down
9 changes: 0 additions & 9 deletions ui/components/ui/icon/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import SendIcon from './send-icon.component';
import Sign from './sign-icon.component';
import SunCheck from './sun-check-icon.component';
import Swap from './swap-icon-for-list.component';
import IconCopy from './icon-copy'
import IconBlockExplorer from './icon-block-explorer';


Expand Down Expand Up @@ -182,14 +181,6 @@ Use the `className` prop to add an additional class to the icon. This additional

<ArgsTable of={Preloader} />

## IconCopy

<Canvas>
<Story id="components-ui-icon--icon-copy-story" />
</Canvas>

<ArgsTable of={IconCopy} />

## IconBlockExplorer

<Canvas>
Expand Down
49 changes: 0 additions & 49 deletions ui/components/ui/icon/icon-copied.js

This file was deleted.

Loading

0 comments on commit 72dad73

Please sign in to comment.