diff --git a/frontend/src/components/ResetRoutingDataDialogContent.tsx b/frontend/src/components/ResetRoutingDataDialogContent.tsx new file mode 100644 index 00000000..1e6f1ebd --- /dev/null +++ b/frontend/src/components/ResetRoutingDataDialogContent.tsx @@ -0,0 +1,119 @@ +import React from "react"; +import { + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, +} from "src/components/ui/alert-dialog"; +import { Label } from "src/components/ui/label"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "src/components/ui/select"; +import { useToast } from "src/components/ui/use-toast"; +import { useInfo } from "src/hooks/useInfo"; +import { request } from "src/utils/request"; + +const RESET_KEY_OPTIONS = [ + { + value: "ALL", + label: "All", + }, + { + value: "Scorer", + label: "Scorer", + }, + { + value: "NetworkGraph", + label: "Network Graph", + }, +]; + +export function ResetRoutingDataDialogContent() { + const { mutate: reloadInfo } = useInfo(); + const { toast } = useToast(); + const [resetKey, setResetKey] = React.useState(); + + async function resetRouter() { + try { + await request("/api/reset-router", { + method: "POST", + body: JSON.stringify({ key: resetKey }), + headers: { + "Content-Type": "application/json", + }, + }); + await reloadInfo(); + toast({ title: "🎉 Router reset" }); + } catch (error) { + console.error(error); + toast({ + variant: "destructive", + title: "Something went wrong: " + error, + }); + } + } + + return ( + + + Clear Routing Data + +
+

Are you sure you want to clear your routing data?

+
+ + +
+
+

Clear Data Options

+

+ All - Clears + both the scorer and network graph data +

+

+ Scorer - + Clears the scores/penalties applied to nodes from past payment + attempts. +

+

+ Network Graph{" "} + - Clears the cache of nodes on the network +

+
+

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

+
+
+
+ + Cancel + + Confirm + + +
+ ); +} diff --git a/frontend/src/screens/channels/Channels.tsx b/frontend/src/screens/channels/Channels.tsx index 59dd9c07..cb9bd41d 100644 --- a/frontend/src/screens/channels/Channels.tsx +++ b/frontend/src/screens/channels/Channels.tsx @@ -18,17 +18,6 @@ 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, @@ -51,16 +40,8 @@ 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, @@ -75,7 +56,6 @@ import { import { useAlbyBalance } from "src/hooks/useAlbyBalance.ts"; import { useBalances } from "src/hooks/useBalances.ts"; import { useChannels } from "src/hooks/useChannels"; -import { useInfo } from "src/hooks/useInfo"; import { useIsDesktop } from "src/hooks/useMediaQuery.ts"; import { useNodeConnectionInfo } from "src/hooks/useNodeConnectionInfo.ts"; import { useRedeemOnchainFunds } from "src/hooks/useRedeemOnchainFunds.ts"; @@ -85,25 +65,6 @@ 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(); @@ -111,13 +72,11 @@ export default function Channels() { const { data: balances } = useBalances(); const { data: albyBalance, mutate: reloadAlbyBalance } = useAlbyBalance(); const [nodes, setNodes] = React.useState([]); - const { mutate: reloadInfo } = useInfo(); const redeemOnchainFunds = useRedeemOnchainFunds(); const { toast } = useToast(); const [drainingAlbySharedFunds, setDrainingAlbySharedFunds] = React.useState(false); - const [resetKey, setResetKey] = React.useState(); const isDesktop = useIsDesktop(); const nodeHealth = channels ? getNodeHealth(channels) : 0; @@ -187,26 +146,6 @@ export default function Channels() { } } - async function resetRouter() { - try { - await request("/api/reset-router", { - method: "POST", - body: JSON.stringify({ key: resetKey }), - headers: { - "Content-Type": "application/json", - }, - }); - await reloadInfo(); - toast({ title: "🎉 Router reset" }); - } catch (error) { - console.error(error); - toast({ - variant: "destructive", - title: "Something went wrong: " + error, - }); - } - } - const showHostedBalance = albyBalance && albyBalance.sats > ALBY_HIDE_HOSTED_BALANCE_LIMIT; @@ -217,123 +156,72 @@ export default function Channels() { description="Manage your lightning node" contentRight={
- - - - - - - - -
{ - if (!nodeConnectionInfo) { - return; - } - copyToClipboard(nodeConnectionInfo.pubkey); - }} - > -
Node
-
- {nodeConnectionInfo?.pubkey || "Loading..."} -
- {nodeConnectionInfo && ( - - )} + + + + + + + +
{ + if (!nodeConnectionInfo) { + return; + } + copyToClipboard(nodeConnectionInfo.pubkey); + }} + > +
Node
+
+ {nodeConnectionInfo?.pubkey || "Loading..."}
- - - - - - - Deposit Bitcoin - - - {(balances?.onchain.spendable || 0) > ONCHAIN_DUST_SATS && ( - - Withdraw Savings Balance - {redeemOnchainFunds.isLoading && } - - )} - + {nodeConnectionInfo && ( + + )} +
+
+
+ - - Management - - - Connected Peers - - - - - Sign Message - + + + Deposit Bitcoin + + + {(balances?.onchain.spendable || 0) > ONCHAIN_DUST_SATS && ( + + Withdraw Savings Balance + {redeemOnchainFunds.isLoading && } - - - 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 - - -
- + )} + + + + Management + + + Connected Peers + + + + + Sign Message + + + + + diff --git a/frontend/src/screens/settings/DebugTools.tsx b/frontend/src/screens/settings/DebugTools.tsx index d44ebc34..8458b882 100644 --- a/frontend/src/screens/settings/DebugTools.tsx +++ b/frontend/src/screens/settings/DebugTools.tsx @@ -1,4 +1,9 @@ import { useState } from "react"; +import { ResetRoutingDataDialogContent } from "src/components/ResetRoutingDataDialogContent"; +import { + AlertDialog, + AlertDialogTrigger, +} from "src/components/ui/alert-dialog"; import { Button } from "src/components/ui/button"; import { Textarea } from "src/components/ui/textarea"; @@ -118,6 +123,12 @@ export default function DebugTools() { > Get Network Graph + + + + + +
{apiResponse && (