-
Notifications
You must be signed in to change notification settings - Fork 468
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enable recovery flow structure (#2775)
* feat: enable recovery flow structure * feat: intro step * feat: basic settings template * feat: settings + review step * fix: add test coverage + remove comments * fix: cleanup code + rename test * fix: test * fix: spacing + add connector * refactor: extract `Chip` component * fix: rerender + spacing
- Loading branch information
Showing
20 changed files
with
870 additions
and
15 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,18 @@ | ||
import { Chip as MuiChip } from '@mui/material' | ||
import type { ChipProps } from '@mui/material' | ||
import type { ReactElement } from 'react' | ||
|
||
import { useDarkMode } from '@/hooks/useDarkMode' | ||
|
||
export function Chip(props: ChipProps): ReactElement { | ||
const isDarkMode = useDarkMode() | ||
return ( | ||
<MuiChip | ||
label="New" | ||
color={isDarkMode ? 'primary' : 'secondary'} | ||
size="small" | ||
sx={{ borderRadius: '4px', fontSize: '12px' }} | ||
{...props} | ||
/> | ||
) | ||
} |
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 |
---|---|---|
|
@@ -25,8 +25,3 @@ | |
font-weight: 700; | ||
display: inline; | ||
} | ||
|
||
.chip { | ||
border-radius: 4px; | ||
font-size: 12px; | ||
} |
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,46 @@ | ||
import { Alert, Box, Button, Grid, Paper, Typography } from '@mui/material' | ||
import { useContext } from 'react' | ||
import type { ReactElement } from 'react' | ||
|
||
import { EnableRecoveryFlow } from '@/components/tx-flow/flows/EnableRecovery' | ||
import { TxModalContext } from '@/components/tx-flow' | ||
import { Chip } from '@/components/common/Chip' | ||
import ExternalLink from '@/components/common/ExternalLink' | ||
|
||
export function Recovery(): ReactElement { | ||
const { setTxFlow } = useContext(TxModalContext) | ||
|
||
return ( | ||
<Paper sx={{ p: 4 }}> | ||
<Grid container spacing={3}> | ||
<Grid item lg={4} xs={12}> | ||
<Box display="flex" alignItems="center" gap={1} mb={1}> | ||
<Typography variant="h4" fontWeight="bold"> | ||
Account recovery | ||
</Typography> | ||
|
||
<Chip label="New" /> | ||
</Box> | ||
</Grid> | ||
|
||
<Grid item xs> | ||
<Typography mb={2}> | ||
Choose a trusted guardian to recover your Safe Account, in case you should ever lose access to your Account. | ||
Enabling the Account recovery module will require a transactions. | ||
</Typography> | ||
|
||
<Alert severity="info"> | ||
Unhappy with the provided option? {/* TODO: Add link */} | ||
<ExternalLink noIcon href="#"> | ||
Give us feedback | ||
</ExternalLink> | ||
</Alert> | ||
|
||
<Button variant="contained" onClick={() => setTxFlow(<EnableRecoveryFlow />)} sx={{ mt: 2 }}> | ||
Set up recovery | ||
</Button> | ||
</Grid> | ||
</Grid> | ||
</Paper> | ||
) | ||
} |
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
23 changes: 23 additions & 0 deletions
23
src/components/tx-flow/flows/EnableRecovery/EnableRecoveryFlowEmailHint.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,23 @@ | ||
import { Box, Typography, SvgIcon, Alert } from '@mui/material' | ||
import type { ReactElement } from 'react' | ||
|
||
import LightbulbIcon from '@/public/images/common/lightbulb.svg' | ||
|
||
import infoWidgetCss from '@/components/new-safe/create/InfoWidget/styles.module.css' | ||
|
||
export function EnableRecoveryFlowEmailHint(): ReactElement { | ||
return ( | ||
<Alert severity="info" sx={{ border: 'unset', p: 3 }} icon={false}> | ||
<Box className={infoWidgetCss.title} sx={{ backgroundColor: ({ palette }) => palette.info.main }}> | ||
<SvgIcon component={LightbulbIcon} inheritViewBox className={infoWidgetCss.titleIcon} /> | ||
<Typography variant="caption"> | ||
<b>Security tip</b> | ||
</Typography> | ||
</Box> | ||
<Typography variant="body2" mt={2}> | ||
For security reasons, we highly recommend adding an email address. You will be notified once a Guardian | ||
initiates recovery and be able to reject it if it's a malicious attempt. | ||
</Typography> | ||
</Alert> | ||
) | ||
} |
73 changes: 73 additions & 0 deletions
73
src/components/tx-flow/flows/EnableRecovery/EnableRecoveryFlowIntro.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,73 @@ | ||
import { Button, CardActions, Divider, Grid, Typography } from '@mui/material' | ||
import type { ReactElement, ReactNode } from 'react' | ||
|
||
import TxCard from '../../common/TxCard' | ||
import RecoveryGuardians from '@/public/images/settings/spending-limit/beneficiary.svg' | ||
import RecoveryGuardian from '@/public/images/transactions/recovery-guardian.svg' | ||
import RecoveryDelay from '@/public/images/settings/spending-limit/time.svg' | ||
import RecoveryExecution from '@/public/images/transactions/recovery-execution.svg' | ||
|
||
import css from './styles.module.css' | ||
import commonCss from '@/components/tx-flow/common/styles.module.css' | ||
|
||
const RecoverySteps: Array<{ Icon: ReactElement; title: string; subtitle: ReactNode }> = [ | ||
{ | ||
Icon: RecoveryGuardians, | ||
title: 'Choose a guardian and set a delay', | ||
subtitle: | ||
'Only your chosen guardian can initiate the recovery process. The process can be cancelled at any time during the delay period.', | ||
}, | ||
{ | ||
Icon: RecoveryGuardian, | ||
title: 'Lost access? Let the guardian connect', | ||
subtitle: 'The recovery process can be initiated by a trusted guardian when connected to your Safe Account.', | ||
}, | ||
{ | ||
Icon: RecoveryDelay, | ||
title: 'Start the recovery process', | ||
subtitle: ( | ||
<> | ||
Your <b>guardian</b> chooses new Safe Account owner(s) that you control and can initiates the recovery | ||
transaction. | ||
</> | ||
), | ||
}, | ||
{ | ||
Icon: RecoveryExecution, | ||
title: 'All done! The Account is yours again', | ||
subtitle: | ||
'Once the delay period has passed, you can execute the recovery transaction and regain access to your Safe Account.', | ||
}, | ||
] | ||
|
||
export function EnableRecoveryFlowIntro({ onSubmit }: { onSubmit: () => void }): ReactElement { | ||
return ( | ||
<TxCard> | ||
<Grid container display="flex" gap={4} className={css.connector}> | ||
{RecoverySteps.map(({ Icon, title, subtitle }, index) => ( | ||
<Grid item xs={12} key={index}> | ||
<Grid container display="flex" gap={3}> | ||
<Grid item> | ||
<Icon className={css.icon} /> | ||
</Grid> | ||
<Grid item xs> | ||
<Typography variant="h5" mb={0.5}> | ||
{title} | ||
</Typography> | ||
<Typography variant="body2">{subtitle}</Typography> | ||
</Grid> | ||
</Grid> | ||
</Grid> | ||
))} | ||
</Grid> | ||
|
||
<Divider className={commonCss.nestedDivider} /> | ||
|
||
<CardActions sx={{ mt: 'var(--space-1) !important' }}> | ||
<Button variant="contained" onClick={onSubmit}> | ||
Next | ||
</Button> | ||
</CardActions> | ||
</TxCard> | ||
) | ||
} |
Oops, something went wrong.