-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEAT]: Handling already created key with new or same Ledger device (#…
…7687) * [FEAT]: Handling alredy created key with new or same Ledger device * [FIX]: integration tests ✅ * Fix mocktest
- Loading branch information
1 parent
eb9a36f
commit 297ce51
Showing
36 changed files
with
1,735 additions
and
1,488 deletions.
There are no files selected for viewing
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,6 @@ | ||
--- | ||
"ledger-live-desktop": patch | ||
"@ledgerhq/trustchain": patch | ||
--- | ||
|
||
Handling alredy created key with new or same Ledger device |
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
87 changes: 87 additions & 0 deletions
87
apps/ledger-live-desktop/src/newArch/features/WalletSync/components/GenericStatusDisplay.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,87 @@ | ||
import { Box, Flex, Icons, Text } from "@ledgerhq/react-ui"; | ||
import React from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
import styled, { useTheme } from "styled-components"; | ||
import { AnalyticsPage } from "../hooks/useWalletSyncAnalytics"; | ||
import TrackPage from "~/renderer/analytics/TrackPage"; | ||
import ButtonV3 from "~/renderer/components/ButtonV3"; | ||
|
||
export type GenericProps = { | ||
title?: string; | ||
description?: string; | ||
withClose?: boolean; | ||
withCta?: boolean; | ||
onClick?: () => void; | ||
onClose?: () => void; | ||
analyticsPage?: AnalyticsPage; | ||
type?: "success" | "info"; | ||
specificCta?: string; | ||
}; | ||
|
||
const Container = styled(Box)` | ||
background-color: ${p => p.theme.colors.opacityDefault.c05}; | ||
border-radius: 100%; | ||
height: 72px; | ||
width: 72px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
`; | ||
|
||
export const GenericStatusDisplay = ({ | ||
title, | ||
description, | ||
withClose = false, | ||
withCta = false, | ||
onClick, | ||
onClose, | ||
analyticsPage, | ||
type, | ||
specificCta, | ||
}: GenericProps) => { | ||
const { t } = useTranslation(); | ||
const { colors } = useTheme(); | ||
|
||
return ( | ||
<Flex flexDirection="column" alignItems="center" justifyContent="center" rowGap="24px"> | ||
<TrackPage category={String(analyticsPage)} /> | ||
<Container> | ||
{type === "info" ? ( | ||
<Icons.InformationFill size={"L"} color={colors.primary.c60} /> | ||
) : ( | ||
<Icons.CheckmarkCircleFill size={"L"} color={colors.success.c60} /> | ||
)} | ||
</Container> | ||
<Text fontSize={24} variant="h4Inter" color="neutral.c100" textAlign="center"> | ||
{title} | ||
</Text> | ||
<Text variant="bodyLineHeight" color="neutral.c70" textAlign="center"> | ||
{description} | ||
</Text> | ||
|
||
{withClose || withCta ? ( | ||
<BottomContainer | ||
mb={3} | ||
width={"100%"} | ||
px={"40px"} | ||
flexDirection="column" | ||
justifyContent="center" | ||
rowGap={"16px"} | ||
> | ||
{withCta && onClick && ( | ||
<ButtonV3 variant="main" onClick={onClick} flex={1}> | ||
{specificCta ?? t("walletSync.success.synchAnother")} | ||
</ButtonV3> | ||
)} | ||
{withClose && ( | ||
<ButtonV3 variant="shade" onClick={onClose} flex={1}> | ||
{t("walletSync.success.close")} | ||
</ButtonV3> | ||
)} | ||
</BottomContainer> | ||
) : null} | ||
</Flex> | ||
); | ||
}; | ||
|
||
const BottomContainer = styled(Flex)``; |
4 changes: 4 additions & 0 deletions
4
apps/ledger-live-desktop/src/newArch/features/WalletSync/components/Info.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,4 @@ | ||
import React from "react"; | ||
import { GenericProps, GenericStatusDisplay } from "./GenericStatusDisplay"; | ||
|
||
export const Info = (props: GenericProps) => <GenericStatusDisplay {...props} type="info" />; |
79 changes: 2 additions & 77 deletions
79
apps/ledger-live-desktop/src/newArch/features/WalletSync/components/Success.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 |
---|---|---|
@@ -1,79 +1,4 @@ | ||
import { Box, Flex, Icons, Text } from "@ledgerhq/react-ui"; | ||
import React from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
import styled, { useTheme } from "styled-components"; | ||
import TrackPage from "~/renderer/analytics/TrackPage"; | ||
import ButtonV3 from "~/renderer/components/ButtonV3"; | ||
import { AnalyticsPage } from "../hooks/useWalletSyncAnalytics"; | ||
import { GenericProps, GenericStatusDisplay } from "./GenericStatusDisplay"; | ||
|
||
type Props = { | ||
title?: string; | ||
description?: string; | ||
withClose?: boolean; | ||
withCta?: boolean; | ||
onClick?: () => void; | ||
onClose?: () => void; | ||
analyticsPage?: AnalyticsPage; | ||
}; | ||
|
||
const Container = styled(Box)` | ||
background-color: ${p => p.theme.colors.opacityDefault.c05}; | ||
border-radius: 100%; | ||
height: 72px; | ||
width: 72px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
`; | ||
|
||
export const Success = ({ | ||
title, | ||
description, | ||
withClose = false, | ||
withCta = false, | ||
onClick, | ||
onClose, | ||
analyticsPage, | ||
}: Props) => { | ||
const { t } = useTranslation(); | ||
const { colors } = useTheme(); | ||
|
||
return ( | ||
<Flex flexDirection="column" alignItems="center" justifyContent="center" rowGap="24px"> | ||
<TrackPage category={String(analyticsPage)} /> | ||
<Container> | ||
<Icons.CheckmarkCircleFill size={"L"} color={colors.success.c60} /> | ||
</Container> | ||
<Text fontSize={24} variant="h4Inter" color="neutral.c100" textAlign="center"> | ||
{title} | ||
</Text> | ||
<Text variant="bodyLineHeight" color="neutral.c70" textAlign="center"> | ||
{description} | ||
</Text> | ||
|
||
{withClose || withCta ? ( | ||
<BottomContainer | ||
mb={3} | ||
width={"100%"} | ||
px={"40px"} | ||
flexDirection="column" | ||
justifyContent="center" | ||
rowGap={"16px"} | ||
> | ||
{withCta && onClick && ( | ||
<ButtonV3 variant="main" onClick={onClick} flex={1}> | ||
{t("walletSync.success.synchAnother")} | ||
</ButtonV3> | ||
)} | ||
{withClose && ( | ||
<ButtonV3 variant="shade" onClick={onClose} flex={1}> | ||
{t("walletSync.success.close")} | ||
</ButtonV3> | ||
)} | ||
</BottomContainer> | ||
) : null} | ||
</Flex> | ||
); | ||
}; | ||
|
||
const BottomContainer = styled(Flex)``; | ||
export const Success = (props: GenericProps) => <GenericStatusDisplay {...props} type="success" />; |
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
43 changes: 43 additions & 0 deletions
43
...p/src/newArch/features/WalletSync/screens/Synchronize/06-ActivationAlreadyCreatedSame.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,43 @@ | ||
import React from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
import { useDispatch } from "react-redux"; | ||
import { setDrawerVisibility, setFlow } from "~/renderer/actions/walletSync"; | ||
import { Flow, Step } from "~/renderer/reducers/walletSync"; | ||
import { AnalyticsPage, useWalletSyncAnalytics } from "../../hooks/useWalletSyncAnalytics"; | ||
import { Info } from "../../components/Info"; | ||
|
||
export default function AlreadyCreatedWithSameSeedStep() { | ||
const { t } = useTranslation(); | ||
const dispatch = useDispatch(); | ||
|
||
const { onClickTrack } = useWalletSyncAnalytics(); | ||
|
||
const understood = () => { | ||
dispatch(setFlow({ flow: Flow.WalletSyncActivated, step: Step.WalletSyncActivated })); | ||
onClickTrack({ | ||
button: "I Understand", | ||
page: AnalyticsPage.AlreadySecuredSameSeed, | ||
flow: "Wallet Sync", | ||
}); | ||
}; | ||
|
||
const onClose = () => { | ||
dispatch(setDrawerVisibility(false)); | ||
onClickTrack({ | ||
button: "Close", | ||
page: AnalyticsPage.AlreadySecuredSameSeed, | ||
flow: "Wallet Sync", | ||
}); | ||
}; | ||
return ( | ||
<Info | ||
title={t("walletSync.alreadySecureError.title")} | ||
description={t("walletSync.alreadySecureError.description")} | ||
withCta | ||
onClick={understood} | ||
onClose={onClose} | ||
analyticsPage={AnalyticsPage.AlreadySecuredSameSeed} | ||
specificCta={t("walletSync.alreadySecureError.cta")} | ||
/> | ||
); | ||
} |
44 changes: 44 additions & 0 deletions
44
.../src/newArch/features/WalletSync/screens/Synchronize/07-ActivationAlreadyCreatedOther.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,44 @@ | ||
import React from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
import { useDispatch } from "react-redux"; | ||
import { setDrawerVisibility, setFlow } from "~/renderer/actions/walletSync"; | ||
import { Flow, Step } from "~/renderer/reducers/walletSync"; | ||
import { AnalyticsPage, useWalletSyncAnalytics } from "../../hooks/useWalletSyncAnalytics"; | ||
import { Error } from "../../components/Error"; | ||
|
||
export default function AlreadyCreatedOtherSeedStep() { | ||
const { t } = useTranslation(); | ||
const dispatch = useDispatch(); | ||
|
||
const { onClickTrack } = useWalletSyncAnalytics(); | ||
|
||
const deleteKey = () => { | ||
dispatch(setFlow({ flow: Flow.ManageBackup, step: Step.ManageBackup })); | ||
onClickTrack({ | ||
button: "Delete my encryption key", | ||
page: AnalyticsPage.AlreadySecuredOtherSeed, | ||
flow: "Wallet Sync", | ||
}); | ||
}; | ||
|
||
const onClose = () => { | ||
dispatch(setDrawerVisibility(false)); | ||
onClickTrack({ | ||
button: "close", | ||
page: AnalyticsPage.AlreadySecuredOtherSeed, | ||
flow: "Wallet Sync", | ||
}); | ||
}; | ||
|
||
return ( | ||
<Error | ||
title={t("walletSync.alreadySecureOtherSeedError.title")} | ||
description={t("walletSync.alreadySecureOtherSeedError.description")} | ||
onClick={deleteKey} | ||
analyticsPage={AnalyticsPage.AlreadySecuredOtherSeed} | ||
cta={t("walletSync.alreadySecureOtherSeedError.cta")} | ||
ctaVariant="shade" | ||
onClose={onClose} | ||
/> | ||
); | ||
} |
Oops, something went wrong.