From 2dd05d807e2482ed846f53335495980dae86aaa5 Mon Sep 17 00:00:00 2001 From: Riccardo Forina Date: Fri, 9 Aug 2024 11:35:51 +0200 Subject: [PATCH] Improved loading of the sidebar --- .../kafka/[kafkaId]/ClusterLinks.tsx | 57 +++++++++++-------- .../(authorized)/kafka/[kafkaId]/layout.tsx | 32 +---------- 2 files changed, 37 insertions(+), 52 deletions(-) diff --git a/ui/app/[locale]/(authorized)/kafka/[kafkaId]/ClusterLinks.tsx b/ui/app/[locale]/(authorized)/kafka/[kafkaId]/ClusterLinks.tsx index 9c49a3a12..00fb29196 100644 --- a/ui/app/[locale]/(authorized)/kafka/[kafkaId]/ClusterLinks.tsx +++ b/ui/app/[locale]/(authorized)/kafka/[kafkaId]/ClusterLinks.tsx @@ -2,33 +2,44 @@ import { getKafkaCluster } from "@/api/kafka/actions"; import { NavItemLink } from "@/components/Navigation/NavItemLink"; import { NavGroup, NavList } from "@/libs/patternfly/react-core"; import { useTranslations } from "next-intl"; +import { Suspense } from "react"; -export async function ClusterLinks({ kafkaId }: { kafkaId: string }) { +export function ClusterLinks({ kafkaId }: { kafkaId: string }) { const t = useTranslations(); - const cluster = await getKafkaCluster(kafkaId); - if (cluster) { - return ( - - - - {t("AppLayout.cluster_overview")} - - - {t("AppLayout.topics")} - - - {t("AppLayout.brokers")} - - {/* + return ( + + + + + ) as unknown as string + } + > + + {t("AppLayout.cluster_overview")} + + + {t("AppLayout.topics")} + + + {t("AppLayout.brokers")} + + {/* Service registry */} - - {t("AppLayout.consumer_groups")} - - - - ); - } + + {t("AppLayout.consumer_groups")} + + + + ); +} + +async function ClusterName({ kafkaId }: { kafkaId: string }) { + const cluster = await getKafkaCluster(kafkaId); + return cluster?.attributes.name ?? `Cluster ${kafkaId}`; } diff --git a/ui/app/[locale]/(authorized)/kafka/[kafkaId]/layout.tsx b/ui/app/[locale]/(authorized)/kafka/[kafkaId]/layout.tsx index 65bb9bb2d..e24d09999 100644 --- a/ui/app/[locale]/(authorized)/kafka/[kafkaId]/layout.tsx +++ b/ui/app/[locale]/(authorized)/kafka/[kafkaId]/layout.tsx @@ -1,20 +1,16 @@ -import { getKafkaCluster, getKafkaClusters } from "@/api/kafka/actions"; import { ClusterLinks } from "@/app/[locale]/(authorized)/kafka/[kafkaId]/ClusterLinks"; import { getAuthOptions } from "@/app/api/auth/[...nextauth]/route"; import { AppLayout } from "@/components/AppLayout"; import { AppLayoutProvider } from "@/components/AppLayoutProvider"; -import { getServerSession } from "next-auth"; -import { KafkaParams } from "./kafka.params"; -import { KafkaBreadcrumbItem } from "./KafkaBreadcrumbItem"; import { Breadcrumb, - BreadcrumbItem, PageBreadcrumb, PageGroup, } from "@/libs/patternfly/react-core"; +import { getServerSession } from "next-auth"; import { useTranslations } from "next-intl"; -import { notFound } from "next/navigation"; import { PropsWithChildren, ReactNode, Suspense } from "react"; +import { KafkaParams } from "./kafka.params"; export default async function AsyncLayout({ children, @@ -62,11 +58,7 @@ function Layout({ - - - } + sidebar={} > @@ -80,21 +72,3 @@ function Layout({ ); } - -async function ConnectedKafkaBreadcrumbItem({ - kafkaId, - isActive, -}: KafkaParams & { isActive: boolean }) { - const cluster = await getKafkaCluster(kafkaId); - if (!cluster) { - notFound(); - } - const clusters = await getKafkaClusters(); - return ( - - ); -}