-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: edit custom network flow (#25272)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** Edit network flow from the modal added <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/25272?quickstart=1) ## **Related issues** Fixes: ## **Manual testing steps** 1. Run `yarn && ENABLE_NETWORK_UI_REDESIGN=1 yarn start` 2. Go to Settings -> Developer Options 3. Tun on the network new toggle 4. Go to the wallet page 5. Click on the network button ( see the video below ) 6. click on the three points button 7. click on edit 8. you should be able to edit a network ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** https://github.com/MetaMask/metamask-extension/assets/26223211/cc2e7716-cb13-4158-9994-1c7bccf377ad ### **After** https://github.com/MetaMask/metamask-extension/assets/26223211/c6473a45-bdd1-49d7-81bd-cf92f55376f5 ## **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/develop/.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/develop/.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. --------- Co-authored-by: David Walsh <[email protected]>
- Loading branch information
Showing
22 changed files
with
774 additions
and
214 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { NetworkListItemMenu } from './network-list-item-menu'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@use "design-system"; | ||
|
||
.multichain-network-list-item-menu__popover { | ||
z-index: design-system.$popover-in-modal-z-index; | ||
overflow: hidden; | ||
min-width: 225px; | ||
max-width: 225px; | ||
} |
98 changes: 98 additions & 0 deletions
98
ui/components/multichain/network-list-item-menu/network-list-item-menu.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { useI18nContext } from '../../../hooks/useI18nContext'; | ||
import { | ||
IconName, | ||
ModalFocus, | ||
Popover, | ||
PopoverPosition, | ||
PopoverRole, | ||
Text, | ||
} from '../../component-library'; | ||
import { MenuItem } from '../../ui/menu'; | ||
import { IconColor, TextColor } from '../../../helpers/constants/design-system'; | ||
|
||
export const NetworkListItemMenu = ({ | ||
anchorElement, | ||
onClose, | ||
onEditClick, | ||
onDeleteClick, | ||
isOpen, | ||
}) => { | ||
const t = useI18nContext(); | ||
|
||
return ( | ||
<Popover | ||
className="multichain-network-list-item-menu__popover" | ||
onClickOutside={onClose} | ||
referenceElement={anchorElement} | ||
role={PopoverRole.Dialog} | ||
position={PopoverPosition.Bottom} | ||
offset={[0, 0]} | ||
padding={0} | ||
isOpen={isOpen} | ||
isPortal | ||
preventOverflow | ||
flip | ||
> | ||
<ModalFocus restoreFocus initialFocusRef={anchorElement}> | ||
<div> | ||
{onEditClick ? ( | ||
<MenuItem | ||
iconName={IconName.Edit} | ||
onClick={(e) => { | ||
e.stopPropagation(); | ||
|
||
// Pass network info? | ||
onEditClick(); | ||
}} | ||
data-testid="network-list-item-options-edit" | ||
> | ||
{t('edit')} | ||
</MenuItem> | ||
) : null} | ||
{onDeleteClick ? ( | ||
<MenuItem | ||
iconName={IconName.Trash} | ||
iconColor={IconColor.errorDefault} | ||
onClick={(e) => { | ||
e.stopPropagation(); | ||
|
||
// Pass network info? | ||
onDeleteClick(); | ||
}} | ||
data-testid="network-list-item-options-delete" | ||
> | ||
<Text color={TextColor.errorDefault}>{t('delete')}</Text> | ||
</MenuItem> | ||
) : null} | ||
</div> | ||
</ModalFocus> | ||
</Popover> | ||
); | ||
}; | ||
|
||
NetworkListItemMenu.propTypes = { | ||
/** | ||
* Element that the menu should display next to | ||
*/ | ||
anchorElement: PropTypes.instanceOf(window.Element), | ||
/** | ||
* Function that executes when the menu is closed | ||
*/ | ||
onClose: PropTypes.func.isRequired, | ||
/** | ||
* Function that executes when the Edit menu item is clicked | ||
*/ | ||
onEditClick: PropTypes.func, | ||
/** | ||
* Function that executes when the Delete menu item is closed | ||
*/ | ||
onDeleteClick: PropTypes.func, | ||
/** | ||
* Represents if the menu is open or not | ||
* | ||
* @type {boolean} | ||
*/ | ||
isOpen: PropTypes.bool.isRequired, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.