diff --git a/frontend/src/screens/channels/Channels.tsx b/frontend/src/screens/channels/Channels.tsx index e783e6c1..59dd9c07 100644 --- a/frontend/src/screens/channels/Channels.tsx +++ b/frontend/src/screens/channels/Channels.tsx @@ -18,6 +18,17 @@ import { ChannelsTable } from "src/components/channels/ChannelsTable.tsx"; import EmptyState from "src/components/EmptyState.tsx"; import ExternalLink from "src/components/ExternalLink"; import Loading from "src/components/Loading.tsx"; +import { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, + AlertDialogTrigger, +} from "src/components/ui/alert-dialog"; import { Alert, AlertDescription, @@ -40,8 +51,16 @@ import { DropdownMenuSeparator, DropdownMenuTrigger, } from "src/components/ui/dropdown-menu.tsx"; +import { Label } from "src/components/ui/label"; import { LoadingButton } from "src/components/ui/loading-button.tsx"; import { CircleProgress } from "src/components/ui/progress.tsx"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "src/components/ui/select"; import { Tooltip, TooltipContent, @@ -66,6 +85,25 @@ import { cn } from "src/lib/utils.ts"; import { Channel, Node, UpdateChannelRequest } from "src/types"; import { request } from "src/utils/request"; +const RESET_KEY_OPTIONS = [ + { + value: "ALL", + label: "All", + }, + { + value: "LatestRgsSyncTimestamp", + label: "LatestRgsSyncTimestamp", + }, + { + value: "Scorer", + label: "Scorer", + }, + { + value: "NetworkGraph", + label: "NetworkGraph", + }, +]; + export default function Channels() { useSyncWallet(); const { data: channels, mutate: reloadChannels } = useChannels(); @@ -79,6 +117,7 @@ export default function Channels() { const { toast } = useToast(); const [drainingAlbySharedFunds, setDrainingAlbySharedFunds] = React.useState(false); + const [resetKey, setResetKey] = React.useState(); const isDesktop = useIsDesktop(); const nodeHealth = channels ? getNodeHealth(channels) : 0; @@ -150,29 +189,20 @@ export default function Channels() { async function resetRouter() { try { - const key = prompt( - "Enter key to reset (choose one of ALL, LatestRgsSyncTimestamp, Scorer, NetworkGraph). After resetting, you'll need to re-enter your unlock password.", - "ALL" - ); - if (!key) { - console.error("Cancelled reset"); - return; - } - await request("/api/reset-router", { method: "POST", - body: JSON.stringify({ key }), + body: JSON.stringify({ key: resetKey }), headers: { "Content-Type": "application/json", }, }); await reloadInfo(); - toast({ description: "🎉 Router reset" }); + toast({ title: "🎉 Router reset" }); } catch (error) { console.error(error); toast({ variant: "destructive", - description: "Something went wrong: " + error, + title: "Something went wrong: " + error, }); } } @@ -187,78 +217,123 @@ export default function Channels() { description="Manage your lightning node" contentRight={
- - - - - - - -
{ - if (!nodeConnectionInfo) { - return; - } - copyToClipboard(nodeConnectionInfo.pubkey); - }} - > -
Node
-
- {nodeConnectionInfo?.pubkey || "Loading..."} + + + + + + + + +
{ + if (!nodeConnectionInfo) { + return; + } + copyToClipboard(nodeConnectionInfo.pubkey); + }} + > +
Node
+
+ {nodeConnectionInfo?.pubkey || "Loading..."} +
+ {nodeConnectionInfo && ( + + )}
- {nodeConnectionInfo && ( - - )} -
- - - + + + + + + + Deposit Bitcoin + + + {(balances?.onchain.spendable || 0) > ONCHAIN_DUST_SATS && ( + + Withdraw Savings Balance + {redeemOnchainFunds.isLoading && } + + )} + - - - Deposit Bitcoin - - - {(balances?.onchain.spendable || 0) > ONCHAIN_DUST_SATS && ( - - Withdraw Savings Balance - {redeemOnchainFunds.isLoading && } + + Management + + + Connected Peers + + + + + Sign Message + - )} - - - - Management - - - Connected Peers - - - - - Sign Message - - - - Clear Routing Data - - - - + + + Clear Routing Data + + + + + + + + Clear Routing Data + +
+

Are you sure you want to clear your routing data?

+
+ + +
+

+ After clearing, you'll need to login again to restart + your node. +

+
+
+
+ + Cancel + + Confirm + + +
+