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

fix (cherry-pick): Fix #24322 - Disable edits for all dapp initiated transactions (#24334) #24354

Merged
merged 1 commit into from
May 2, 2024
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: 3 additions & 3 deletions test/e2e/tests/dapp-interactions/dapp-tx-edit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('Editing confirmations of dapp initiated contract interactions', functi
);
});

it('should show an edit button on a simple ETH send initiated by a dapp', async function () {
it('should NOT show an edit button on a simple ETH send initiated by a dapp', async function () {
await withFixtures(
{
dapp: true,
Expand Down Expand Up @@ -88,8 +88,8 @@ describe('Editing confirmations of dapp initiated contract interactions', functi
);
assert.equal(
editTransactionButton,
true,
`Edit transaction button should be visible on a contract interaction created by a dapp`,
false,
`Edit transaction button should not be visible on a simple send transaction created by a dapp`,
);
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
import {
ENVIRONMENT_TYPE_POPUP,
ENVIRONMENT_TYPE_NOTIFICATION,
ORIGIN_METAMASK,
} from '../../../../../../shared/constants/app';
import { getEnvironmentType } from '../../../../../../app/scripts/lib/util';
import NetworkDisplay from '../../../../../components/app/network-display';
Expand All @@ -18,6 +19,7 @@ export default function ConfirmPageContainerHeader({
accountAddress,
showAccountInHeader,
children,
origin,
}) {
const t = useI18nContext();
const windowType = getEnvironmentType();
Expand Down Expand Up @@ -48,21 +50,23 @@ export default function ConfirmPageContainerHeader({
<AccountMismatchWarning address={accountAddress} />
</div>
) : (
<div
className="confirm-page-container-header__back-button-container"
style={{
visibility: showEdit ? 'initial' : 'hidden',
}}
>
<Icon name={IconName.ArrowLeft} />
<span
data-testid="confirm-page-back-edit-button"
className="confirm-page-container-header__back-button"
onClick={() => onEdit()}
origin === ORIGIN_METAMASK && (
<div
className="confirm-page-container-header__back-button-container"
style={{
visibility: showEdit ? 'initial' : 'hidden',
}}
>
{t('edit')}
</span>
</div>
<Icon name={IconName.ArrowLeft} />
<span
data-testid="confirm-page-back-edit-button"
className="confirm-page-container-header__back-button"
onClick={() => onEdit()}
>
{t('edit')}
</span>
</div>
)
)}
{isFullScreen ? null : <NetworkDisplay />}
</div>
Expand All @@ -77,4 +81,5 @@ ConfirmPageContainerHeader.propTypes = {
showEdit: PropTypes.bool,
onEdit: PropTypes.func,
children: PropTypes.node,
origin: PropTypes.string,
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import configureStore from 'redux-mock-store';
import { NetworkStatus } from '@metamask/network-controller';
import { NetworkType } from '@metamask/controller-utils';
import { ORIGIN_METAMASK } from '../../../../../../shared/constants/app';
import { renderWithProvider } from '../../../../../../test/lib/render-helpers';
import { getEnvironmentType } from '../../../../../../app/scripts/lib/util';
import ConfirmPageContainerHeader from '.';
Expand Down Expand Up @@ -38,6 +39,7 @@ describe('Confirm Detail Row Component', () => {
onEdit: jest.fn(),
showAccountInHeader: false,
accountAddress: '0xmockAccountAddress',
origin: ORIGIN_METAMASK,
};

const { container } = renderWithProvider(
Expand All @@ -56,6 +58,7 @@ describe('Confirm Detail Row Component', () => {
onEdit: jest.fn(),
showAccountInHeader: false,
accountAddress: '0xmockAccountAddress',
origin: ORIGIN_METAMASK,
};

const { container } = renderWithProvider(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ const ConfirmPageContainer = (props) => {
onEdit={() => onEdit()}
showAccountInHeader={showAccountInHeader}
accountAddress={fromAddress}
origin={origin}
>
{hideSenderToRecipient ? null : (
<SenderToRecipient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,7 @@ exports[`ConfirmSendEther should render correct information for for confirm send
>
<div
class="confirm-page-container-header__row"
>
<div
class="confirm-page-container-header__back-button-container"
style="visibility: initial;"
>
<span
class="mm-box mm-icon mm-icon--size-md mm-box--display-inline-block mm-box--color-inherit"
style="mask-image: url('./images/icons/arrow-left.svg');"
/>
<span
class="confirm-page-container-header__back-button"
data-testid="confirm-page-back-edit-button"
>
Edit
</span>
</div>
</div>
/>
<div
class="sender-to-recipient sender-to-recipient--default"
data-testid="sender-to-recipient"
Expand Down
Loading