-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(3765): Add modal to include metric id before redirecting to supp…
…ort page
- Loading branch information
1 parent
2b39e3b
commit 77c1d55
Showing
15 changed files
with
482 additions
and
45 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
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
83 changes: 83 additions & 0 deletions
83
...pp/modals/visit-support-data-consent-modal/__snapshots__/visit-support-data.test.tsx.snap
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,83 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`VisitSupportDataConsentModal renders the modal correctly when open 1`] = ` | ||
<div | ||
class="mm-modal visit-support-data-consent-modal" | ||
data-testid="visit-support-data-consent-modal" | ||
> | ||
<div | ||
aria-hidden="true" | ||
class="mm-box mm-modal-overlay mm-box--width-full mm-box--height-full mm-box--background-color-overlay-default" | ||
/> | ||
<div | ||
data-focus-guard="true" | ||
style="width: 1px; height: 0px; padding: 0px; overflow: hidden; position: fixed; top: 1px; left: 1px;" | ||
tabindex="0" | ||
/> | ||
<div | ||
data-focus-lock-disabled="false" | ||
> | ||
<div | ||
class="mm-box mm-modal-content mm-box--padding-top-4 mm-box--sm:padding-top-8 mm-box--md:padding-top-12 mm-box--padding-right-4 mm-box--padding-bottom-4 mm-box--sm:padding-bottom-8 mm-box--md:padding-bottom-12 mm-box--padding-left-4 mm-box--display-flex mm-box--justify-content-center mm-box--align-items-flex-start mm-box--width-screen mm-box--height-screen" | ||
> | ||
<section | ||
aria-modal="true" | ||
class="mm-box mm-modal-content__dialog mm-modal-content__dialog--size-sm mm-box--padding-top-4 mm-box--padding-bottom-4 mm-box--display-flex mm-box--flex-direction-column mm-box--width-full mm-box--background-color-background-default mm-box--rounded-lg" | ||
role="dialog" | ||
> | ||
<header | ||
class="mm-box mm-header-base mm-modal-header mm-box--padding-right-4 mm-box--padding-bottom-4 mm-box--padding-left-4 mm-box--display-flex mm-box--justify-content-space-between" | ||
> | ||
<div | ||
class="mm-box mm-box--width-full" | ||
> | ||
<h4 | ||
class="mm-box mm-text mm-text--heading-sm mm-text--text-align-center mm-box--color-text-default" | ||
> | ||
Share device details with support | ||
</h4> | ||
</div> | ||
</header> | ||
<div | ||
class="mm-box mm-modal-body visit-support-data-consent-modal__body mm-box--padding-right-4 mm-box--padding-left-4" | ||
> | ||
<p | ||
class="mm-box mm-text mm-text--body-md mm-box--color-text-default" | ||
> | ||
Do you want to share your MetaMask Identifier and app version with our Support Center? This can help us better solve your problem, but is optional. | ||
</p> | ||
</div> | ||
<div | ||
class="mm-box mm-modal-footer mm-box--padding-top-4 mm-box--padding-right-4 mm-box--padding-left-4" | ||
> | ||
<div | ||
class="mm-box mm-box--display-flex mm-box--gap-4" | ||
> | ||
<button | ||
class="mm-box mm-text mm-button-base mm-button-base--size-lg mm-button-secondary mm-text--body-md-medium mm-box--padding-0 mm-box--padding-right-4 mm-box--padding-left-4 mm-box--display-inline-flex mm-box--justify-content-center mm-box--align-items-center mm-box--width-1/2 mm-box--color-primary-default mm-box--background-color-transparent mm-box--rounded-pill mm-box--border-color-primary-default box--border-style-solid box--border-width-1" | ||
data-testid="visit-support-data-consent-modal-reject-button" | ||
> | ||
Don’t share | ||
</button> | ||
<button | ||
class="mm-box mm-text mm-button-base mm-button-base--size-lg mm-button-primary mm-text--body-md-medium mm-box--padding-0 mm-box--padding-right-4 mm-box--padding-left-4 mm-box--display-inline-flex mm-box--justify-content-center mm-box--align-items-center mm-box--width-1/2 mm-box--color-primary-inverse mm-box--background-color-primary-default mm-box--rounded-pill" | ||
data-testid="visit-support-data-consent-modal-accept-button" | ||
data-theme="light" | ||
> | ||
Confirm | ||
</button> | ||
</div> | ||
<div | ||
class="mm-box mm-container mm-container--max-width-sm mm-box--margin-right-auto mm-box--margin-left-auto mm-box--display-flex mm-box--gap-4 mm-box--flex-wrap-wrap mm-box--align-items-center" | ||
/> | ||
</div> | ||
</section> | ||
</div> | ||
</div> | ||
<div | ||
data-focus-guard="true" | ||
style="width: 1px; height: 0px; padding: 0px; overflow: hidden; position: fixed; top: 1px; left: 1px;" | ||
tabindex="0" | ||
/> | ||
</div> | ||
`; |
10 changes: 10 additions & 0 deletions
10
ui/components/app/modals/visit-support-data-consent-modal/index.scss
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,10 @@ | ||
@use 'design-system'; | ||
|
||
.visit-support-data-consent-modal { | ||
&__body { | ||
&__preference-checkbox { | ||
margin-top: 16px; | ||
margin-bottom: 16px; | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
ui/components/app/modals/visit-support-data-consent-modal/index.ts
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 './visit-support-data-consent-modal'; |
16 changes: 16 additions & 0 deletions
16
.../app/modals/visit-support-data-consent-modal/visit-support-data-consent-modal.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,16 @@ | ||
import React from 'react'; | ||
import VisitSupportDataConsentModal from '.'; | ||
|
||
export default { | ||
title: 'Components/App/Modals/VisitSupportDataConsentModal', | ||
}; | ||
|
||
export const DefaultStory = () => ( | ||
<VisitSupportDataConsentModal | ||
version="1.0.0" | ||
isOpen | ||
onClose={() => {}} | ||
/> | ||
); | ||
|
||
DefaultStory.storyName = 'Default'; |
129 changes: 129 additions & 0 deletions
129
...mponents/app/modals/visit-support-data-consent-modal/visit-support-data-consent-modal.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,129 @@ | ||
import React, { useCallback, useContext } from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
import { useI18nContext } from '../../../../hooks/useI18nContext'; | ||
import { selectSessionData } from '../../../../selectors/identity/authentication'; | ||
import { getMetaMetricsId } from '../../../../selectors/selectors'; | ||
import { openWindow } from '../../../../helpers/utils/window'; | ||
import { | ||
Modal, | ||
ModalOverlay, | ||
ModalContent, | ||
ModalHeader, | ||
Box, | ||
ModalFooter, | ||
ButtonPrimary, | ||
ButtonPrimarySize, | ||
ModalBody, | ||
Text, | ||
ButtonSecondary, | ||
ButtonSecondarySize, | ||
} from '../../../../components/component-library'; | ||
Check failure on line 20 in ui/components/app/modals/visit-support-data-consent-modal/visit-support-data-consent-modal.tsx
|
||
import { | ||
Display, | ||
TextVariant, | ||
BlockSize, | ||
} from '../../../../helpers/constants/design-system'; | ||
import { | ||
MetaMetricsContextProp, | ||
MetaMetricsEventCategory, | ||
MetaMetricsEventName, | ||
} from '../../../../../shared/constants/metametrics'; | ||
import { MetaMetricsContext } from '../../../../contexts/metametrics'; | ||
import { SUPPORT_LINK } from '../../../../../shared/lib/ui-utils'; | ||
|
||
type VisitSupportDataConsentModalProps = { | ||
onClose: () => void; | ||
isOpen: boolean; | ||
}; | ||
|
||
const VisitSupportDataConsentModal: React.FC< | ||
VisitSupportDataConsentModalProps | ||
> = ({ isOpen, onClose }) => { | ||
const version = process.env.METAMASK_VERSION; | ||
const t = useI18nContext(); | ||
const trackEvent = useContext(MetaMetricsContext); | ||
const sessionData = useSelector(selectSessionData); | ||
const profileId = sessionData?.profile?.profileId; | ||
const metaMetricsId = useSelector(getMetaMetricsId); | ||
|
||
const handleClickContactSupportButton = useCallback(() => { | ||
onClose(); | ||
const supportLinkWithUserId = `${SUPPORT_LINK}?metamask_version=${version}&metamask_profile_id=${profileId}&metamask_metametrics_id=${metaMetricsId}`; | ||
trackEvent( | ||
{ | ||
category: MetaMetricsEventCategory.Settings, | ||
event: MetaMetricsEventName.SupportLinkClicked, | ||
properties: { | ||
url: supportLinkWithUserId, | ||
}, | ||
}, | ||
{ | ||
contextPropsIntoEventProperties: [MetaMetricsContextProp.PageTitle], | ||
}, | ||
); | ||
openWindow(supportLinkWithUserId); | ||
}, [version, profileId, metaMetricsId, trackEvent, onClose]); | ||
|
||
const handleClickNoShare = useCallback(() => { | ||
onClose(); | ||
trackEvent( | ||
{ | ||
category: MetaMetricsEventCategory.Settings, | ||
event: MetaMetricsEventName.SupportLinkClicked, | ||
properties: { | ||
url: SUPPORT_LINK, | ||
}, | ||
}, | ||
{ | ||
contextPropsIntoEventProperties: [MetaMetricsContextProp.PageTitle], | ||
}, | ||
); | ||
openWindow(SUPPORT_LINK as string); | ||
}, [onClose, trackEvent]); | ||
|
||
return ( | ||
<Modal | ||
isOpen={isOpen} | ||
onClose={onClose} | ||
data-testid="visit-support-data-consent-modal" | ||
className="visit-support-data-consent-modal" | ||
> | ||
<ModalOverlay /> | ||
<ModalContent> | ||
<ModalHeader>{t('visitSupportDataConsentModalTitle')}</ModalHeader> | ||
<ModalBody | ||
paddingLeft={4} | ||
paddingRight={4} | ||
className="visit-support-data-consent-modal__body" | ||
> | ||
<Text variant={TextVariant.bodyMd}> | ||
{t('visitSupportDataConsentModalDescription')} | ||
</Text> | ||
</ModalBody> | ||
|
||
<ModalFooter> | ||
<Box display={Display.Flex} gap={4}> | ||
<ButtonSecondary | ||
size={ButtonSecondarySize.Lg} | ||
width={BlockSize.Half} | ||
onClick={handleClickNoShare} | ||
data-testid="visit-support-data-consent-modal-reject-button" | ||
> | ||
{t('visitSupportDataConsentModalReject')} | ||
</ButtonSecondary> | ||
<ButtonPrimary | ||
size={ButtonPrimarySize.Lg} | ||
width={BlockSize.Half} | ||
onClick={handleClickContactSupportButton} | ||
data-testid="visit-support-data-consent-modal-accept-button" | ||
> | ||
{t('visitSupportDataConsentModalAccept')} | ||
</ButtonPrimary> | ||
</Box> | ||
</ModalFooter> | ||
</ModalContent> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default VisitSupportDataConsentModal; |
Oops, something went wrong.