Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding alerts for transaction inside deprecation #21193

Merged
merged 7 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/_locales/en/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 36 additions & 24 deletions ui/components/app/confirm-data/confirm-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import { getKnownMethodData } from '../../../selectors';
import { useI18nContext } from '../../../hooks/useI18nContext';
import { useTransactionFunctionType } from '../../../hooks/useTransactionFunctionType';

import Box from '../../ui/box/box';
import Disclosure from '../../ui/disclosure';
import TransactionDecoding from '../transaction-decoding';
import { Text } from '../../component-library';
import { Text, Box } from '../../component-library';
import TransactionInsightsDeprecationAlert from './transaction-insights-deprecation-alert';

const ConfirmData = ({ txData, dataComponent }) => {
const t = useI18nContext();
Expand All @@ -25,7 +25,14 @@ const ConfirmData = ({ txData, dataComponent }) => {
const { functionType } = useTransactionFunctionType(txData);

if (dataComponent) {
return dataComponent;
return (
<Box>
<Box marginLeft={4} marginRight={4} marginTop={4}>
<TransactionInsightsDeprecationAlert />
</Box>
{dataComponent}
</Box>
);
}

if (!txParams.data) {
Expand All @@ -38,28 +45,33 @@ const ConfirmData = ({ txData, dataComponent }) => {
: '';

return (
<Box color={Color.textAlternative} className="confirm-data" padding={4}>
<Box paddingBottom={3} paddingTop={2}>
<Text
as="span"
textTransform={TextTransform.Uppercase}
variant={TextVariant.bodySm}
>
{`${t('functionType')}:`}
</Text>
<Text
as="span"
color={Color.textDefault}
paddingLeft={1}
textTransform={TextTransform.Capitalize}
variant={TextVariant.bodySmBold}
>
{`${functionType} ${functionParams}`}
</Text>
<Box>
<Box marginLeft={4} marginRight={4} marginTop={4}>
<TransactionInsightsDeprecationAlert />
</Box>
<Box color={Color.textAlternative} className="confirm-data" padding={4}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] we can move `className="confirm-data" to the parent Box element to follow the pattern we have in our codebase. This would also require us to update one of the styles

& > .disclosure {& .disclosure { (or specifying a new classname)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is existing div only wrapped in a parent element and an alert placed on top of it. I would avoid refactoring it and functionality is being deprecated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I don't think there is much reason to spend time maintaining this if we are gonna remove it in a couple of releases.

<Box paddingBottom={3} paddingTop={2}>
<Text
as="span"
textTransform={TextTransform.Uppercase}
variant={TextVariant.bodySm}
>
{`${t('functionType')}:`}
</Text>
<Text
as="span"
color={Color.textDefault}
paddingLeft={1}
textTransform={TextTransform.Capitalize}
variant={TextVariant.bodySmBold}
>
{`${functionType} ${functionParams}`}
</Text>
</Box>
<Disclosure>
<TransactionDecoding to={txParams?.to} inputData={txParams?.data} />
</Disclosure>
</Box>
<Disclosure>
<TransactionDecoding to={txParams?.to} inputData={txParams?.data} />
</Disclosure>
</Box>
);
};
Expand Down
5 changes: 5 additions & 0 deletions ui/components/app/confirm-data/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@
& > .disclosure {
margin-top: 0;
}

&_alert-snaps {
font-size: var(--typography-l-body-sm-font-size);
vertical-align: baseline;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';

import {
TextVariant,
FontWeight,
} from '../../../helpers/constants/design-system';
import { useI18nContext } from '../../../hooks/useI18nContext';
import { BannerAlert, Text, ButtonLink } from '../../component-library';

const TransactionInsightsDeprecationAlert = () => {
const t = useI18nContext();

return (
<BannerAlert className="confirm-data_alert">
<Text variant={TextVariant.bodyMd} fontWeight={FontWeight.Medium}>
{t('transactionInsightsDeprecationTitle')}
</Text>
<Text variant={TextVariant.bodySm}>
{t('transactionInsightsDeprecationInfo')}{' '}
<ButtonLink
className="confirm-data_alert-snaps"
fontWeight={FontWeight.Normal}
target="_blank"
href=" https://snaps.metamask.io/transaction-insights"
>
{t('snaps')}
</ButtonLink>
.
</Text>
</BannerAlert>
);
};

export default TransactionInsightsDeprecationAlert;
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ import Button from '../../ui/button';
import Tooltip from '../../ui/tooltip';
import CancelButton from '../cancel-button';
import Popover from '../../ui/popover';
import {
Box,
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
Icon,
IconName,
Text,
///: END:ONLY_INCLUDE_IN
} from '../../component-library';
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
import Box from '../../ui/box/box';
import { Icon, IconName, Text } from '../../component-library';
import { IconColor } from '../../../helpers/constants/design-system';
///: END:ONLY_INCLUDE_IN
import { SECOND } from '../../../../shared/constants/time';
Expand All @@ -22,6 +28,7 @@ import { TransactionType } from '../../../../shared/constants/transaction';
import { getURLHostName } from '../../../helpers/utils/util';
import TransactionDecoding from '../transaction-decoding';
import { NETWORKS_ROUTE } from '../../../helpers/constants/routes';
import TransactionInsightsDeprecationAlert from '../confirm-data/transaction-insights-deprecation-alert';

export default class TransactionListItemDetails extends PureComponent {
static contextTypes = {
Expand Down Expand Up @@ -393,6 +400,9 @@ export default class TransactionListItemDetails extends PureComponent {
)}
{transactionGroup.initialTransaction?.txParams?.data ? (
<Disclosure title="Transaction data" size="small">
<Box marginBottom={2}>
<TransactionInsightsDeprecationAlert />
</Box>
<TransactionDecoding
title={t('transactionData')}
to={transactionGroup.initialTransaction.txParams?.to}
Expand Down
Loading