Skip to content

Commit

Permalink
fix (cherry-pick): Fix #24322 - Disable edits for all dapp initiated …
Browse files Browse the repository at this point in the history
…transactions (#24334) (#24354)

Cherry picks 4a1853c (#24322) to v11.14.5

Co-authored-by: David Walsh <[email protected]>
  • Loading branch information
danjm and darkwing authored May 2, 2024
1 parent 2d9f5f7 commit 949e733
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 34 deletions.
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

0 comments on commit 949e733

Please sign in to comment.