mirror of
https://github.com/getAlby/hub.git
synced 2026-08-13 12:33:39 +02:00
refactor(frontend): address review feedback on wallet on-chain mode
- OnchainTransactionsTable: don't flash the empty state while SWR is still loading; only render it once transactions is defined AND empty. - OnchainTransactionsTable: add DialogDescription to the details dialog so DialogContent has an accessible description (fixes Radix's dev warning and improves screen-reader flow). - OnchainTransactionsTable: swap the copy-tx-id native button for the shadcn Button in ghost/icon-xs — kept the row-level button native because the shadcn variants (justify-center, h-9, bg) fight the custom-shaped row surface. - Wallet: dynamic aria-label on the balance-mode toggle so the current state is announced (previously "Switch balance mode" hid the visible label). - Wallet: align on "On-chain Balance" (repo convention — ~18 other uses) instead of "On-Chain Balance". - Wallet: gate the "Open Your First Channel" alert on channels being loaded so it doesn't flash while useChannels() is resolving. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
bcd34f0f96
commit
6a8f47b3ab
2 changed files with 36 additions and 20 deletions
|
|
@ -14,6 +14,7 @@ import { Button } from "src/components/ui/button";
|
|||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
|
|
@ -136,6 +137,11 @@ function OnchainTransactionRow({
|
|||
<DialogTitle className={cn(isPending && "animate-pulse")}>
|
||||
{`${typeStateText} On-chain Transaction`}
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
{isPending
|
||||
? "This transaction is pending confirmation."
|
||||
: "This transaction has been confirmed on the blockchain."}
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<div className="space-y-6 text-sm">
|
||||
<div
|
||||
|
|
@ -174,14 +180,15 @@ function OnchainTransactionRow({
|
|||
<p className="break-all font-mono text-muted-foreground">
|
||||
{tx.txId}
|
||||
</p>
|
||||
<button
|
||||
<Button
|
||||
type="button"
|
||||
className="shrink-0 cursor-pointer text-muted-foreground"
|
||||
variant="ghost"
|
||||
size="icon-xs"
|
||||
onClick={() => copyToClipboard(tx.txId)}
|
||||
aria-label="Copy transaction ID"
|
||||
>
|
||||
<CopyIcon className="size-4" />
|
||||
</button>
|
||||
<CopyIcon />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -213,7 +220,11 @@ export function OnchainTransactionsTable() {
|
|||
const { data: info } = useInfo();
|
||||
const { data: transactions } = useOnchainTransactions();
|
||||
|
||||
if (!transactions?.length) {
|
||||
if (!transactions) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (transactions.length === 0) {
|
||||
return (
|
||||
<div className="flex w-full flex-1 flex-col">
|
||||
<EmptyState
|
||||
|
|
|
|||
|
|
@ -118,29 +118,34 @@ function Wallet() {
|
|||
balances.lightning.totalSpendable * 0.1 && (
|
||||
<LowReceivingCapacityAlert />
|
||||
)}
|
||||
{!isOnchainMode && hasChannelManagement && !hasChannelsOpen && (
|
||||
<Alert>
|
||||
<AlertTriangleIcon className="h-4 w-4" />
|
||||
<AlertTitle>Open Your First Channel</AlertTitle>
|
||||
<AlertDescription className="inline">
|
||||
You won't be able to receive or send payments until you{" "}
|
||||
<Link className="underline" to="/channels/first">
|
||||
open your first channel
|
||||
</Link>
|
||||
.
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
)}
|
||||
{!isOnchainMode &&
|
||||
hasChannelManagement &&
|
||||
channels &&
|
||||
!hasChannelsOpen && (
|
||||
<Alert>
|
||||
<AlertTriangleIcon className="h-4 w-4" />
|
||||
<AlertTitle>Open Your First Channel</AlertTitle>
|
||||
<AlertDescription className="inline">
|
||||
You won't be able to receive or send payments until you{" "}
|
||||
<Link className="underline" to="/channels/first">
|
||||
open your first channel
|
||||
</Link>
|
||||
.
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
)}
|
||||
<div className="flex w-full flex-col items-center gap-8 pt-12 pb-16 text-center">
|
||||
<div className="flex flex-col items-center gap-4">
|
||||
{hasChannelManagement ? (
|
||||
<button
|
||||
type="button"
|
||||
onClick={toggleBalanceMode}
|
||||
aria-label="Switch balance mode"
|
||||
aria-label={`Toggle balance mode, currently ${
|
||||
isOnchainMode ? "On-chain Balance" : "Spending Balance"
|
||||
}`}
|
||||
className="inline-flex items-center justify-center gap-1 text-xs font-medium leading-none uppercase text-muted-foreground transition-colors hover:text-foreground"
|
||||
>
|
||||
{isOnchainMode ? "On-Chain Balance" : "Spending Balance"}
|
||||
{isOnchainMode ? "On-chain Balance" : "Spending Balance"}
|
||||
<ArrowDownUpIcon aria-hidden className="size-3 shrink-0" />
|
||||
</button>
|
||||
) : (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue