-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open sea security provider warning message #17662
Merged
bschorchit
merged 9 commits into
develop
from
open-sea-security-provider-warning-message
Feb 23, 2023
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ead938d
Warning message for the OpenSea security provider
filipsekulic 507f1ea
Updated snapshots
filipsekulic d83157e
Removed flask usage
filipsekulic 17b766f
Covered more test cases
filipsekulic 7d86790
Code refactor
filipsekulic c7caadc
Fixed errors
filipsekulic c72bed0
Code refactor
filipsekulic 85db441
Fixed few issues
filipsekulic f25e7c0
Covered more code with tests
filipsekulic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 @@ | ||
export { default } from './security-provider-banner-message'; |
5 changes: 5 additions & 0 deletions
5
...onents/app/security-provider-banner-message/security-provider-banner-message.constants.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,5 @@ | ||
export const SECURITY_PROVIDER_MESSAGE_SEVERITIES = { | ||
NOT_MALICIOUS: 0, | ||
MALICIOUS: 1, | ||
NOT_SAFE: 2, | ||
}; |
74 changes: 74 additions & 0 deletions
74
ui/components/app/security-provider-banner-message/security-provider-banner-message.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,74 @@ | ||
import React, { useContext } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { | ||
Color, | ||
SEVERITIES, | ||
Size, | ||
TypographyVariant, | ||
} from '../../../helpers/constants/design-system'; | ||
import { I18nContext } from '../../../../.storybook/i18n'; | ||
import { BannerAlert, ButtonLink } from '../../component-library'; | ||
import Typography from '../../ui/typography/typography'; | ||
import { SECURITY_PROVIDER_MESSAGE_SEVERITIES } from './security-provider-banner-message.constants'; | ||
|
||
export default function SecurityProviderBannerMessage({ | ||
securityProviderResponse, | ||
}) { | ||
const t = useContext(I18nContext); | ||
|
||
let messageTitle; | ||
let messageText; | ||
let severity; | ||
|
||
if ( | ||
securityProviderResponse.flagAsDangerous === | ||
SECURITY_PROVIDER_MESSAGE_SEVERITIES.MALICIOUS | ||
) { | ||
messageTitle = | ||
securityProviderResponse.reason_header === '' | ||
? t('requestFlaggedAsMaliciousFallbackCopyReasonTitle') | ||
: securityProviderResponse.reason_header; | ||
messageText = | ||
securityProviderResponse.reason === '' | ||
? t('requestFlaggedAsMaliciousFallbackCopyReason') | ||
: securityProviderResponse.reason; | ||
severity = SEVERITIES.DANGER; | ||
} else if ( | ||
securityProviderResponse.flagAsDangerous === | ||
SECURITY_PROVIDER_MESSAGE_SEVERITIES.NOT_SAFE | ||
) { | ||
messageTitle = t('requestMayNotBeSafe'); | ||
messageText = t('requestMayNotBeSafeError'); | ||
severity = SEVERITIES.WARNING; | ||
} else { | ||
messageTitle = t('requestNotVerified'); | ||
messageText = t('requestNotVerifiedError'); | ||
severity = SEVERITIES.WARNING; | ||
} | ||
|
||
return ( | ||
<BannerAlert | ||
marginTop={4} | ||
marginRight={4} | ||
marginLeft={4} | ||
title={messageTitle} | ||
severity={severity} | ||
> | ||
<Typography variant={TypographyVariant.H6}>{messageText}</Typography> | ||
<Typography variant={TypographyVariant.H7} color={Color.textAlternative}> | ||
{t('thisIsBasedOn')} | ||
<ButtonLink | ||
size={Size.inherit} | ||
href="https://opensea.io/" | ||
target="_blank" | ||
> | ||
{t('openSeaNew')} | ||
</ButtonLink> | ||
</Typography> | ||
</BannerAlert> | ||
); | ||
} | ||
|
||
SecurityProviderBannerMessage.propTypes = { | ||
securityProviderResponse: PropTypes.object, | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be nice to have test coverage of the code change in this component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed here: 40ce40f