added uid for identification (#620)

This commit is contained in:
DONY BENNY
2025-11-15 22:58:12 +05:30
committed by GitHub
parent b23310cb2d
commit 1d8151d41d
2 changed files with 34 additions and 31 deletions

View File

@@ -1,41 +1,45 @@
import { HD_RESOURCE_CONDITION_TYPE } from "../../API/releases";
import { Tooltip } from "flowbite-react";
import { ReleaseHealthStatus } from "../../data/types";
import { v4 as uuidv4 } from "uuid";
interface Props {
statusData: ReleaseHealthStatus[];
}
const HealthStatus = ({ statusData }: Props) => {
const statuses = statusData.map((item) => {
for (let i = 0; i < item.status.conditions.length; i++) {
const cond = item.status.conditions[i];
const statuses = statusData.flatMap((item) => {
return item.status?.conditions
?.filter((cond) => cond.type === HD_RESOURCE_CONDITION_TYPE)
.map((cond) => {
const stableKey =
item.metadata?.uid
? `${item.metadata.uid}-${item.metadata.namespace ?? "default"}`
: `${item.kind}-${item.metadata?.namespace ?? "default"}-${item.metadata?.name}`;
if (cond.type !== HD_RESOURCE_CONDITION_TYPE) {
continue;
}
return (
<Tooltip
key={uuidv4()} // this is not a good practice, we need to fetch some unique id from the backend
content={`${cond.status} ${item.kind} ${item.metadata.name}`}
>
<span
className={`inline-block ${
cond.status === "Healthy"
? "bg-success"
: cond.status === "Progressing"
? "bg-warning"
: "bg-danger"
} w-2.5 h-2.5 rounded-sm`}
></span>
</Tooltip>
);
}
return (
<Tooltip
key={stableKey}
content={`${cond.status} ${item.kind} ${item.metadata?.name}`}
>
<span
className={`inline-block ${
cond.status === "Healthy"
? "bg-success"
: cond.status === "Progressing"
? "bg-warning"
: "bg-danger"
} w-2.5 h-2.5 rounded-sm`}
></span>
</Tooltip>
);
});
});
if (statuses.length === 0) {
return <div>No health statuses available</div>;
}
return <div className="flex flex-wrap gap-1">{statuses}</div>;
};
export default HealthStatus;
export default HealthStatus;

View File

@@ -53,10 +53,9 @@ export type ReleaseHealthStatus = {
metadata: {
name: string;
namespace: string;
creationTimestamp?: string;
labels: {
[key: string]: string;
};
uid?: string; // added: Kubernetes UID for stable identification
creationTimestamp: Date;
labels: string[];
};
spec: unknown;
status: {