-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use new
SnapAuthorshipPill
component to show snap origin in c…
…onfirmation flow (#26881) ## **Description** 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? Previously, the confirmation page would just show the snap id for "request from" as part of the confirmation screen. 2. What is the improvement/solution? A pill is now used to show the snap icon and name, the pill opens up to a metadata modal. Fixes: MetaMask/MetaMask-planning#3085 ## **Manual testing steps** 1. Build the extension 2. Install a snap that uses `personal_sign` 3. Call `personal_sign` from the snap ## **Screenshots/Recordings** https://github.com/user-attachments/assets/894ebaf8-9b58-4073-913e-bce64db2ad2a ## **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/develop/.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/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [x] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [x] 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.
- Loading branch information
Showing
7 changed files
with
111 additions
and
2 deletions.
There are no files selected for viewing
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
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,7 @@ | ||
.snap-authorship-pill { | ||
cursor: pointer; | ||
|
||
&:hover { | ||
background-color: var(--color-background-alternative); | ||
} | ||
} |
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 { default } from './snap-authorship-pill'; |
20 changes: 20 additions & 0 deletions
20
ui/components/app/snaps/snap-authorship-pill/snap-authorship-pill.stories.tsx
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,20 @@ | ||
import React from 'react'; | ||
import SnapAuthorshipPill from './snap-authorship-pill' | ||
|
||
export default { | ||
title: 'Components/App/Snaps/SnapAuthorshipPill', | ||
component: SnapAuthorshipPill, | ||
argTypes: { | ||
snapId: { | ||
control: 'text', | ||
}, | ||
}, | ||
}; | ||
|
||
export const DefaultStory = (args) => <SnapAuthorshipPill {...args} />; | ||
|
||
DefaultStory.storyName = 'Default'; | ||
|
||
DefaultStory.args = { | ||
snapId: 'npm:@metamask/test-snap-bip44', | ||
}; |
55 changes: 55 additions & 0 deletions
55
ui/components/app/snaps/snap-authorship-pill/snap-authorship-pill.tsx
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,55 @@ | ||
import React from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
import { Box, IconSize, Text } from '../../../component-library'; | ||
import { SnapIcon } from '../snap-icon'; | ||
import { getSnapMetadata } from '../../../../selectors'; | ||
import { | ||
AlignItems, | ||
BorderRadius, | ||
Display, | ||
FlexDirection, | ||
TextColor, | ||
TextVariant, | ||
} from '../../../../helpers/constants/design-system'; | ||
|
||
type SnapAuthorshipPillProps = { | ||
snapId: string; | ||
onClick: () => void; | ||
}; | ||
|
||
const SnapAuthorshipPill: React.FC<SnapAuthorshipPillProps> = ({ | ||
snapId, | ||
onClick, | ||
}) => { | ||
const { name: snapName } = useSelector((state) => | ||
// @ts-expect-error ts is picking up the wrong type for the selector | ||
getSnapMetadata(state, snapId), | ||
); | ||
|
||
return ( | ||
<Box | ||
className="snap-authorship-pill" | ||
display={Display.Flex} | ||
flexDirection={FlexDirection.Row} | ||
alignItems={AlignItems.center} | ||
borderRadius={BorderRadius.pill} | ||
paddingTop={1} | ||
paddingBottom={1} | ||
paddingLeft={1} | ||
paddingRight={2} | ||
onClick={onClick} | ||
> | ||
<SnapIcon avatarSize={IconSize.Sm} snapId={snapId} /> | ||
<Text | ||
color={TextColor.primaryDefault} | ||
variant={TextVariant.bodyMdMedium} | ||
ellipsis | ||
paddingLeft={1} | ||
> | ||
{snapName} | ||
</Text> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default SnapAuthorshipPill; |