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

UX enhancement in Rebalance Page #1373

Merged
merged 3 commits into from
Jan 16, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,18 @@ import {
DescriptionListTerm,
DescriptionListDescription,
Badge,
Popover,
List,
ListItem,
Tooltip,
} from "@/libs/patternfly/react-core";
import {
CheckIcon,
ExclamationCircleIcon,
PauseCircleIcon,
PendingIcon,
OutlinedClockIcon,
HelpIcon,
} from "@/libs/patternfly/react-icons";
import Link from "next/link";
import React, { ReactNode } from "react";
Expand All @@ -34,80 +39,96 @@ export type RebalanceTableColumn = (typeof RebalanceTableColumns)[number];

const StatusLabel: Record<RebalanceStatus, ReactNode> = {
New: (
<>
<Icon>
<ExclamationCircleIcon />
</Icon>
&nbsp; New
</>
<Tooltip content="New rebalance initiated">
<span>
<Icon>
<ExclamationCircleIcon />
</Icon>
&nbsp; New
</span>
</Tooltip>
),
PendingProposal: (
<>
<Icon>
<PendingIcon />
</Icon>
&nbsp;PendingProposal
</>
<Tooltip content="Optimization proposal not generated">
<span>
<Icon>
<PendingIcon />
</Icon>
&nbsp;PendingProposal
</span>
</Tooltip>
),
ProposalReady: (
<>
<Icon>
<CheckIcon />
</Icon>
&nbsp;ProposalReady
</>
<Tooltip content="Optimization proposal is ready for approval">
<span>
<Icon>
<CheckIcon />
</Icon>
&nbsp;ProposalReady
</span>
</Tooltip>
),
Stopped: (
<>
<Icon>
<Image
src={"/stop-icon.svg"}
alt="stop icon"
width={100}
height={100}
/>
</Icon>
&nbsp;Stopped
</>
<Tooltip content="Rebalance stopped">
<span>
<Icon>
<Image
src={"/stop-icon.svg"}
alt="stop icon"
width={100}
height={100}
/>
</Icon>
&nbsp;Stopped
</span>
</Tooltip>
),
Rebalancing: (
<>
<Icon>
<PendingIcon />
</Icon>
&nbsp;Rebalancing
</>
<Tooltip content="Rebalance in progress">
<span>
<Icon>
<PendingIcon />
</Icon>
&nbsp;Rebalancing
</span>
</Tooltip>
),
NotReady: (
<>
<Icon>
<OutlinedClockIcon />
</Icon>
&nbsp;NotReady
</>
<Tooltip content="Error occurred with the rebalance">
<span>
<Icon>
<OutlinedClockIcon />
</Icon>
&nbsp;NotReady
</span>
</Tooltip>
),
Ready: (
<>
<Icon>
<CheckIcon />
</Icon>
&nbsp;Ready
</>
<Tooltip content="Rebalance complete">
<span>
<Icon>
<CheckIcon />
</Icon>
&nbsp;Ready
</span>
</Tooltip>
),
ReconciliationPaused: (
<>
<Icon>
<PauseCircleIcon />
</Icon>
&nbsp;ReconciliationPaused
</>
<Tooltip content="Rebalance is paused">
<span>
<Icon>
<PauseCircleIcon />
</Icon>
&nbsp;ReconciliationPaused
</span>
</Tooltip>
),
};

const ModeLabel: Record<RebalanceMode, ReactNode> = {
full: <>full</>,
"add-brokers": <>add-brokers</>,
"remove-brokers": <>remove-brokers</>,
full: <>Full</>,
"add-brokers": <>Add</>,
"remove-brokers": <>Remove</>,
};

