Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Patternfly v6 #1191

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 22 additions & 19 deletions ui/app/[locale]/(authorized)/kafka/[kafkaId]/@header/nodes/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ import { getKafkaCluster } from "@/api/kafka/actions";
import { KafkaParams } from "@/app/[locale]/(authorized)/kafka/[kafkaId]/kafka.params";
import { AppHeader } from "@/components/AppHeader";
import { Number } from "@/components/Format/Number";
import { NavItemLink } from "@/components/Navigation/NavItemLink";
import { NavTabLink } from "@/components/Navigation/NavTabLink";
import {
Label,
Nav,
NavList,
PageNavigation,
PageSection,
Spinner,
Split,
SplitItem,
} from "@/libs/patternfly/react-core";
import { CheckCircleIcon } from "@/libs/patternfly/react-icons";
import { useTranslations } from "next-intl";
import { Suspense } from "react";

export default function NodesHeader({ params }: { params: KafkaParams }) {
Expand Down Expand Up @@ -45,11 +44,26 @@ function Header({
kafkaId: string | undefined;
cruiseControlEnable: boolean;
}) {
const t = useTranslations("node-header");

const tabs = [
{ key: 0, title: t("overveiw"), url: `/kafka/${kafkaId}/nodes` },
...(cruiseControlEnable
? [
{
key: 1,
title: t("rebalance"),
url: `/kafka/${kafkaId}/nodes/rebalances`,
},
]
: []),
];

return (
<AppHeader
title={
<Split hasGutter={true}>
<SplitItem>Brokers</SplitItem>
<SplitItem>{t("brokers")}</SplitItem>
<SplitItem>
<Label
color={"green"}
Expand All @@ -67,20 +81,9 @@ function Header({
</Split>
}
navigation={
<PageNavigation>
<Nav aria-label="Node navigation" variant="tertiary">
<NavList>
<NavItemLink url={`/kafka/${kafkaId}/nodes`} exact={true}>
Overview
</NavItemLink>
{cruiseControlEnable && (
<NavItemLink url={`/kafka/${kafkaId}/nodes/rebalances`}>
Rebalance
</NavItemLink>
)}
</NavList>
</Nav>
</PageNavigation>
<PageSection className={"pf-v6-u-px-sm"} type="subnav">
<NavTabLink tabs={tabs} />
</PageSection>
}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ import { getKafkaCluster } from "@/api/kafka/actions";
import { KafkaParams } from "@/app/[locale]/(authorized)/kafka/[kafkaId]/kafka.params";
import { AppHeader } from "@/components/AppHeader";
import { Number } from "@/components/Format/Number";
import { NavItemLink } from "@/components/Navigation/NavItemLink";
import { NavTabLink } from "@/components/Navigation/NavTabLink";
import {
Label,
Nav,
NavList,
PageNavigation,
PageSection,
Spinner,
Split,
SplitItem,
Expand Down Expand Up @@ -45,6 +43,19 @@ function Header({
kafkaId: string | undefined;
cruiseControlEnable: boolean;
}) {
const tabs = [
{ key: 0, title: "Overview", url: `/kafka/${kafkaId}/nodes` },
...(cruiseControlEnable
? [
{
key: 1,
title: "Rebalance",
url: `/kafka/${kafkaId}/nodes/rebalances`,
},
]
: []),
];

return (
<AppHeader
title={
Expand All @@ -67,20 +78,9 @@ function Header({
</Split>
}
navigation={
<PageNavigation>
<Nav aria-label="Node navigation" variant="tertiary">
<NavList>
<NavItemLink url={`/kafka/${kafkaId}/nodes`}>
Overview
</NavItemLink>
{cruiseControlEnable && (
<NavItemLink url={`/kafka/${kafkaId}/nodes/rebalances`}>
Rebalance
</NavItemLink>
)}
</NavList>
</Nav>
</PageNavigation>
<PageSection className="pf-v6-u-px-sm" type="subnav">
<NavTabLink tabs={tabs} />
</PageSection>
}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ import { KafkaTopicParams } from "@/app/[locale]/(authorized)/kafka/[kafkaId]/to
import { AppHeader } from "@/components/AppHeader";
import { Number } from "@/components/Format/Number";
import { ManagedTopicLabel } from "@/components/ManagedTopicLabel";
import { NavItemLink } from "@/components/Navigation/NavItemLink";
import { NavTabLink } from "@/components/Navigation/NavTabLink";
import {
Label,
Nav,
NavList,
PageNavigation,
PageSection,
Skeleton,
Spinner,
} from "@/libs/patternfly/react-core";
import { Skeleton } from "@patternfly/react-core";
import { useTranslations } from "next-intl";
import { notFound } from "next/navigation";
import { ReactNode, Suspense } from "react";

Expand All @@ -26,55 +25,62 @@ export function TopicHeader({
showRefresh,
}: TopicHeaderProps) {
const portal = <div key={"topic-header-portal"} id={"topic-header-portal"} />;
const t = useTranslations("topic-header");

const tabs = [
{
key: 0,
title: (
<>
{t("messages")}&nbsp;
<Label isCompact={true}>
<Spinner size="sm" />
</Label>
</>
),
url: `/kafka/${kafkaId}/topics/${topicId}/messages`,
},
{
key: 1,
title: (
<>
{t("partitions")}&nbsp;
<Label isCompact={true}>
<Spinner size="sm" />
</Label>
</>
),
url: `/kafka/${kafkaId}/topics/${topicId}/partitions`,
},
{
key: 2,
title: (
<>
{t("consumer_groups")}&nbsp;
<Label isCompact={true}>
<Spinner size="sm" />
</Label>
</>
),
url: `/kafka/${kafkaId}/topics/${topicId}/consumer-groups`,
},
{
key: 3,
title: t("configuration"),
url: `/kafka/${kafkaId}/topics/${topicId}/configuration`,
},
];

return (
<Suspense
fallback={
<AppHeader
title={<Skeleton width="35%" />}
showRefresh={showRefresh}
navigation={
<PageNavigation>
<Nav aria-label="Group section navigation" variant="tertiary">
<NavList>
<NavItemLink
url={`/kafka/${kafkaId}/topics/${topicId}/messages`}
>
Messages&nbsp;
<Label isCompact={true}>
<Spinner size="sm" />
</Label>
</NavItemLink>
<NavItemLink
url={`/kafka/${kafkaId}/topics/${topicId}/partitions`}
>
Partitions&nbsp;
<Label isCompact={true}>
<Spinner size="sm" />
</Label>
</NavItemLink>
<NavItemLink
url={`/kafka/${kafkaId}/topics/${topicId}/consumer-groups`}
>
Consumer groups&nbsp;
<Label isCompact={true}>
<Spinner size="sm" />
</Label>
</NavItemLink>
{/*
<NavItemLink
url={`/kafka/${kafkaId}/topics/${topicId}/schema-registry`}
>
Schema
</NavItemLink>
*/}
<NavItemLink
url={`/kafka/${kafkaId}/topics/${topicId}/configuration`}
>
Configuration
</NavItemLink>
</NavList>
</Nav>
</PageNavigation>
<PageSection className="pf-v6-u-px-sm" type="subnav">
<NavTabLink tabs={tabs} />
</PageSection>
}
actions={[portal]}
/>
Expand All @@ -98,11 +104,54 @@ async function ConnectedTopicHeader({
showRefresh?: boolean;
portal: ReactNode;
}) {
const t = useTranslations("topic-header");
const cluster = await getKafkaCluster(kafkaId);
if (!cluster) {
notFound();
}
const topic = await getTopic(cluster.id, topicId);

const tabs = [
{
key: 0,
title: t("messages"),
url: `/kafka/${kafkaId}/topics/${topicId}/messages`,
},
{
key: 1,
title: (
<>
{t("partitions")}&nbsp;
<Label isCompact={true}>
<Suspense fallback={<Spinner size="sm" />}>
<Number value={topic?.attributes.numPartitions} />
</Suspense>
</Label>
</>
),
url: `/kafka/${kafkaId}/topics/${topicId}/partitions`,
},
{
key: 2,
title: (
<>
{t("consumer_groups")}&nbsp;
<Label isCompact={true}>
<Number
value={topic?.relationships.consumerGroups?.data.length ?? 0}
/>
</Label>
</>
),
url: `/kafka/${kafkaId}/topics/${topicId}/consumer-groups`,
},
{
key: 3,
title: t("configuration"),
url: `/kafka/${kafkaId}/topics/${topicId}/configuration`,
},
];

return (
<AppHeader
title={
Expand All @@ -113,47 +162,9 @@ async function ConnectedTopicHeader({
}
showRefresh={showRefresh}
navigation={
<PageNavigation>
<Nav aria-label="Group section navigation" variant="tertiary">
<NavList>
<NavItemLink url={`/kafka/${kafkaId}/topics/${topicId}/messages`}>
Messages&nbsp;
</NavItemLink>
<NavItemLink
url={`/kafka/${kafkaId}/topics/${topicId}/partitions`}
>
Partitions&nbsp;
<Label isCompact={true}>
<Suspense fallback={<Spinner size="sm" />}>
<Number value={topic?.attributes.numPartitions} />
</Suspense>
</Label>
</NavItemLink>
<NavItemLink
url={`/kafka/${kafkaId}/topics/${topicId}/consumer-groups`}
>
Consumer groups&nbsp;
<Label isCompact={true}>
<Number
value={topic?.relationships.consumerGroups?.data.length ?? 0}
/>
</Label>
</NavItemLink>
{/*
<NavItemLink
url={`/kafka/${kafkaId}/topics/${topicId}/schema-registry`}
>
Schema
</NavItemLink>
*/}
<NavItemLink
url={`/kafka/${kafkaId}/topics/${topicId}/configuration`}
>
Configuration
</NavItemLink>
</NavList>
</Nav>
</PageNavigation>
<PageSection className="pf-v6-u-px-sm" type="subnav">
<NavTabLink tabs={tabs} />
</PageSection>
}
actions={[portal]}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function Header({
<CheckCircleIcon />
)
}
color={"cyan"}
color={"teal"}
>
{ok !== undefined && <Number value={ok} />}
</Label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ export function KafkaSwitcher<T extends string>({
onClick={onToggleClick}
isExpanded={isOpen}
variant={"plainText"}
className={"pf-v5-u-p-0"}
className={"pf-v6-u-p-0"}
style={
{
"--pf-v5-c-menu-toggle__toggle-icon--MarginRight": 0,
"--pf-v5-c-menu-toggle__controls--PaddingLeft":
"var(--pf-v5-global--spacer--sm)",
"--pf-v6-c-menu-toggle__toggle-icon--MarginRight": 0,
"--pf-v6-c-menu-toggle__controls--PaddingLeft":
"var(--pf-v6--global--spacer--sm)",
} as CSSProperties
}
>
Expand Down
Loading
Loading