1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-12 04:37:13 +01:00
metamask-extension/ui/components/app/modals/hold-to-reveal-modal/hold-to-reveal-modal.js
Monte Lai cdc1bce688
SRP hold to reveal (#17232)
* refactor class to functional component

* update messages

* fix: use classnames

* feat: add hold to reveal modal

* feat: add new zendesk url for secret recovery phrase and noncustodial wallet

* update: clipboard to clear copied text after delay

* fix: remove save to csv

* feat: update styles for reveal seed page

* fix: update reveal seed snapshot

* add test to check for modal

* fix: lint

* fix: unused messages locale

* fix: use new banner component

* fix: use new button from design system

* fix: update snapshot

* fix: lint

* revert text

* fix: lint

* fix: remove --copy-only

* fix: marginBottom prop value

* fix: iconName and prop error

* --made the QR code slightly smaller so it's less likely to have a scrollbar
--updated the snapshots

* fix: error message not displaying

* SRP hold to reveal using more DS components (#17583)

* Updating to add DS components and remove CSS

* Fixing rendered html and removing some unneeded props

* fix: set block to true

---------

Co-authored-by: Monte <monte.lai@consensys.net>

* fix: add descriptions to messages

* Update ui/components/ui/export-text-container/export-text-container.component.js

fix: lint

Co-authored-by: HowardBraham <HowardBraham@users.noreply.github.com>

* fix: remove using displayWarning in requestRevealSeedWords

* fix: update test to remove displayError

* fix: update design system enums

* fix: messages descriptions

* fix: banner to banneralert

* fix: update preview

* add additional tests

* fix: use jest instead of sinon

* add test if long press isn't completed

* add test if password is wrong

---------

Co-authored-by: Howard Braham <howrad@gmail.com>
Co-authored-by: George Marshall <george.marshall@consensys.net>
2023-02-15 10:07:33 -08:00

117 lines
3.1 KiB
JavaScript

import PropTypes from 'prop-types';
import React from 'react';
import withModalProps from '../../../../helpers/higher-order-components/with-modal-props';
import Box from '../../../ui/box';
import {
Text,
Button,
BUTTON_TYPES,
ButtonIcon,
ICON_NAMES,
} from '../../../component-library';
import {
AlignItems,
DISPLAY,
FLEX_DIRECTION,
JustifyContent,
Size,
TextVariant,
} from '../../../../helpers/constants/design-system';
import HoldToRevealButton from '../../hold-to-reveal-button';
import { useI18nContext } from '../../../../hooks/useI18nContext';
import ZENDESK_URLS from '../../../../helpers/constants/zendesk-url';
const HoldToRevealModal = ({ onLongPressed, hideModal }) => {
const t = useI18nContext();
const unlock = () => {
onLongPressed();
hideModal();
};
const handleCancel = () => {
hideModal();
};
return (
<Box
className="hold-to-reveal-modal"
display={DISPLAY.FLEX}
flexDirection={FLEX_DIRECTION.COLUMN}
justifyContent={JustifyContent.flexStart}
padding={6}
>
<Box
display={DISPLAY.FLEX}
flexDirection={FLEX_DIRECTION.ROW}
alignItems={AlignItems.center}
justifyContent={JustifyContent.spaceBetween}
marginBottom={6}
>
<Text variant={TextVariant.headingSm}>{t('holdToRevealTitle')}</Text>
<ButtonIcon
className="hold-to-reveal-modal__close"
iconName={ICON_NAMES.CLOSE}
size={Size.SM}
onClick={handleCancel}
ariaLabel={t('close')}
/>
</Box>
<Box
display={DISPLAY.FLEX}
flexDirection={FLEX_DIRECTION.COLUMN}
gap={4}
marginBottom={6}
>
<Text variant={TextVariant.bodyMd}>
{t('holdToRevealContent1', [
<Text
key="hold-to-reveal-2"
variant={TextVariant.bodyMdBold}
as="span"
>
{t('holdToRevealContent2')}
</Text>,
])}
</Text>
<Text variant={TextVariant.bodyMdBold}>
{t('holdToRevealContent3', [
<Text
key="hold-to-reveal-4"
variant={TextVariant.bodyMd}
as="span"
display={DISPLAY.INLINE}
>
{t('holdToRevealContent4')}
</Text>,
<Button
key="hold-to-reveal-5"
type={BUTTON_TYPES.LINK}
size={Size.auto}
href={ZENDESK_URLS.NON_CUSTODIAL_WALLET}
target="_blank"
rel="noopener noreferrer"
>
{t('holdToRevealContent5')}
</Button>,
])}
</Text>
</Box>
<HoldToRevealButton
buttonText={t('holdToReveal')}
onLongPressed={unlock}
marginLeft="auto"
marginRight="auto"
/>
</Box>
);
};
HoldToRevealModal.propTypes = {
// The function to be executed after the hold to reveal long press has been completed
onLongPressed: PropTypes.func.isRequired,
hideModal: PropTypes.func,
};
export default withModalProps(HoldToRevealModal);