Skip to content

Commit 4c4bd74

Browse files
Merge pull request #3288 from getAlby/update-banner-close
fix: blue boxes
2 parents 3a4a063 + 00060c1 commit 4c4bd74

File tree

13 files changed

+78
-88
lines changed

13 files changed

+78
-88
lines changed

src/app/components/Alert/index.tsx

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,51 @@
1+
import { PopiconsXLine } from "@popicons/react";
2+
import { useState } from "react";
13
import { classNames } from "~/app/utils";
24

35
type Props = {
46
type: "warn" | "info";
57
children: React.ReactNode;
8+
showClose?: boolean;
9+
onClose?: () => void;
610
};
711

8-
export default function Alert({ type, children }: Props) {
12+
export default function Alert({
13+
type,
14+
children,
15+
showClose = false,
16+
onClose,
17+
}: Props) {
18+
const [isVisible, setIsVisible] = useState(true);
19+
20+
const handleClose = () => {
21+
setIsVisible(false);
22+
if (onClose) {
23+
onClose();
24+
}
25+
};
26+
27+
if (!isVisible) return null;
28+
929
return (
1030
<div
1131
className={classNames(
12-
"border rounded-md p-3",
13-
type == "warn" &&
14-
"text-orange-700 dark:text-orange-300 bg-orange-50 dark:bg-orange-900 border-orange-100 dark:border-orange-900",
15-
type == "info" &&
32+
"border rounded-md p-3 flex justify-between relative",
33+
type === "warn" &&
34+
"text-orange-700 dark:text-orange-300 bg-orange-50 dark:bg-orange-900 border-orange-100 dark:border-orange-900",
35+
type === "info" &&
1636
"text-blue-700 dark:text-blue-300 bg-blue-50 dark:bg-blue-900 border-blue-100 dark:border-blue-900"
1737
)}
1838
>
19-
{children}
39+
{showClose && (
40+
<button
41+
onClick={handleClose}
42+
className="absolute right-2 top-2 text-gray-600 dark:text-neutral-400 hover:text-gray-700 dark:hover:text-neutral-300"
43+
aria-label="Close alert"
44+
>
45+
<PopiconsXLine className="w-5 h-5" />
46+
</button>
47+
)}
48+
<div className="pr-8">{children}</div>
2049
</div>
2150
);
2251
}

src/app/screens/Home/DefaultView/index.tsx

Lines changed: 18 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const DefaultView: FC<Props> = (props) => {
5555
const [isBlockedUrl, setIsBlockedUrl] = useState<boolean>(false);
5656
const [currentAccount, setCurrentAccount] = useState<GetAccountRes>();
5757
const [nostrPublicKey, setNostrPublicKey] = useState("");
58+
const [hasSeenInfoBanner, setHasSeenInfoBanner] = useState<boolean>(true);
5859

5960
const { transactions, isLoadingTransactions, loadTransactions } =
6061
useTransactions();
@@ -85,6 +86,8 @@ const DefaultView: FC<Props> = (props) => {
8586
const userAccount = await api.getAccount();
8687
const nostrPrivateKey = await api.nostr.getPrivateKey(userAccount.id);
8788

89+
setHasSeenInfoBanner(userAccount.hasSeenInfoBanner);
90+
8891
setNostrPublicKey(
8992
nostrPrivateKey ? await nostr.derivePublicKey(nostrPrivateKey) : ""
9093
);
@@ -176,41 +179,26 @@ const DefaultView: FC<Props> = (props) => {
176179
</Alert>
177180
)}
178181

179-
{account?.sharedNode && (
180-
<Alert type="info">
181-
<div className="flex items-center gap-2">
182-
<div className="shrink-0">
183-
<PopiconsCircleExclamationLine className="w-5 h-5" />
184-
</div>
185-
<span className="text-sm">
186-
<Trans
187-
i18nKey={"default_view.using_shared_node"}
188-
t={t}
189-
components={[
190-
// eslint-disable-next-line react/jsx-key
191-
<Hyperlink
192-
className="underline"
193-
href="https://getalby.com/node/embrace_albyhub"
194-
target="_blank"
195-
rel="noopener nofollow"
196-
/>,
197-
]}
198-
/>
199-
</span>
200-
</div>
201-
</Alert>
202-
)}
203-
204-
{account?.usingFeeCredits && (
205-
<Alert type="info">
182+
{(account?.usingFeeCredits || account?.nodeRequired) &&
183+
!hasSeenInfoBanner ? (
184+
<Alert
185+
type="info"
186+
showClose
187+
onClose={async () => {
188+
await api.editAccount(account.id, {
189+
hasSeenInfoBanner: true,
190+
});
191+
setHasSeenInfoBanner(true);
192+
}}
193+
>
206194
<div className="flex items-center gap-2">
207195
<div className="shrink-0">
208196
<PopiconsCircleExclamationLine className="w-5 h-5" />
209197
</div>
210198
<span className="text-sm">
211199
<Trans
212-
i18nKey={"default_view.using_fee_credits"}
213-
t={t}
200+
i18nKey={"setup_wallet"}
201+
t={tCommon}
214202
values={{
215203
max_account_balance: getFormattedSats(
216204
account?.limits?.max_account_balance || 0
@@ -220,39 +208,7 @@ const DefaultView: FC<Props> = (props) => {
220208
// eslint-disable-next-line react/jsx-key
221209
<Hyperlink
222210
className="underline"
223-
href="https://getalby.com/onboarding/node/new"
224-
target="_blank"
225-
rel="noopener nofollow"
226-
/>,
227-
// eslint-disable-next-line react/jsx-key
228-
<Hyperlink
229-
className="underline"
230-
href="https://guides.getalby.com/user-guide/alby-account-and-browser-extension/alby-account/faqs-alby-account/what-are-fee-credits-in-my-alby-account"
231-
target="_blank"
232-
rel="noopener nofollow"
233-
/>,
234-
]}
235-
/>
236-
</span>
237-
</div>
238-
</Alert>
239-
)}
240-
241-
{account?.nodeRequired ? (
242-
<Alert type="info">
243-
<div className="flex items-center gap-2">
244-
<div className="shrink-0">
245-
<PopiconsCircleExclamationLine className="w-5 h-5" />
246-
</div>
247-
<span className="text-sm">
248-
<Trans
249-
i18nKey={"node_required"}
250-
t={tCommon}
251-
components={[
252-
// eslint-disable-next-line react/jsx-key
253-
<Hyperlink
254-
className="underline"
255-
href="https://getalby.com/onboarding/node/new"
211+
href="https://getalby.com/node/embrace_albyhub"
256212
target="_blank"
257213
rel="noopener nofollow"
258214
/>,

src/app/screens/Options/TestConnection/index.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { useSettings } from "~/app/context/SettingsContext";
1515
import TestConnectionResultCard from "~/app/screens/Options/TestConnection/card";
1616
import api from "~/common/lib/api";
1717
import msg from "~/common/lib/msg";
18+
1819
import type { AccountInfo } from "~/types";
1920

2021
export default function TestConnection() {
@@ -30,6 +31,7 @@ export default function TestConnection() {
3031
}>();
3132
const [errorMessage, setErrorMessage] = useState("");
3233
const [loading, setLoading] = useState(false);
34+
const { getFormattedSats } = useSettings();
3335

3436
const navigate = useNavigate();
3537
const { t } = useTranslation("translation", {
@@ -127,13 +129,18 @@ export default function TestConnection() {
127129
</div>
128130
<span className="text-sm">
129131
<Trans
130-
i18nKey={"node_required"}
132+
i18nKey={"setup_wallet"}
131133
t={tCommon}
134+
values={{
135+
max_account_balance: getFormattedSats(
136+
account?.limits?.max_account_balance || 0
137+
),
138+
}}
132139
components={[
133140
// eslint-disable-next-line react/jsx-key
134141
<Hyperlink
135142
className="underline"
136-
href="https://getalby.com/onboarding/node/new"
143+
href="https://getalby.com/node/embrace_albyhub"
137144
target="_blank"
138145
rel="noopener nofollow"
139146
/>,

src/common/lib/api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export interface GetAccountRes extends Pick<Account, "id" | "name"> {
7575
hasMnemonic: boolean;
7676
isMnemonicBackupDone: boolean;
7777
hasImportedNostrKey: boolean;
78+
hasSeenInfoBanner: boolean;
7879
bitcoinNetwork: BitcoinNetworkType;
7980
useMnemonicForLnurlAuth: boolean;
8081
}

src/extension/background-script/actions/accounts/__tests__/get.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ describe("account info", () => {
6363
nostrEnabled: false,
6464
liquidEnabled: false,
6565
hasMnemonic: false,
66+
hasSeenInfoBanner: false,
6667
hasImportedNostrKey: true,
6768
bitcoinNetwork: "bitcoin",
6869
useMnemonicForLnurlAuth: false,
@@ -91,6 +92,7 @@ describe("account info", () => {
9192
nostrEnabled: true,
9293
liquidEnabled: true,
9394
hasMnemonic: true,
95+
hasSeenInfoBanner: false,
9496
hasImportedNostrKey: true,
9597
bitcoinNetwork: "regtest",
9698
useMnemonicForLnurlAuth: true,

src/extension/background-script/actions/accounts/edit.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ const edit = async (message: MessageAccountEdit) => {
2727
message.args.isMnemonicBackupDone;
2828
}
2929

30+
if (message.args.hasSeenInfoBanner !== undefined) {
31+
accounts[accountId].hasSeenInfoBanner = message.args.hasSeenInfoBanner;
32+
}
33+
3034
state.setState({ accounts });
3135
// make sure we immediately persist the updated accounts
3236
await state.getState().saveToStorage();

src/extension/background-script/actions/accounts/get.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const get = async (message: MessageAccountGet) => {
3030
// Note: undefined (default for new accounts) it is also considered imported
3131
hasImportedNostrKey: account.hasImportedNostrKey !== false,
3232
bitcoinNetwork: account.bitcoinNetwork || "bitcoin",
33+
hasSeenInfoBanner: account.hasSeenInfoBanner || false,
3334
useMnemonicForLnurlAuth: account.useMnemonicForLnurlAuth || false,
3435
};
3536

src/i18n/locales/de/translation.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -435,9 +435,7 @@
435435
"description": "Erstelle einen Master Key für Bitcoin, Nostr und Liquid oder importiere ein bestehendes Nostr-Konto."
436436
}
437437
},
438-
"upgrade_account": "Du verwendest die alte LNDHub-Einstellung. <0>Bitte verbinde dich erneut</0> mit deinem Alby-Konto, um Zugang zu den neuesten Funktionen zu erhalten.",
439-
"using_fee_credits": "Schließe deine Einrichtung ab und verbinde deine Geldbörse mit deinem <0>Alby-Konto</0> für unbegrenzte Zahlungen. Bis deine Einrichtung abgeschlossen ist, kannst du bis zu {{max_account_balance}} sats als <1>Gebührenguthaben</1> erhalten",
440-
"using_shared_node": "Die von dir genutzte gemeinsame Wallet wird zugunsten der Alby Hub Wallet veraltet sein. Um weiterhin Zahlungen zu senden und zu empfangen, <0>richte deine Geldbörse</0> bis zum 3. Januar 2025 ein."
438+
"upgrade_account": "Du verwendest die alte LNDHub-Einstellung. <0>Bitte verbinde dich erneut</0> mit deinem Alby-Konto, um Zugang zu den neuesten Funktionen zu erhalten."
441439
},
442440
"allowance_view": {
443441
"sats": "sats",
@@ -1312,8 +1310,7 @@
13121310
"advanced": "Erweiterte Einstellungen anzeigen",
13131311
"details": "Einzelheiten",
13141312
"general": "Allgemein",
1315-
"wallet_settings": "Wallet-Einstellungen",
1316-
"node_required": "Schließe deine Einrichtung von deiner Geldbörse ab, damit du <0>hier</0> unbegrenzt Zahlungen senden und empfangen kannst. Bis dahin kannst du nur bis zu 50.000 Sats als <1>Gebührenguthaben</1> empfangen."
1313+
"wallet_settings": "Wallet-Einstellungen"
13171314
},
13181315
"permissions": {
13191316
"commando": {

src/i18n/locales/en/translation.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,7 @@
413413
"description": "Fund your account and receive via your lightning address or an invoice"
414414
}
415415
},
416-
"upgrade_account": "You are using the old LNDHub setup. <0>Please re-connect</0> your Alby account to get access to the latest features.",
417-
"using_fee_credits": "Finish your setup and connect your wallet to your <0>Alby account</0> for unlimited payments. Until your setup is complete, you can receive up to {{max_account_balance}} sats as <1>fee credits</1>",
418-
"using_shared_node": "The shared wallet that you use is being deprecated in favor of the Alby Hub wallet. To continue sending and receiving payments <0>setup your wallet</0> by January 3, 2025."
416+
"upgrade_account": "You are using the old LNDHub setup. <0>Please re-connect</0> your Alby account to get access to the latest features."
419417
}
420418
},
421419
"accounts": {
@@ -1142,7 +1140,7 @@
11421140
"website": "Website",
11431141
"wallet_settings": "Wallet Settings",
11441142
"apps": "Apps",
1145-
"node_required": "Finish setting up your wallet to start sending and receiving unlimited payments <0>here</0>. Until then, you can receive up to 50,000 sats as <1>fee credits</1> only.",
1143+
"setup_wallet": "Finish your <0>Alby account setup</0> for unlimited payments. Until your setup is complete, you can receive up to {{max_account_balance}} as <1>fee credits</1>",
11461144
"actions": {
11471145
"back": "Back",
11481146
"delete": "Delete",

src/i18n/locales/ru/translation.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,7 @@
373373
},
374374
"using_shared_node": "Используемый вами общий кошелек устаревает в пользу кошелька Alby Hub. Чтобы продолжать отправлять и получать платежи <0>настройте свой кошелек</0> до 3 января 2025 года.",
375375
"no_transactions": "Для этого аккаунта пока нет транзакций.",
376-
"upgrade_account": "Вы используете старую настройку LNDHub. <0>Пожалуйста, переподключите</0> свою учетную запись Alby, чтобы получить доступ к новейшим функциям.",
377-
"using_fee_credits": "Завершите настройку и подключите кошелек к своему <0>аккаунту Alby</0> для неограниченных платежей. Пока настройка не завершена, вы можете получать до {{max_account_balance}} сатов в качестве <1>бесплатных кредитов</1>"
376+
"upgrade_account": "Вы используете старую настройку LNDHub. <0>Пожалуйста, переподключите</0> свою учетную запись Alby, чтобы получить доступ к новейшим функциям."
378377
},
379378
"allowance_view": {
380379
"permissions": "Разрешения",

0 commit comments

Comments
 (0)