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 3 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
4 changes: 2 additions & 2 deletions cypress/e2e/safe-apps/tx-builder.spec.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ describe('Tx-builder Safe App tests', { defaultCommandTimeout: 20000 }, () => {
getBody().findByText(safeapps.createBatchStr).click()
getBody().findByText(safeapps.sendBatchStr).click()
})
cy.get('p').contains('1').should('be.visible')
cy.get('p').contains('2').should('be.visible')
cy.get('p').contains('1').should('exist')
cy.get('p').contains('2').should('exist')
Copy link
Member Author

Choose a reason for hiding this comment

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

This was failing for some reason. Fixed after consultation with @mike10ca.

})

it('Verify a batch cannot be created with invalid address [C56617]', () => {
Expand Down
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.
45 changes: 45 additions & 0 deletions src/components/dashboard/Recovery/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
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 css from './styles.module.css'

export function Recovery(): ReactElement {
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="primary" size="small" className={css.chip} />
</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
1 change: 1 addition & 0 deletions src/utils/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export enum FEATURES {
RISK_MITIGATION = 'RISK_MITIGATION',
PUSH_NOTIFICATIONS = 'PUSH_NOTIFICATIONS',
NATIVE_WALLETCONNECT = 'NATIVE_WALLETCONNECT',
RECOVERY = 'RECOVERY',
}

export const hasFeature = (chain: ChainInfo, feature: FEATURES): boolean => {
Expand Down
Loading