Skip to content
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

feat: recovery dashboard widget #2768

Merged
merged 7 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions public/images/common/recovery.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions src/components/dashboard/Recovery/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { Box, Button, Card, Chip, Grid, Typography } from '@mui/material'
import type { ReactElement } from 'react'

import RecoveryLogo from '@/public/images/common/recovery.svg'
import { WidgetBody, WidgetContainer } from '@/components/dashboard/styled'
import { useDarkMode } from '@/hooks/useDarkMode'

import css from './styles.module.css'

export function Recovery(): ReactElement {
const isDarkMode = useDarkMode()

const onClick = () => {
// TODO: Open enable recovery flow
}

return (
<WidgetContainer>
<Typography component="h2" variant="subtitle1" className={css.label}>
New in {'Safe{Wallet}'}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: The Figma design says New in Safe here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wording is incorrect in the design. This is a Safe{Wallet} feature.

</Typography>

<WidgetBody>
<Card className={css.card}>
<Grid container className={css.grid}>
<Grid item>
<RecoveryLogo alt="Vault with a circular arrow around it" />
</Grid>
<Grid item xs>
<Box className={css.wrapper}>
<Typography variant="h4" className={css.title}>
Introducing account recovery{' '}
</Typography>
<Chip label="New" color={isDarkMode ? 'primary' : 'secondary'} size="small" className={css.chip} />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest we create a static-primary color in our theme the same way we have static-main so we don't have to use a hook here. Lets do it as a separate PR though.

</Box>
<Typography mt={1} mb={3}>
Ensure that you never lose access to your funds by choosing a guardian to recover your account.
</Typography>
<Button variant="contained" onClick={onClick}>
Set up recovery
</Button>
</Grid>
</Grid>
</Card>
</WidgetBody>
</WidgetContainer>
)
}
32 changes: 32 additions & 0 deletions src/components/dashboard/Recovery/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.label {
font-weight: 700;
margin-bottom: var(--space-2);
}

.card {
padding: var(--space-4);
height: inherit;
}

.grid {
display: flex;
align-items: center;
height: inherit;
gap: var(--space-3);
}

.wrapper {
display: flex;
align-items: center;
gap: var(--space-1);
}

.title {
font-weight: 700;
display: inline;
}

.chip {
border-radius: 4px;
font-size: 12px;
}
80 changes: 0 additions & 80 deletions src/components/dashboard/Relaying/index.tsx
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind removing this widget but for visibility I would suggest we document it somewhere.

This file was deleted.

33 changes: 0 additions & 33 deletions src/components/dashboard/Relaying/styles.module.css

This file was deleted.

12 changes: 6 additions & 6 deletions src/components/dashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import SafeAppsDashboardSection from '@/components/dashboard/SafeAppsDashboardSe
import GovernanceSection from '@/components/dashboard/GovernanceSection/GovernanceSection'
import CreationDialog from '@/components/dashboard/CreationDialog'
import { useRouter } from 'next/router'
import Relaying from '@/components/dashboard/Relaying'
import { Recovery } from './Recovery'
import { FEATURES } from '@/utils/chains'
import { useHasFeature } from '@/hooks/useChains'
import { CREATION_MODAL_QUERY_PARM } from '../new-safe/create/logic'

const Dashboard = (): ReactElement => {
const router = useRouter()
const supportsRelaying = useHasFeature(FEATURES.RELAYING)
const supportsRecovery = useHasFeature(FEATURES.RECOVERY)
const { [CREATION_MODAL_QUERY_PARM]: showCreationModal = '' } = router.query

return (
Expand All @@ -28,13 +28,13 @@ const Dashboard = (): ReactElement => {
<PendingTxsList />
</Grid>

<Grid item xs={12} lg={supportsRelaying ? 6 : undefined}>
<FeaturedApps stackedLayout={!!supportsRelaying} />
<Grid item xs={12} lg={supportsRecovery ? 6 : undefined}>
<FeaturedApps stackedLayout={!!supportsRecovery} />
</Grid>

{supportsRelaying ? (
{supportsRecovery ? (
<Grid item xs={12} lg={6}>
<Relaying />
<Recovery />
</Grid>
) : null}

Expand Down
6 changes: 6 additions & 0 deletions src/hooks/__tests__/useLoadRecovery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ describe('useLoadRecovery', () => {
txNonce,
queueNonce,
queue: [
{
...transactionsAdded[0],
timestamp: 69,
validFrom: BigNumber.from(69).add(txCooldown),
expiresAt: null,
},
{
...transactionsAdded[1],
timestamp: 420,
Expand Down
Loading