-
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.
Confirmation redesign: add message section to personal sign page (#22766
- Loading branch information
Showing
27 changed files
with
378 additions
and
127 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.
File renamed without changes.
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
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export * from './address'; | ||
export * from './divider'; | ||
export * from './row'; | ||
export * from './text'; | ||
export * from './url'; | ||
export * from './value-double'; |
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,25 @@ | ||
import React from 'react'; | ||
import { ConfirmInfoRow } from './row'; | ||
import { ConfirmInfoRowText } from './text'; | ||
|
||
const ConfirmInfoRowTextStory = { | ||
title: 'Components/App/Confirm/InfoRowText', | ||
component: ConfirmInfoRowText, | ||
|
||
decorators: [ | ||
(story) => <ConfirmInfoRow label="Message">{story()}</ConfirmInfoRow>, | ||
], | ||
|
||
argTypes: { | ||
url: { | ||
control: 'text', | ||
}, | ||
}, | ||
}; | ||
|
||
export const DefaultStory = ({ text }) => <ConfirmInfoRowText text={text} />; | ||
DefaultStory.args = { | ||
text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', | ||
}; | ||
|
||
export default ConfirmInfoRowTextStory; |
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,25 @@ | ||
import React from 'react'; | ||
import { Box, Text } from '../../../../component-library'; | ||
import { | ||
AlignItems, | ||
Display, | ||
FlexWrap, | ||
TextColor, | ||
} from '../../../../../helpers/constants/design-system'; | ||
|
||
export type ConfirmInfoRowTextProps = { | ||
text: string; | ||
}; | ||
|
||
export const ConfirmInfoRowText = ({ text }: ConfirmInfoRowTextProps) => { | ||
return ( | ||
<Box | ||
display={Display.Flex} | ||
alignItems={AlignItems.center} | ||
flexWrap={FlexWrap.Wrap} | ||
gap={2} | ||
> | ||
<Text color={TextColor.inherit}>{text}</Text> | ||
</Box> | ||
); | ||
}; |
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
38 changes: 4 additions & 34 deletions
38
ui/pages/confirmations/components/confirm/info/info.test.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 |
---|---|---|
@@ -1,51 +1,21 @@ | ||
import React from 'react'; | ||
import configureMockStore from 'redux-mock-store'; | ||
|
||
import { unapprovedPersonalMsg } from '../../../../../../test/data/confirmations/personal_sign'; | ||
import { renderWithProvider } from '../../../../../../test/lib/render-helpers'; | ||
import ConfirmTitle from './info'; | ||
|
||
const mockPersonalSign = { | ||
id: '0050d5b0-c023-11ee-a0cb-3390a510a0ab', | ||
status: 'unapproved', | ||
time: new Date().getTime(), | ||
type: 'personal_sign', | ||
securityProviderResponse: null, | ||
msgParams: { | ||
from: '0x8eeee1781fd885ff5ddef7789486676961873d12', | ||
data: '0x4578616d706c652060706572736f6e616c5f7369676e60206d657373616765', | ||
origin: 'https://metamask.github.io', | ||
siwe: { isSIWEMessage: false, parsedMessage: null }, | ||
}, | ||
}; | ||
|
||
describe('Info', () => { | ||
it('renders origin for personal sign request', () => { | ||
it('renders info section for personal sign request', () => { | ||
const mockState = { | ||
confirm: { | ||
currentConfirmation: mockPersonalSign, | ||
currentConfirmation: unapprovedPersonalMsg, | ||
}, | ||
}; | ||
const mockStore = configureMockStore([])(mockState); | ||
const { getByText } = renderWithProvider(<ConfirmTitle />, mockStore); | ||
|
||
expect(getByText('Origin')).toBeInTheDocument(); | ||
expect(getByText('Request from')).toBeInTheDocument(); | ||
expect(getByText('https://metamask.github.io')).toBeInTheDocument(); | ||
}); | ||
|
||
it('does not render if required data is not present in the transaction', () => { | ||
const mockState = { | ||
confirm: { | ||
currentConfirmation: { | ||
id: '0050d5b0-c023-11ee-a0cb-3390a510a0ab', | ||
status: 'unapproved', | ||
time: new Date().getTime(), | ||
type: 'json_request', | ||
}, | ||
}, | ||
}; | ||
const mockStore = configureMockStore([])(mockState); | ||
const { queryByText } = renderWithProvider(<ConfirmTitle />, mockStore); | ||
|
||
expect(queryByText('Origin')).not.toBeInTheDocument(); | ||
}); | ||
}); |
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
38 changes: 38 additions & 0 deletions
38
ui/pages/confirmations/components/confirm/info/personal-sign/personalSign.test.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,38 @@ | ||
import React from 'react'; | ||
import configureMockStore from 'redux-mock-store'; | ||
|
||
import { renderWithProvider } from '../../../../../../../test/lib/render-helpers'; | ||
import { unapprovedPersonalMsg } from '../../../../../../../test/data/confirmations/personal_sign'; | ||
import PersonalSign from './personalSign'; | ||
|
||
describe('personalSign', () => { | ||
it('renders origin for personal sign request', () => { | ||
const mockState = { | ||
confirm: { | ||
currentConfirmation: unapprovedPersonalMsg, | ||
}, | ||
}; | ||
const mockStore = configureMockStore([])(mockState); | ||
const { getByText } = renderWithProvider(<PersonalSign />, mockStore); | ||
|
||
expect(getByText('Request from')).toBeInTheDocument(); | ||
expect(getByText('https://metamask.github.io')).toBeInTheDocument(); | ||
}); | ||
|
||
it('does not render if required data is not present in the transaction', () => { | ||
const mockState = { | ||
confirm: { | ||
currentConfirmation: { | ||
id: '0050d5b0-c023-11ee-a0cb-3390a510a0ab', | ||
status: 'unapproved', | ||
time: new Date().getTime(), | ||
type: 'json_request', | ||
}, | ||
}, | ||
}; | ||
const mockStore = configureMockStore([])(mockState); | ||
const { queryByText } = renderWithProvider(<PersonalSign />, mockStore); | ||
|
||
expect(queryByText('Request from')).not.toBeInTheDocument(); | ||
}); | ||
}); |
Oops, something went wrong.