Skip to content

Commit 066a863

Browse files
authored
Feat/add having issues btn to migration (#968)
* feat: add temporary mitigation for migration end state * feat: add mitigation on nami namespace injection
1 parent a449ccd commit 066a863

File tree

4 files changed

+81
-69
lines changed

4 files changed

+81
-69
lines changed

src/features/analytics/events.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export enum Events {
115115
NamiMigrationDismissedNotStarted = 'nami tool | nami | migration dismissed | not started | click',
116116
NamiMigrationDismissedInProgress = 'nami tool | nami | migration dismissed | in progress | click',
117117
NamiMigrationOpenLaceOrOpenChromeStore = 'nami tool | nami | open lace or open chrome store link | click',
118+
NamiMigrationHavingIssuesClick = 'nami tool | nami | having migration issues | click',
118119
}
119120

120121
export type Property =

src/pages/Content/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ const injectScript = () => {
1616
};
1717

1818
async function shouldInject() {
19-
const { laceMigration } = (await storage.local.get(MIGRATION_KEY)) || {
19+
const { laceMigration } = (await storage.local.get([MIGRATION_KEY])) || {
2020
laceMigration: undefined,
2121
};
22+
2223
// Prevent injection into window.cardano namespace if migration has been completed
24+
// or if the user has dismissed because they are having issues migrating (setting migration state back to 'none')
2325
if (laceMigration === MigrationState.Completed) return false;
2426
const documentElement = document.documentElement.nodeName;
2527
const docElemCheck = documentElement

src/ui/lace-migration/components/migration-view/migration-view.component.jsx

Lines changed: 68 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
import React, { useEffect } from 'react';
2-
import { MigrationState } from '../../../../api/migration-tool/migrator/migration-state.data';
2+
import {
3+
MigrationState,
4+
MIGRATION_KEY,
5+
} from '../../../../api/migration-tool/migrator/migration-state.data';
36
import { Carousel } from '../carousel/carousel.component';
47
import { Slide1 } from '../carousel/slides/Slide1.component';
58
import { Slide2 } from '../carousel/slides/Slide2.component';
69
import { Slide3 } from '../carousel/slides/Slide3.component';
710
import { AlmostThere } from '../almost-there/almost-there.component';
811
import { AllDone } from '../all-done/all-done.component';
912
import { NoWallet } from '../no-wallet/no-wallet.component';
10-
import { useColorModeValue, Flex } from '@chakra-ui/react';
13+
import { useColorModeValue, Flex, Link } from '@chakra-ui/react';
1114
import { useFeatureFlagsContext } from '../../../../features/feature-flags/provider';
1215
import { Events } from '../../../../features/analytics/events';
1316
import { useCaptureEvent } from '../../../../features/analytics/hooks';
1417
import { AnalyticsConsentModal } from '../../../../features/analytics/ui/AnalyticsConsentModal';
1518
import { useAnalyticsContext } from '../../../../features/analytics/provider';
19+
import { storage } from 'webextension-polyfill';
1620

1721
export const MigrationView = ({
1822
migrationState,
@@ -42,36 +46,44 @@ export const MigrationView = ({
4246
const dismissibleSeconds =
4347
featureFlags?.['is-migration-active']?.dismissInterval;
4448

49+
const hasShowIssuesButton =
50+
featureFlags?.['show-having-issues-button'] || false;
51+
52+
const handleHavingIssuesClick = () => {
53+
storage.local.set({
54+
[MIGRATION_KEY]: MigrationState.None,
55+
});
56+
captureEvent(Events.NamiMigrationHavingIssuesClick);
57+
};
58+
4559
if (!hasWallet) {
4660
captureEvent(Events.MigrationViewNoWalletViewed);
4761
return (
48-
<><Flex
49-
h="100%"
50-
backgroundColor={panelBg}
51-
>
52-
<Flex
53-
pt="40px"
54-
pb="30px"
55-
px="40px"
56-
borderTopRadius='20px'
57-
backgroundColor={bgColor}
58-
mt='17px'
59-
flexDirection='column'
60-
h='calc(100% - 17px)'
61-
w="100%"
62-
>
63-
<NoWallet
64-
isLaceInstalled={isLaceInstalled}
65-
onAction={onNoWalletActionClick}
66-
isDismissable={isDismissable}
67-
dismissibleSeconds={dismissibleSeconds}
68-
/>
62+
<>
63+
<Flex h="100%" backgroundColor={panelBg}>
64+
<Flex
65+
pt="40px"
66+
pb="30px"
67+
px="40px"
68+
borderTopRadius="20px"
69+
backgroundColor={bgColor}
70+
mt="17px"
71+
flexDirection="column"
72+
h="calc(100% - 17px)"
73+
w="100%"
74+
>
75+
<NoWallet
76+
isLaceInstalled={isLaceInstalled}
77+
onAction={onNoWalletActionClick}
78+
isDismissable={isDismissable}
79+
dismissibleSeconds={dismissibleSeconds}
80+
/>
81+
</Flex>
6982
</Flex>
70-
</Flex>
71-
<AnalyticsConsentModal
72-
askForConsent={analytics.consent === undefined}
73-
setConsent={setAnalyticsConsent}
74-
/>
83+
<AnalyticsConsentModal
84+
askForConsent={analytics.consent === undefined}
85+
setConsent={setAnalyticsConsent}
86+
/>
7587
</>
7688
);
7789
}
@@ -81,19 +93,16 @@ export const MigrationView = ({
8193
case MigrationState.None:
8294
captureEvent(Events.MigrationNoStartedViewed);
8395
return (
84-
<Flex
85-
h="100%"
86-
backgroundColor={panelBg}
87-
>
96+
<Flex h="100%" backgroundColor={panelBg}>
8897
<Flex
8998
flexDirection={'column'}
9099
pt="40px"
91100
pb="30px"
92101
px="0px"
93-
borderTopRadius='20px'
102+
borderTopRadius="20px"
94103
backgroundColor={bgColor}
95-
mt='17px'
96-
h='calc(100% - 17px)'
104+
mt="17px"
105+
h="calc(100% - 17px)"
97106
w="100%"
98107
>
99108
<Carousel onSlideSwitched={onSlideSwitched}>
@@ -124,19 +133,16 @@ export const MigrationView = ({
124133
if (!isLaceInstalled) {
125134
onWaitingForLaceScreenViewed?.();
126135
return (
127-
<Flex
128-
h="100%"
129-
backgroundColor={panelBg}
130-
>
136+
<Flex h="100%" backgroundColor={panelBg}>
131137
<Flex
132138
pt="40px"
133139
pb="30px"
134140
px="40px"
135-
borderTopRadius='20px'
141+
borderTopRadius="20px"
136142
backgroundColor={bgColor}
137-
mt='17px'
138-
flexDirection='column'
139-
h='calc(100% - 17px)'
143+
mt="17px"
144+
flexDirection="column"
145+
h="calc(100% - 17px)"
140146
w="100%"
141147
>
142148
<AlmostThere
@@ -151,19 +157,16 @@ export const MigrationView = ({
151157
} else {
152158
onOpenLaceScreenViewed?.();
153159
return (
154-
<Flex
155-
h="100%"
156-
backgroundColor={panelBg}
157-
>
160+
<Flex h="100%" backgroundColor={panelBg}>
158161
<Flex
159162
pt="40px"
160163
pb="30px"
161164
px="40px"
162-
borderTopRadius='20px'
165+
borderTopRadius="20px"
163166
backgroundColor={bgColor}
164-
mt='17px'
165-
flexDirection='column'
166-
h='calc(100% - 17px)'
167+
mt="17px"
168+
flexDirection="column"
169+
h="calc(100% - 17px)"
167170
w="100%"
168171
>
169172
<AlmostThere
@@ -180,19 +183,16 @@ export const MigrationView = ({
180183
case MigrationState.Completed:
181184
onAllDoneScreenViewed?.();
182185
return (
183-
<Flex
184-
h="100%"
185-
backgroundColor={panelBg}
186-
>
186+
<Flex h="100%" backgroundColor={panelBg}>
187187
<Flex
188188
pt="40px"
189189
pb="30px"
190190
px="40px"
191-
borderTopRadius='20px'
191+
borderTopRadius="20px"
192192
backgroundColor={bgColor}
193-
mt='17px'
194-
flexDirection='column'
195-
h='calc(100% - 17px)'
193+
mt="17px"
194+
flexDirection="column"
195+
h="calc(100% - 17px)"
196196
w="100%"
197197
>
198198
<AllDone
@@ -201,6 +201,15 @@ export const MigrationView = ({
201201
isLaceInstalled ? onOpenLaceClicked : onDownloadLaceClicked
202202
}
203203
/>
204+
{hasShowIssuesButton && (
205+
<Link
206+
textAlign="center"
207+
marginTop={4}
208+
onClick={handleHavingIssuesClick}
209+
>
210+
Having issues? Click here to continue using Nami
211+
</Link>
212+
)}
204213
</Flex>
205214
</Flex>
206215
);

src/ui/lace-migration/components/migration.component.jsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,30 +137,30 @@ export const AppWithMigration = () => {
137137
slideIndex: nextSlideIndex,
138138
});
139139
}}
140-
onUpgradeWalletClicked={async() => {
140+
onUpgradeWalletClicked={async () => {
141141
enableMigration();
142142
await captureEvent(Events.MigrationUpgradeYourWalletClicked);
143143
}}
144-
onWaitingForLaceScreenViewed={async() => {
145-
await captureEvent(Events.MigrationDownloadLaceScreenViewed);
144+
onWaitingForLaceScreenViewed={async () => {
145+
await captureEvent(Events.MigrationDownloadLaceScreenViewed);
146146
}}
147-
onOpenLaceScreenViewed={async() => {
147+
onOpenLaceScreenViewed={async () => {
148148
await captureEvent(Events.MigrationOpenLaceScreenViewed);
149149
}}
150-
onDownloadLaceClicked={async() => {
150+
onDownloadLaceClicked={async () => {
151151
await captureEvent(Events.MigrationDownloadLaceClicked);
152152
window.open(
153153
`https://chromewebstore.google.com/detail/lace/${secrets.LACE_EXTENSION_ID}`
154154
);
155155
}}
156-
onOpenLaceClicked={async() => {
157-
await captureEvent(Events.MigrationOpenLaceClicked);
156+
onOpenLaceClicked={async () => {
157+
await captureEvent(Events.MigrationOpenLaceClicked);
158158
openLace();
159159
}}
160-
onAllDoneScreenViewed={async() => {
160+
onAllDoneScreenViewed={async () => {
161161
await captureEvent(Events.MigrationAllDoneScreenViewed);
162162
}}
163-
onNoWalletActionClick={async() => {
163+
onNoWalletActionClick={async () => {
164164
if (state.isLaceInstalled) {
165165
await captureEvent(Events.MigrationOpenLaceClicked);
166166
openLace();

0 commit comments

Comments
 (0)