-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add disconnect peer dialog (#434)
* feat(lnd): add disconnect peer * chore: add disconnect peer dialog * fix: add break-all to toast text * chore: render dialog component outside table * chore: remove check for node id * chore: minor changes * fix: usage of break all * chore: rename * chore: undo break-all change on the toast component * chore: fix naming * fix: word wrap on toast content * fix: disconnect peer toasts * chore: rename dialog content components * chore: minor copy improvements --------- Co-authored-by: Roland Bewick <[email protected]>
- Loading branch information
1 parent
d9a01d9
commit acd95ff
Showing
7 changed files
with
127 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { toast } from "src/components/ui/use-toast"; | ||
import { usePeers } from "src/hooks/usePeers"; | ||
import { Peer } from "src/types"; | ||
import { request } from "src/utils/request"; | ||
import { | ||
AlertDialogAction, | ||
AlertDialogCancel, | ||
AlertDialogContent, | ||
AlertDialogDescription, | ||
AlertDialogFooter, | ||
AlertDialogHeader, | ||
AlertDialogTitle, | ||
} from "./ui/alert-dialog"; | ||
|
||
type Props = { | ||
peer: Peer; | ||
name: string | undefined; | ||
}; | ||
|
||
export function DisconnectPeerDialogContent({ peer, name }: Props) { | ||
const { mutate: reloadPeers } = usePeers(); | ||
|
||
async function disconnectPeer() { | ||
try { | ||
console.info(`Disconnecting from ${peer.nodeId}`); | ||
|
||
await request(`/api/peers/${peer.nodeId}`, { | ||
method: "DELETE", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
}); | ||
toast({ | ||
title: "Successfully disconnected from peer", | ||
description: peer.nodeId, | ||
}); | ||
await reloadPeers(); | ||
} catch (e) { | ||
toast({ | ||
variant: "destructive", | ||
title: "Failed to disconnect peer", | ||
description: "" + e, | ||
}); | ||
console.error(e); | ||
} | ||
} | ||
|
||
return ( | ||
<AlertDialogContent> | ||
<AlertDialogHeader> | ||
<AlertDialogTitle>Disconnect Peer</AlertDialogTitle> | ||
<AlertDialogDescription> | ||
<div> | ||
<p> | ||
Are you sure you wish to disconnect from {name || "this peer"}? | ||
</p> | ||
<p className="text-primary font-medium mt-4">Peer Pubkey</p> | ||
<p className="break-all">{peer.nodeId}</p> | ||
</div> | ||
</AlertDialogDescription> | ||
</AlertDialogHeader> | ||
<AlertDialogFooter> | ||
<AlertDialogCancel>Cancel</AlertDialogCancel> | ||
<AlertDialogAction onClick={disconnectPeer}>Confirm</AlertDialogAction> | ||
</AlertDialogFooter> | ||
</AlertDialogContent> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters