-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[LLD] - [LIVE-12264] - Add Wallet Sync activation screen (#6782)
* Add Activation screen for Wallet Sync * Add WalletSync store * Split WalletSync by Activaton & Manage side content * Add changeset * Add first test * fix lint * Fix test with translation --------- Co-authored-by: Martin Cayuelas <[email protected]>
- Loading branch information
1 parent
f72f4d5
commit 879fda4
Showing
16 changed files
with
224 additions
and
25 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,5 @@ | ||
--- | ||
"ledger-live-desktop": patch | ||
--- | ||
|
||
Add Wallet Sync activation screen |
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
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
36 changes: 36 additions & 0 deletions
36
apps/ledger-live-desktop/src/renderer/reducers/walletSync.ts
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,36 @@ | ||
import { handleActions } from "redux-actions"; | ||
import { Handlers } from "./types"; | ||
|
||
export type WalletSyncState = { | ||
activated: boolean; | ||
}; | ||
|
||
const initialState: WalletSyncState = { | ||
activated: false, | ||
}; | ||
|
||
type HandlersPayloads = { | ||
WALLET_SYNC_ACTIVATE: boolean; | ||
WALLET_SYNC_DEACTIVATE: boolean; | ||
}; | ||
|
||
type MarketHandlers<PreciseKey = true> = Handlers<WalletSyncState, HandlersPayloads, PreciseKey>; | ||
|
||
const handlers: MarketHandlers = { | ||
WALLET_SYNC_ACTIVATE: (state: WalletSyncState) => ({ | ||
...state, | ||
activated: true, | ||
}), | ||
WALLET_SYNC_DEACTIVATE: (state: WalletSyncState) => ({ | ||
...state, | ||
activated: false, | ||
}), | ||
}; | ||
|
||
// Selectors | ||
export const walletSyncSelector = (state: { walletSync: WalletSyncState }) => state.walletSync; | ||
|
||
export default handleActions<WalletSyncState, HandlersPayloads[keyof HandlersPayloads]>( | ||
handlers as unknown as MarketHandlers<false>, | ||
initialState, | ||
); |
81 changes: 81 additions & 0 deletions
81
...ktop/src/renderer/screens/settings/sections/General/WalletSync/SideContent/Activation.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,81 @@ | ||
import { Box, Flex, Icons, Text } from "@ledgerhq/react-ui"; | ||
import React, { PropsWithChildren } from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
import ButtonV3 from "~/renderer/components/ButtonV3"; | ||
import useTheme from "~/renderer/hooks/useTheme"; | ||
|
||
const LogoWrapper = ({ children, opacity = "70%" }: PropsWithChildren & { opacity?: string }) => ( | ||
<Box> | ||
<Flex padding="7px" borderRadius="13px" border="1px solid hsla(0, 0%, 100%, 0.05)"> | ||
<Flex | ||
borderRadius="9px" | ||
backgroundColor="hsla(248, 100%, 85%, 0.08)" | ||
padding="5px" | ||
opacity={opacity} | ||
> | ||
{children} | ||
</Flex> | ||
</Flex> | ||
</Box> | ||
); | ||
|
||
const WalletSyncActivation = () => { | ||
const { colors } = useTheme(); | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<Flex | ||
flexDirection="column" | ||
height="100%" | ||
paddingX="64px" | ||
alignSelf="center" | ||
justifyContent="center" | ||
rowGap="48px" | ||
> | ||
<Flex flexDirection="column" alignSelf="center" justifyContent="center" rowGap="24px"> | ||
<Flex justifyContent="center" alignItems="center"> | ||
<LogoWrapper> | ||
<Icons.Mobile color={colors.constant.purple} /> | ||
</LogoWrapper> | ||
|
||
<LogoWrapper opacity="100%"> | ||
<Icons.Refresh size="L" color={colors.constant.purple} /> | ||
</LogoWrapper> | ||
|
||
<LogoWrapper> | ||
<Icons.Desktop color={colors.constant.purple} /> | ||
</LogoWrapper> | ||
</Flex> | ||
|
||
<Text fontSize={24} variant="h4Inter" textAlign="center"> | ||
{t("walletSync.activate.title")} | ||
</Text> | ||
<Text fontSize={14} variant="body" color="hsla(0, 0%, 58%, 1)" textAlign="center"> | ||
{t("walletSync.activate.description")} | ||
</Text> | ||
<Flex justifyContent="center"> | ||
<ButtonV3 variant="main"> {t("walletSync.activate.cta")}</ButtonV3> | ||
</Flex> | ||
</Flex> | ||
|
||
<Box> | ||
<Flex | ||
flexDirection="row" | ||
padding="18px" | ||
borderRadius="12px" | ||
backgroundColor={colors.opacityDefault.c05} | ||
justifyContent="space-between" | ||
> | ||
<Text variant="body" fontSize={14} flexShrink={1}> | ||
{t("walletSync.alreadySync.title")} | ||
</Text> | ||
<Box> | ||
<ButtonV3 variant="shade">{t("walletSync.alreadySync.cta")}</ButtonV3> | ||
</Box> | ||
</Flex> | ||
</Box> | ||
</Flex> | ||
); | ||
}; | ||
|
||
export default WalletSyncActivation; |
7 changes: 7 additions & 0 deletions
7
...-desktop/src/renderer/screens/settings/sections/General/WalletSync/SideContent/Manage.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,7 @@ | ||
import React from "react"; | ||
|
||
const WalletSyncManage = () => { | ||
return <div>Wallet Sync</div>; | ||
}; | ||
|
||
export default WalletSyncManage; |
29 changes: 29 additions & 0 deletions
29
...p/src/renderer/screens/settings/sections/General/WalletSync/__tests__/walletSync.test.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,29 @@ | ||
/** | ||
* @jest-environment jsdom | ||
*/ | ||
|
||
import { describe, it, expect } from "@jest/globals"; | ||
|
||
import React from "react"; | ||
import { render, screen, waitFor } from "tests/testUtils"; | ||
import "@testing-library/jest-dom"; | ||
import { WalletSyncPages } from "../setupTests/shared"; | ||
|
||
describe("Rendering", () => { | ||
it("should loads and displays WalletSync Row", async () => { | ||
render(<WalletSyncPages />); | ||
expect(screen.getByRole("button", { name: "Manage" })).toBeTruthy(); | ||
}); | ||
|
||
it("should open drawer and display Wallet Sync Activation flow", async () => { | ||
const { user } = render(<WalletSyncPages />); | ||
const button = screen.getByRole("button", { name: "Manage" }); | ||
|
||
await user.click(button); | ||
await waitFor(() => | ||
expect(screen.getByRole("button", { name: "Create a backup" })).toBeDefined(), | ||
); | ||
|
||
expect(screen.getByRole("button", { name: "Synchronize" })).toBeDefined(); | ||
}); | ||
}); |
22 changes: 9 additions & 13 deletions
22
...ttings/sections/General/WalletSyncRow.tsx → ...ngs/sections/General/WalletSync/index.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
11 changes: 11 additions & 0 deletions
11
...e-desktop/src/renderer/screens/settings/sections/General/WalletSync/setupTests/shared.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,11 @@ | ||
import * as React from "react"; | ||
import WalletSyncRow from "../index"; | ||
|
||
export function WalletSyncPages() { | ||
return ( | ||
<> | ||
<div id="modals"></div> | ||
<WalletSyncRow /> | ||
</> | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,20 @@ | ||
import { jest } from "@jest/globals"; | ||
import { TextDecoder, TextEncoder } from "util"; | ||
|
||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore FIX TS config | ||
jest.mock("@sentry/electron/renderer", () => ({ | ||
init: jest.fn(), | ||
setUser: jest.fn(), | ||
captureException: jest.fn(), | ||
addBreadcrumb: jest.fn(), | ||
setTags: jest.fn(), | ||
})); | ||
|
||
jest.mock("src/sentry/install", () => ({ | ||
init: jest.fn(), | ||
})); | ||
|
||
global.TextEncoder = TextEncoder; | ||
// @ts-expect-error weird compatibility | ||
global.TextDecoder = TextDecoder; |
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 |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
"package.json", | ||
"release-notes.json", | ||
"tests", | ||
"index-types.d.ts" | ||
"index-types.d.ts", | ||
"tests/jestSetup.ts" | ||
] | ||
} |