From c64d77c2ce2662f7e3aa80dcf5b04d749dff7610 Mon Sep 17 00:00:00 2001 From: Amogh Bharadwaj Date: Mon, 18 Mar 2024 23:33:40 +0530 Subject: [PATCH] UI: Redirect to peers page by default, add buttons there (#1498) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now users do not land on the Home page. The landing route is the peers page (`/peers`), where if there are no peers, the below look holds: Screenshot 2024-03-18 at 10 09 31 PM --- ui/app/peers/page.tsx | 68 +++++++++++++++++++++++++++++++++---- ui/app/peers/peersTable.tsx | 3 +- ui/next.config.js | 9 +++++ 3 files changed, 71 insertions(+), 9 deletions(-) diff --git a/ui/app/peers/page.tsx b/ui/app/peers/page.tsx index d7812e54c0..48394acde7 100644 --- a/ui/app/peers/page.tsx +++ b/ui/app/peers/page.tsx @@ -15,7 +15,8 @@ import useSWR from 'swr'; import { fetcher } from '../utils/swr'; export default function Peers() { - const { data: peers, error, isLoading } = useSWR('/api/peers', fetcher); + const peers: any[] = []; + const { data, error, isLoading } = useSWR('/api/peers', fetcher); return ( @@ -39,6 +40,10 @@ export default function Peers() { > Peers + {isLoading && ( @@ -46,12 +51,61 @@ export default function Peers() { )} - {!isLoading && ( - peer)} - /> - )} + {!isLoading && + (peers && peers.length == 0 ? ( +
+ + + +
+ ) : ( + peer)} /> + ))}
); diff --git a/ui/app/peers/peersTable.tsx b/ui/app/peers/peersTable.tsx index a49cbd2e53..a592d232f3 100644 --- a/ui/app/peers/peersTable.tsx +++ b/ui/app/peers/peersTable.tsx @@ -33,7 +33,7 @@ function PeerRow({ peer }: { peer: Peer }) { ); } -function PeersTable({ title, peers }: { title: string; peers: Peer[] }) { +function PeersTable({ peers }: { peers: Peer[] }) { const [searchQuery, setSearchQuery] = useState(''); const [filteredType, setFilteredType] = useState( undefined @@ -65,7 +65,6 @@ function PeersTable({ title, peers }: { title: string; peers: Peer[] }) { return ( {title}} toolbar={{ left: <>, right: ( diff --git a/ui/next.config.js b/ui/next.config.js index a42a10c727..5212d4780c 100644 --- a/ui/next.config.js +++ b/ui/next.config.js @@ -3,6 +3,15 @@ const nextConfig = { compiler: { styledComponents: true, }, + async redirects() { + return [ + { + source: '/', + destination: '/peers', + permanent: false, + }, + ]; + }, reactStrictMode: true, swcMinify: true, output: 'standalone',