Skip to content

Commit 808170f

Browse files
Merge pull request LedgerHQ#11385 from LedgerHQ/feat/lld-modular-drawer-with-remote-data
✨ LLD - Modular drawer is now leveraging the dada backend service
2 parents fd58c5f + ce2e917 commit 808170f

28 files changed

+8911
-308
lines changed

.changeset/good-impalas-drop.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"ledger-live-desktop": minor
3+
"@ledgerhq/live-env": minor
4+
---
5+
6+
LLD - Modular Drawer is now leveraging the DADA service instead of local data

apps/ledger-live-desktop/src/newArch/features/ModularDrawer/ModularDrawerFlowManager.stories.tsx

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type { Meta, StoryObj } from "@storybook/react";
1313
import { expect, fn, userEvent, waitFor, within } from "@storybook/test";
1414
import React from "react";
1515
import { Provider } from "react-redux";
16-
import { legacy_createStore as createStore } from "redux";
16+
import { configureStore } from "@reduxjs/toolkit";
1717
import { track } from "~/renderer/analytics/__mocks__/segment";
1818
import { ARB_ACCOUNT, BTC_ACCOUNT, ETH_ACCOUNT } from "../__mocks__/accounts.mock";
1919
import {
@@ -22,11 +22,11 @@ import {
2222
bitcoinCurrency,
2323
ethereumCurrency,
2424
} from "../__mocks__/useSelectAssetFlow.mock";
25-
import ModularDrawerFlowManager, {
26-
ModularDrawerFlowManagerProps,
27-
} from "./ModularDrawerFlowManager";
25+
import { assetsDataApi } from "./data/state-manager/api";
26+
import ModularDrawerFlowManager from "./ModularDrawerFlowManager";
27+
import { ModularDrawerFlowManagerProps } from "./types";
2828

29-
const store = createStore(() => ({
29+
const createMockState = () => ({
3030
accounts: [ARB_ACCOUNT, ETH_ACCOUNT, BTC_ACCOUNT],
3131
wallet: {
3232
accountNames: new Map([
@@ -36,7 +36,7 @@ const store = createStore(() => ({
3636
]),
3737
},
3838
currency: {
39-
type: "FiatCurrency",
39+
type: "FiatCurrency" as const,
4040
ticker: "USD",
4141
name: "US Dollar",
4242
symbol: "$",
@@ -51,7 +51,24 @@ const store = createStore(() => ({
5151
],
5252
},
5353
application: { debug: {} },
54-
}));
54+
});
55+
56+
const initialMockState = createMockState();
57+
58+
const store = configureStore({
59+
reducer: {
60+
accounts: (state = initialMockState.accounts) => state,
61+
wallet: (state = initialMockState.wallet) => state,
62+
currency: (state = initialMockState.currency) => state,
63+
application: (state = initialMockState.application) => state,
64+
assetsDataApi: assetsDataApi.reducer,
65+
},
66+
middleware: getDefaultMiddleware =>
67+
getDefaultMiddleware({
68+
serializableCheck: false,
69+
immutableCheck: false,
70+
}).concat(assetsDataApi.middleware),
71+
});
5572

5673
function makeMockedContextValue(
5774
mockedFeatures: Partial<Record<FeatureId, Feature>>,
@@ -72,6 +89,7 @@ type ExtraStoryArgs = {
7289
networksLeftElement?: (typeof networksLeftElementOptions)[number] | "default";
7390
networksRightElement?: (typeof networksRightElementOptions)[number] | "default";
7491
assetsFilter?: (typeof filterOptions)[number] | "default";
92+
lldModularDrawerBackendDataEnabled?: boolean;
7593
};
7694

7795
type StoryArgs = ModularDrawerFlowManagerProps & ExtraStoryArgs;
@@ -85,6 +103,7 @@ const meta: Meta<StoryArgs> = {
85103
onAccountSelected: () => null,
86104
source: "sourceTest",
87105
flow: "Modular Asset Flow",
106+
lldModularDrawerBackendDataEnabled: false,
88107
},
89108
argTypes: {
90109
assetsFilter: {
@@ -107,14 +126,20 @@ const meta: Meta<StoryArgs> = {
107126
options: [...networksRightElementOptions, "default"],
108127
control: { type: "select" },
109128
},
129+
lldModularDrawerBackendDataEnabled: {
130+
control: { type: "boolean" },
131+
description: "Enable/disable the lldModularDrawerBackendData feature flag",
132+
},
110133
},
111134
decorators: [
112-
Story => {
135+
(Story, context) => {
136+
const { lldModularDrawerBackendDataEnabled = false } = context.args;
113137
return (
114138
<div style={{ minHeight: "400px", position: "relative", margin: "50px" }}>
115139
<FeatureFlagsProvider
116140
value={makeMockedContextValue({
117141
lldModularDrawer: { enabled: true, params: { enableModularization: true } },
142+
lldModularDrawerBackendData: { enabled: lldModularDrawerBackendDataEnabled },
118143
})}
119144
>
120145
<Provider store={store}>
@@ -168,13 +193,18 @@ export const CustomDrawerConfig: StoryObj<StoryArgs> = {
168193
<div style={{ color: "#333", backgroundColor: "#f9f9f9", padding: "5px" }}>
169194
<p style={{ fontSize: "16px", marginBottom: "8px" }}>
170195
Use the storybook controls below to alter the{" "}
171-
<span style={{ fontWeight: 600 }}>drawerConfiguration</span> parameters:
196+
<span style={{ fontWeight: 600 }}>drawerConfiguration</span> parameters and feature
197+
flags:
172198
</p>
173199
<p style={{ fontSize: "14px", marginBottom: "16px", color: "#555" }}>
174200
&quot;undefined&quot; represents no element shown, &quot;default&quot; represents the
175201
default element if the parameter is not provided in the drawerConfiguration object.
176202
</p>
177203
<ul style={{ paddingLeft: "20px", fontSize: "14px", marginBottom: "16px" }}>
204+
<li>
205+
<span style={{ fontWeight: 600 }}>lldModularDrawerBackendDataEnabled:</span> Toggle
206+
the lldModularDrawerBackendData feature flag to enable/disable backend data fetching.
207+
</li>
178208
<li>
179209
<span style={{ fontWeight: 600 }}>assetsFilter:</span> Element to display at the top
180210
of the drawer to filter assets.

0 commit comments

Comments
 (0)