export type RebalanceTabelProps = {
Expand Down Expand Up @@ -192,7 +213,7 @@ export function RebalanceTable({
case "name":
return (
<Td key={key} dataLabel={"Rebalance Name"} width={10}>
<Link href={`${baseurl}/${row.id}`}>
<Link href={`${baseurl}/rebalances/${row.id}`}>
<Badge key={key}>{t("cr_badge")}</Badge> {row.attributes.name}
</Link>
</Td>
Expand Down Expand Up @@ -239,21 +260,13 @@ export function RebalanceTable({
}
getExpandedRow={({ row }) => {
return (
<DescriptionList>
<DescriptionList className="pf-v5-u-mb-lg">
<Flex justifyContent={{ default: "justifyContentSpaceEvenly" }}>
<FlexItem
style={{
width: "15%",
width: "25%",
}}
>
<DescriptionListGroup>
<DescriptionListTerm>{t("mode")}</DescriptionListTerm>
<DescriptionListDescription>
{ModeLabel[row.attributes.mode]}
</DescriptionListDescription>
</DescriptionListGroup>
</FlexItem>
<FlexItem style={{ width: "25%", paddingLeft: "5rem" }}>
<DescriptionListGroup>
<DescriptionListTerm>
{t("auto_approval_enabled")}
Expand All @@ -263,14 +276,58 @@ export function RebalanceTable({
</DescriptionListDescription>
</DescriptionListGroup>
</FlexItem>
<FlexItem style={{ width: "27%", paddingRight: "5rem" }}>
<FlexItem style={{ width: "50%", paddingRight: "5rem" }}>
<DescriptionListGroup>
<DescriptionListTerm>{t("brokers")}</DescriptionListTerm>
<DescriptionListTerm>
{t("mode")}
{" "}
<Popover
aria-label={t("mode")}
headerContent={<div>{t("rebalance_mode")}</div>}
bodyContent={
<div>
<List>
<ListItem>
{t.rich("full_mode")}&nbsp;
{t("full_mode_description")}
</ListItem>
<ListItem>
{t.rich("add_brokers_mode")}
&nbsp;
{t("add_brokers_mode_description")}
</ListItem>
<ListItem>
{t.rich("remove_brokers_mode")}
&nbsp;
{t("remove_brokers_mode_description")}
</ListItem>
</List>
</div>
}
>
<HelpIcon />
</Popover>
</DescriptionListTerm>
<DescriptionListDescription>
{!row.attributes.brokers ||
row.attributes.brokers.length === 0
? "N/A"
: row.attributes.brokers.join(",")}
{row.attributes.mode === "full" ? (
ModeLabel[row.attributes.mode]
) : (
<>
{ModeLabel[row.attributes.mode]}{" "}
{row.attributes.brokers?.length
? row.attributes.brokers.map((b, index) => (
<>
<Link href={`${baseurl}/${b}`}>
{t("broker", { b })}
</Link>
{index <
(row.attributes.brokers?.length || 0) - 1 &&
", "}
</>
))
: ""}
</>
)}
</DescriptionListDescription>
</DescriptionListGroup>
</FlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ export default function RebalancesPage({
};
}) {
const name = searchParams["name"];
const mode = (searchParams["mode"] || "")
.split(",")
.filter((v) => !!v) as RebalanceMode[] | undefined;;
const mode = (searchParams["mode"] || "").split(",").filter((v) => !!v) as
| RebalanceMode[]
| undefined;
const pageSize = stringToInt(searchParams.perPage) || 20;
const sort = (searchParams["sort"] || "name") as RebalanceTableColumn;
const sortDir = (searchParams["sortDir"] || "asc") as "asc" | "desc";
Expand All @@ -69,7 +69,9 @@ export default function RebalancesPage({
nextPageCursor={undefined}
prevPageCursor={undefined}
mode={mode}
baseurl={`/kafka/${params.kafkaId}/nodes`} kafkaId={params.kafkaId} />
baseurl={`/kafka/${params.kafkaId}/nodes`}
kafkaId={params.kafkaId}
/>
}
>
<AsyncReabalanceTable
Expand Down Expand Up @@ -103,7 +105,7 @@ async function AsyncReabalanceTable({
pageSize: number;
pageCursor: string | undefined;
status: RebalanceStatus[] | undefined;
mode: RebalanceMode[] | undefined;
mode: RebalanceMode[] | undefined;
} & KafkaParams) {
const response = await getRebalancesList(kafkaId, {
name,
Expand Down Expand Up @@ -136,7 +138,7 @@ async function AsyncReabalanceTable({
sort={sort}
sortDir={sortDir}
status={status}
baseurl={`/kafka/${kafkaId}/nodes/rebalances`}
baseurl={`/kafka/${kafkaId}/nodes`}
page={rebalance.meta.page.pageNumber || 1}
nextPageCursor={nextPageCursor}
prevPageCursor={prevPageCursor}
Expand Down
11 changes: 9 additions & 2 deletions ui/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -585,10 +585,17 @@
"close": "Close",
"mode": "Mode",
"auto_approval_enabled": "Auto-approval enabled",
"brokers": "Brokers",
"rebalance_mode": "Rebalance mode",
"cr_badge": "CR",
"approved_alert": "KafkaRebalance approved!",
"stopped_alert": "KafkaRebalance has stopped!",
"refresh_alert": "KafkaRebalance has been refreshed!"
"refresh_alert": "KafkaRebalance has been refreshed!",
"full_mode": "<b>Full mode:</b>",
"full_mode_description": "Moves replicas across all brokers. This is the default mode",
"add_brokers_mode_description": "Moves replicas to newly added brokers. Brokers must be specified",
"add_brokers_mode": "<b>Add-brokers mode:</b>",
"remove_brokers_mode": "<b>Remove-brokers mode:</b>",
"remove_brokers_mode_description": "Moves replicas off brokers to be removed. Brokers must be specified",
"broker": "broker {b}"
}
}
Loading