Skip to content

Commit a88251b

Browse files
chore: remove deprecated ErrorMessage component (#36872)
## **Description** This PR removes the deprecated `ErrorMessage` component from the codebase and replaces its usage with the modern `BannerAlert` component from the component-library. This continues the effort to modernize MetaMask's UI components and remove deprecated code. **Key Changes:** - Completely removed the deprecated `ErrorMessage` component and all related files - Replaced `ErrorMessage` usage in `EditGasFeePopover` with `BannerAlert` - Cleaned up SCSS imports and styles - Added comprehensive Storybook stories for `EditGasFeePopover` **Component Migration:** - `ErrorMessage` → `BannerAlert` with `severity={BannerAlertSeverity.Danger}` - Maintains the same visual appearance and functionality - Uses the modern component-library API [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/36872?quickstart=1) ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: #20394 ## **Manual testing steps** 1. Build the application to ensure no broken imports 2. Navigate to any transaction confirmation flow that shows gas editing 3. Verify that insufficient funds errors still display correctly with red styling 4. Check Storybook to ensure EditGasFeePopover stories render correctly: - Run `yarn storybook` - Navigate to Pages/Confirmations/Components/EditGasFeePopover - Test different scenarios including error states 5. Run tests to ensure no regressions: `yarn test` ## **Screenshots/Recordings** N/A - This is a component refactor with no visual changes to end users ### **Before** - Deprecated ErrorMessage component used in edit gas modal <img width="354" height="609" alt="Screenshot 2025-10-14 at 2 46 12 PM" src="https://github.com/user-attachments/assets/70ac19bf-5bbd-43ce-a1b6-725583c27c1c" /> ### **After** - Replaced with BannerAlert component <img width="366" height="600" alt="Screenshot 2025-10-14 at 2 44 59 PM" src="https://github.com/user-attachments/assets/540cb9b1-558d-46c8-ac6a-cb7aa8de729d" /> ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I've included tests if applicable - [x] I've documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Removes `ErrorMessage` and replaces its usage in `EditGasFeePopover` with `BannerAlert`, deletes related files, updates styles, and adds a Storybook story. > > - **UI Migration** > - Replace `ErrorMessage` with `BannerAlert` (`Danger`) in `ui/pages/confirmations/components/edit-gas-fee-popover/edit-gas-fee-popover.js` (uses `t(INSUFFICIENT_FUNDS_ERROR_KEY)` for description). > - Adjust imports to use component-library `BannerAlert` and `Text`. > - **Cleanup/Removals** > - Delete deprecated `ui/components/ui/error-message/*` (component, tests, stories, styles, snapshots). > - Remove `@import 'error-message/index';` from `ui/components/ui/ui-components.scss`. > - Drop `.error-message` margin overrides from `ui/pages/confirmations/components/edit-gas-fee-popover/index.scss`. > - **Storybook** > - Add `EditGasFeePopover` story `edit-gas-fee-popover.stories.tsx` with mocked providers and args. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit c4da056. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 2b08cde commit a88251b

File tree

10 files changed

+104
-156
lines changed

10 files changed

+104
-156
lines changed

ui/components/ui/error-message/__snapshots__/error-message.component.test.js.snap

Lines changed: 0 additions & 37 deletions
This file was deleted.

ui/components/ui/error-message/error-message.component.js

Lines changed: 0 additions & 48 deletions
This file was deleted.

ui/components/ui/error-message/error-message.component.test.js

Lines changed: 0 additions & 23 deletions
This file was deleted.

ui/components/ui/error-message/error-message.stories.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

ui/components/ui/error-message/index.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

ui/components/ui/error-message/index.scss

Lines changed: 0 additions & 19 deletions
This file was deleted.

ui/components/ui/ui-components.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
@import 'confusable/index';
1414
@import 'definition-list/definition-list';
1515
@import 'dropdown/dropdown';
16-
@import 'error-message/index';
1716
@import 'icon-border/icon-border';
1817
@import 'icon-button/icon-button';
1918
@import 'icon-with-fallback/icon-with-fallback';

ui/pages/confirmations/components/edit-gas-fee-popover/edit-gas-fee-popover.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
import { useI18nContext } from '../../../../hooks/useI18nContext';
88
import { useTransactionModalContext } from '../../../../contexts/transaction-modal';
99
import Box from '../../../../components/ui/box';
10-
import ErrorMessage from '../../../../components/ui/error-message';
1110
import Popover from '../../../../components/ui/popover';
1211

1312
import {
@@ -18,7 +17,11 @@ import { INSUFFICIENT_FUNDS_ERROR_KEY } from '../../../../helpers/constants/erro
1817
import { useGasFeeContext } from '../../../../contexts/gasFee';
1918
import AppLoadingSpinner from '../../../../components/app/app-loading-spinner';
2019
import ZENDESK_URLS from '../../../../helpers/constants/zendesk-url';
21-
import { Text } from '../../../../components/component-library';
20+
import {
21+
BannerAlert,
22+
BannerAlertSeverity,
23+
Text,
24+
} from '../../../../components/component-library';
2225
import EditGasItem from './edit-gas-item';
2326
import NetworkStatistics from './network-statistics';
2427

@@ -55,7 +58,11 @@ const EditGasFeePopover = () => {
5558
<div className="edit-gas-fee-popover__content">
5659
<Box>
5760
{balanceError && (
58-
<ErrorMessage errorKey={INSUFFICIENT_FUNDS_ERROR_KEY} />
61+
<BannerAlert
62+
severity={BannerAlertSeverity.Danger}
63+
description={t(INSUFFICIENT_FUNDS_ERROR_KEY)}
64+
marginBottom={1}
65+
/>
5966
)}
6067
<div className="edit-gas-fee-popover__content__header">
6168
<span className="edit-gas-fee-popover__content__header-option">
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
import React from 'react';
2+
import { Provider } from 'react-redux';
3+
import { Meta, StoryObj } from '@storybook/react';
4+
import mockState from '../../../../../test/data/mock-state.json';
5+
import configureStore from '../../../../store/store';
6+
import { GasFeeContextProvider } from '../../../../contexts/gasFee';
7+
import { TransactionModalContext } from '../../../../contexts/transaction-modal';
8+
import {
9+
EditGasModes,
10+
PriorityLevels,
11+
} from '../../../../../shared/constants/gas';
12+
import { decGWEIToHexWEI } from '../../../../../shared/modules/conversion.utils';
13+
import EditGasFeePopover from './edit-gas-fee-popover';
14+
15+
const store = configureStore({
16+
...mockState,
17+
metamask: {
18+
...mockState.metamask,
19+
featureFlags: {
20+
...mockState.metamask.featureFlags,
21+
advancedInlineGas: true,
22+
},
23+
},
24+
});
25+
26+
type MockTransactionModalProviderProps = {
27+
children: React.ReactNode;
28+
};
29+
30+
const MockTransactionModalProvider: React.FC<
31+
MockTransactionModalProviderProps
32+
> = ({ children }) => {
33+
return (
34+
<TransactionModalContext.Provider
35+
value={{
36+
closeModal: () => undefined,
37+
closeAllModals: () => undefined,
38+
currentModal: 'editGasFee',
39+
openModal: () => undefined,
40+
openModalCount: 1,
41+
}}
42+
>
43+
{children}
44+
</TransactionModalContext.Provider>
45+
);
46+
};
47+
48+
const createTransaction = (editGasMode = EditGasModes.modifyInPlace) => ({
49+
userFeeLevel: PriorityLevels.medium,
50+
txParams: {
51+
maxFeePerGas: decGWEIToHexWEI('70'),
52+
maxPriorityFeePerGas: decGWEIToHexWEI('7'),
53+
gas: '0x5208',
54+
gasPrice: decGWEIToHexWEI('50'),
55+
type: '0x2',
56+
from: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
57+
to: '0xc42edfcc21ed14dda456aa0756c153f7985d8813',
58+
},
59+
chainId: '0x5', // Use Goerli from mock state
60+
editGasMode,
61+
});
62+
63+
interface StoryArgs {
64+
editGasMode: EditGasModes;
65+
}
66+
67+
const meta: Meta<StoryArgs> = {
68+
title: 'Pages/Confirmations/Components/EditGasFeePopover',
69+
component: EditGasFeePopover,
70+
decorators: [
71+
(Story, context) => (
72+
<Provider store={store}>
73+
<MockTransactionModalProvider>
74+
<GasFeeContextProvider
75+
transaction={createTransaction(context.args.editGasMode)}
76+
editGasMode={context.args.editGasMode}
77+
>
78+
<Story />
79+
</GasFeeContextProvider>
80+
</MockTransactionModalProvider>
81+
</Provider>
82+
),
83+
],
84+
};
85+
86+
export default meta;
87+
88+
type Story = StoryObj<StoryArgs>;
89+
90+
export const Default: Story = {
91+
args: {
92+
editGasMode: EditGasModes.modifyInPlace,
93+
},
94+
};

ui/pages/confirmations/components/edit-gas-fee-popover/index.scss

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@
1313
justify-content: space-between;
1414
padding: 16px 12px;
1515

16-
& .error-message {
17-
margin-top: 0;
18-
margin-bottom: 12px;
19-
}
20-
2116
&__header {
2217
color: var(--color-text-alternative);
2318
font-size: 10px;

0 commit comments

Comments
 (0)