diff --git a/ui/api/Rebalance/actions.ts b/ui/api/Rebalance/actions.ts index 92a22637f..19e56f866 100644 --- a/ui/api/Rebalance/actions.ts +++ b/ui/api/Rebalance/actions.ts @@ -1,5 +1,7 @@ import { logger } from "@/utils/logger"; import { + RebalanceOptimizationProposalResponse, + RebalanceOptimizationProposalSchema, RebalanceResponse, RebalanceResponseSchema, RebalanceSchema, @@ -25,7 +27,8 @@ export async function getRebalancesList( ): Promise { const sp = new URLSearchParams( filterUndefinedFromObj({ - "fields[kafkaRebalances]": "name,namespace,creationTimestamp,status", + "fields[kafkaRebalances]": + "name,namespace,creationTimestamp,status,mode,brokers", "filter[name]": params.name ? `like,*${params.name}*` : undefined, "filter[status]": params.status && params.status.length > 0 @@ -57,7 +60,7 @@ export async function getRebalancesList( export async function getRebalanceDetails( kafkaId: string, rebalanceId: string, -): Promise { +): Promise { const url = `${process.env.BACKEND_URL}/api/kafkas/${kafkaId}/rebalances/${rebalanceId}`; const body = { data: { @@ -73,7 +76,6 @@ export async function getRebalanceDetails( body: JSON.stringify(body), }); const rawData = await res.json(); - console.log(rawData); log.debug({ url, rawData }, "get Optimal proposal response"); - return RebalanceSchema.parse(rawData); + return RebalanceOptimizationProposalSchema.parse(rawData).data; } diff --git a/ui/api/Rebalance/schema.ts b/ui/api/Rebalance/schema.ts index 614158c2b..82cf421d8 100644 --- a/ui/api/Rebalance/schema.ts +++ b/ui/api/Rebalance/schema.ts @@ -30,8 +30,8 @@ const OptimizationResultSchema = z.object({ }); export const RebalanceSchema = z.object({ - type: z.literal("kafkaRebalances"), id: z.string(), + type: z.literal("kafkaRebalances"), meta: z .object({ autoApproval: z.boolean().optional(), @@ -39,12 +39,12 @@ export const RebalanceSchema = z.object({ }) .optional(), attributes: z.object({ - name: z.string().optional(), - namespace: z.string().optional(), - creationTimestamp: z.string().optional(), + name: z.string(), + namespace: z.string(), + creationTimestamp: z.string(), status: RebalanceStatusSchema, mode: z.string().optional(), - brokers: z.array(z.number()).optional(), + brokers: z.array(z.number()).nullable(), sessionId: z.string().optional(), optimizationResult: OptimizationResultSchema, }), @@ -57,6 +57,7 @@ const RebalancesListSchema = z.object({ page: z.object({ cursor: z.string(), }), + autoApproval: z.boolean(), managed: z.boolean().optional(), }), attributes: RebalanceSchema.shape.attributes.pick({ @@ -66,7 +67,6 @@ const RebalancesListSchema = z.object({ mode: true, brokers: true, }), - autoApproval: RebalanceSchema.shape.meta.unwrap().shape.autoApproval, }); export const RebalanceResponseSchema = z.object({ @@ -90,3 +90,11 @@ export type RebalancesResponse = z.infer; export type RebalanceResponse = z.infer; export type RebalanceStatus = z.infer; + +export const RebalanceOptimizationProposalSchema = z.object({ + data: RebalanceSchema, +}); + +export type RebalanceOptimizationProposalResponse = z.infer< + typeof RebalanceSchema +>; diff --git a/ui/app/[locale]/(authorized)/kafka/[kafkaId]/nodes/page.tsx b/ui/app/[locale]/(authorized)/kafka/[kafkaId]/nodes/page.tsx index 9cdd0519f..3efca94d2 100644 --- a/ui/app/[locale]/(authorized)/kafka/[kafkaId]/nodes/page.tsx +++ b/ui/app/[locale]/(authorized)/kafka/[kafkaId]/nodes/page.tsx @@ -28,6 +28,7 @@ export default function NodesPage({ params }: { params: KafkaParams }) { async function ConnectedNodes({ params }: { params: KafkaParams }) { const t = await getTranslations(); const res = await getKafkaClusterKpis(params.kafkaId); + let { cluster, kpis } = res || {}; const nodes: Node[] = (cluster?.attributes.nodes || []).map((node) => { diff --git a/ui/app/[locale]/(authorized)/kafka/[kafkaId]/nodes/rebalances/ConnectedRebalancesTable.tsx b/ui/app/[locale]/(authorized)/kafka/[kafkaId]/nodes/rebalances/ConnectedRebalancesTable.tsx index abcf1927c..08567e0b9 100644 --- a/ui/app/[locale]/(authorized)/kafka/[kafkaId]/nodes/rebalances/ConnectedRebalancesTable.tsx +++ b/ui/app/[locale]/(authorized)/kafka/[kafkaId]/nodes/rebalances/ConnectedRebalancesTable.tsx @@ -1,6 +1,6 @@ "use client"; -import { useRouter } from "@/navigation"; import { useFilterParams } from "@/utils/useFilterParams"; +import { useRouter } from "@/i18n/routing"; import { useOptimistic, useState, useTransition } from "react"; import { RebalanceTable, diff --git a/ui/app/[locale]/(authorized)/kafka/[kafkaId]/nodes/rebalances/RebalanceTable.tsx b/ui/app/[locale]/(authorized)/kafka/[kafkaId]/nodes/rebalances/RebalanceTable.tsx index 4e4f696c7..b9795fba3 100644 --- a/ui/app/[locale]/(authorized)/kafka/[kafkaId]/nodes/rebalances/RebalanceTable.tsx +++ b/ui/app/[locale]/(authorized)/kafka/[kafkaId]/nodes/rebalances/RebalanceTable.tsx @@ -19,7 +19,7 @@ import { ResourcesFullIcon, } from "@/libs/patternfly/react-icons"; import { ReactNode } from "react"; -import { Link } from "@/navigation"; +import Link from "next/link"; export const RebalanceTableColumns = ["name", "status", "createdAt"] as const; @@ -128,7 +128,6 @@ export function RebalanceTable({ onPageChange, }: RebalanceTabelProps) { const t = useTranslations("Rebalancing"); - return ( - {row.autoApproval} + {row.meta.autoApproval === true ? "true" : "false"}