From 121976d101bfa476d6b2da770034b7b6fc0726df Mon Sep 17 00:00:00 2001 From: Eduard Gert Date: Fri, 15 Mar 2024 13:46:27 +0100 Subject: [PATCH] Add option to copy peer details (ip, public ip, hostname, domain name) in detailed peer view (#356) --- src/app/(dashboard)/peer/page.tsx | 46 +++++++++++++++++++------------ src/components/Card.tsx | 9 ++++-- 2 files changed, 35 insertions(+), 20 deletions(-) diff --git a/src/app/(dashboard)/peer/page.tsx b/src/app/(dashboard)/peer/page.tsx index 3863e7c..6119891 100644 --- a/src/app/(dashboard)/peer/page.tsx +++ b/src/app/(dashboard)/peer/page.tsx @@ -306,6 +306,8 @@ function PeerInformationCard({ peer }: { peer: Peer }) { @@ -316,6 +318,8 @@ function PeerInformationCard({ peer }: { peer: Peer }) { /> @@ -325,6 +329,30 @@ function PeerInformationCard({ peer }: { peer: Peer }) { value={peer.connection_ip} /> + + + Domain Name + + } + value={peer.dns_label} + /> + + + + Hostname + + } + value={peer.hostname} + /> + @@ -353,24 +381,6 @@ function PeerInformationCard({ peer }: { peer: Peer }) { } /> - - - Domain Name - - } - value={peer.dns_label} - /> - - - Hostname - - } - value={peer.hostname} - /> diff --git a/src/components/Card.tsx b/src/components/Card.tsx index 6de46e6..9decc8b 100644 --- a/src/components/Card.tsx +++ b/src/components/Card.tsx @@ -30,6 +30,7 @@ type CardListItemProps = { value: React.ReactNode; className?: string; copy?: boolean; + copyText?: string; tooltip?: boolean; }; @@ -38,6 +39,7 @@ function CardListItem({ value, className, copy = false, + copyText, tooltip = true, }: CardListItemProps) { const [, copyToClipBoard] = useCopyToClipboard(value as string); @@ -56,7 +58,10 @@ function CardListItem({ copy && "cursor-pointer hover:text-nb-gray-300 transition-all", )} onClick={() => - copy && copyToClipBoard(`${label} has been copied to clipboard.`) + copy && + copyToClipBoard( + `${copyText ? copyText : label} has been copied to clipboard.`, + ) } > {tooltip ? ( @@ -64,7 +69,7 @@ function CardListItem({ ) : ( value )} - {copy && } + {copy && } );