Commit f1a2b6c
authored
chore: refactor Assets on settings V2 to use createToggleItem (#40750)
## **Description**
Refactors Assets tab toggle items to use the `createToggleItem` factory,
reducing boilerplate and improving consistency.
**Changes:**
- Extended `createToggleItem` factory to support optional
`descriptionKey`
- Converted 3 toggle items to use the factory inline in
`assets-tab.tsx`:
- `AutodetectTokensToggleItem`
- `HideZeroBalanceTokensToggleItem`
- `ShowNetworkTokenToggleItem` (with MetaMetrics tracking)
- Removed standalone component files and their tests
## **Changelog**
CHANGELOG entry: null
## **Related issues**
Fixes:
## **Manual testing steps**
1. Uncomment object beneath `Uncomment to view Settings V2 in Hamburger
Menu`
2. Navigate to Settings V2 > Assets
3. Verify all toggle items render correctly
4. Toggle each setting and verify state persists
5. Verify MetaMetrics events fire for "Show native token as main
balance"
6.
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
### **After**
## **Pre-merge author checklist**
- [ ] 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).
- [ ] I've completed the PR template to the best of my ability
- [ ] I've included tests if applicable
- [ ] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] 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)).
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> Primarily a UI refactor that reuses existing selectors/actions; main
risk is subtle behavior/test-id changes affecting settings toggles and
metrics firing.
>
> **Overview**
> Refactors the Settings V2 *Assets* tab toggles to use the shared
`createToggleItem` factory, inlining the configs in `assets-tab.tsx` and
removing the standalone toggle components/tests for *Autodetect tokens*,
*Hide zero balance tokens*, and *Show native token as main balance*
(including its MetaMetrics tracking).
>
> Extends `createToggleItem` to make `descriptionKey` optional (and adds
coverage for the no-description case), and updates the Assets tab
snapshot/console baseline to reflect the refactor (including removal of
a wrapper `data-testid` around the hide-zero-balance toggle).
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
49dd8e6. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent cfb5fce commit f1a2b6c
File tree
11 files changed
+73
-436
lines changed- test/jest
- ui/pages/settings-v2
- assets-tab
- __snapshots__
11 files changed
+73
-436
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2802 | 2802 | | |
2803 | 2803 | | |
2804 | 2804 | | |
2805 | | - | |
2806 | | - | |
2807 | | - | |
2808 | | - | |
2809 | 2805 | | |
2810 | 2806 | | |
2811 | 2807 | | |
2812 | 2808 | | |
2813 | 2809 | | |
2814 | 2810 | | |
2815 | 2811 | | |
2816 | | - | |
2817 | | - | |
2818 | | - | |
2819 | | - | |
2820 | 2812 | | |
2821 | 2813 | | |
2822 | 2814 | | |
2823 | | - | |
2824 | | - | |
2825 | | - | |
2826 | | - | |
2827 | 2815 | | |
2828 | 2816 | | |
2829 | 2817 | | |
| |||
Lines changed: 1 addition & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
103 | | - | |
104 | | - | |
| 102 | + | |
105 | 103 | | |
106 | 104 | | |
107 | 105 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
4 | 15 | | |
5 | | - | |
6 | | - | |
7 | 16 | | |
8 | 17 | | |
9 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
10 | 50 | | |
11 | 51 | | |
12 | 52 | | |
| |||
Lines changed: 0 additions & 99 deletions
This file was deleted.
Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 0 additions & 115 deletions
This file was deleted.
Lines changed: 0 additions & 22 deletions
This file was deleted.
0 commit comments