Skip to content
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
6 changes: 6 additions & 0 deletions .changeset/kubernetes-badges-click-ui.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@hyperdx/app': patch
---

feat: use the click-ui `Badge` for all status badges on the Kubernetes dashboard
and its node, namespace, and pod drawers.
42 changes: 5 additions & 37 deletions packages/app/src/KubernetesDashboardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import cx from 'classnames';
import sub from 'date-fns/sub';
import { useQueryState } from 'nuqs';
import { useForm, useWatch } from 'react-hook-form';
import { Badge } from '@clickhouse/click-ui';
import { convertDateRangeToGranularityString } from '@hyperdx/common-utils/dist/core/utils';
import {
isLogSource,
Expand All @@ -20,7 +21,6 @@ import {
ActionIcon,
Alert,
Anchor,
Badge,
Breadcrumbs,
Card,
Flex,
Expand Down Expand Up @@ -688,25 +688,9 @@ const NodesTable = ({
<Table.Td>{node.name || 'N/A'}</Table.Td>
<Table.Td>
{node.ready === 1 ? (
<Badge
variant="light"
color="green"
fw="normal"
tt="none"
size="md"
>
Ready
</Badge>
<Badge text="Ready" state="success" />
) : (
<Badge
variant="light"
color="red"
fw="normal"
tt="none"
size="md"
>
Not Ready
</Badge>
<Badge text="Not Ready" state="danger" />

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Status labels break sentence case

The replacement Badge uses Not Ready, but the repository requires sentence case for static user-facing text. Change it to Not ready here and in the node and namespace drawers. This repository requirement must be satisfied before merging.

Context Used: AGENTS.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code Fix in Conductor Fix in Cursor Fix in Codex

)}
</Table.Td>
<Table.Td>
Expand Down Expand Up @@ -886,25 +870,9 @@ const NamespacesTable = ({
<Table.Td>{namespace.name || 'N/A'}</Table.Td>
<Table.Td>
{namespace.phase === 1 ? (
<Badge
variant="light"
color="green"
fw="normal"
tt="none"
size="md"
>
Ready
</Badge>
<Badge text="Ready" state="success" />
) : (
<Badge
variant="light"
color="red"
fw="normal"
tt="none"
size="md"
>
Terminating
</Badge>
<Badge text="Terminating" state="danger" />
)}
</Table.Td>
<Table.Td>
Expand Down
22 changes: 3 additions & 19 deletions packages/app/src/NamespaceDetailsSidePanel.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as React from 'react';
import { parseAsString, useQueryState } from 'nuqs';
import { Badge } from '@clickhouse/click-ui';
import { tcFromSource } from '@hyperdx/common-utils/dist/core/metadata';
import { convertDateRangeToGranularityString } from '@hyperdx/common-utils/dist/core/utils';
import { TLogSource, TMetricSource } from '@hyperdx/common-utils/dist/types';
import {
Badge,
Card,
Drawer,
Flex,
Expand Down Expand Up @@ -103,25 +103,9 @@ const NamespaceDetails = ({
label="Status"
value={
properties.ready === 1 ? (
<Badge
variant="light"
color="green"
fw="normal"
tt="none"
size="md"
>
Ready
</Badge>
<Badge text="Ready" state="success" />
) : (
<Badge
variant="light"
color="red"
fw="normal"
tt="none"
size="md"
>
Not Ready
</Badge>
<Badge text="Not Ready" state="danger" />
)
}
/>
Expand Down
22 changes: 3 additions & 19 deletions packages/app/src/NodeDetailsSidePanel.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as React from 'react';
import { parseAsString, useQueryState } from 'nuqs';
import { Badge } from '@clickhouse/click-ui';
import { tcFromSource } from '@hyperdx/common-utils/dist/core/metadata';
import { convertDateRangeToGranularityString } from '@hyperdx/common-utils/dist/core/utils';
import { TLogSource, TMetricSource } from '@hyperdx/common-utils/dist/types';
import {
Badge,
Card,
Drawer,
Flex,
Expand Down Expand Up @@ -110,25 +110,9 @@ const NodeDetails = ({
label="Status"
value={
properties.ready === 1 ? (
<Badge
variant="light"
color="green"
fw="normal"
tt="none"
size="md"
>
Ready
</Badge>
<Badge text="Ready" state="success" />

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — Ready/Not Ready badge pair is hand-copied at four call sites

Add a FormatReadyStatus({ ready, notReadyLabel }) next to FormatPodStatus in components/KubeComponents.tsx. Use it here, in NamespaceDetailsSidePanel.tsx:106, and at KubernetesDashboardPage.tsx:691/873. That gives the state mapping one source of truth and one test, the same way FormatPodStatus does.

Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond

) : (
<Badge
variant="light"
color="red"
fw="normal"
tt="none"
size="md"
>
Not Ready
</Badge>
<Badge text="Not Ready" state="danger" />
)
}
/>
Expand Down
50 changes: 12 additions & 38 deletions packages/app/src/components/KubeComponents.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import Link from 'next/link';
import { sub } from 'date-fns';
import { Badge } from '@clickhouse/click-ui';
import type { ResponseJSON } from '@hyperdx/common-utils/dist/clickhouse';
import { renderChartConfig } from '@hyperdx/common-utils/dist/core/renderChartConfig';
import {
Expand All @@ -10,7 +11,7 @@ import {
SearchConditionLanguage,
TLogSource,
} from '@hyperdx/common-utils/dist/types';
import { Badge, Group, Text, Timeline } from '@mantine/core';
import { Group, Text, Timeline } from '@mantine/core';
import { useQuery, UseQueryOptions } from '@tanstack/react-query';

import { useClickhouseClient } from '@/clickhouse';
Expand Down Expand Up @@ -152,13 +153,10 @@ const renderKubeEvent = (source: TLogSource) => (event: KubeEvent) => {
</Text>
{event['object.type'] && (
<Badge

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — renderKubeEvent mixes the click-ui Badge with Mantine Group/Text/Timeline in one small render function

The base-branch Click UI convention says "Do not mix both libraries inside one small component". Either keep the Mantine Badge here, using semantic-token styling, or move the whole event row to click-ui (Container/Text).

Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond

variant="light"
size="xs"
fw="normal"
color={event['object.type'] === 'Normal' ? 'green' : 'yellow'}
>
{event['object.type']}
</Badge>
size="sm"
text={event['object.type']}
state={event['object.type'] === 'Normal' ? 'success' : 'warning'}
/>
Comment on lines 155 to +159

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Event row mixes UI libraries

renderKubeEvent now combines a click-ui Badge with Mantine Group and Text in the same small renderer. The repository guide says, “Do not: Mix both libraries inside one small component.” Move the event row into a small click-ui component so its text, badge, and spacing use one library. This repository requirement must be satisfied before merging.

Context Used: AGENTS.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code Fix in Conductor Fix in Cursor Fix in Codex

)}
</Group>
<Text size="xs">{event['object.note'] || event['object.message']}</Text>
Expand Down Expand Up @@ -322,40 +320,16 @@ export const KubeTimeline = ({
export const FormatPodStatus = ({ status }: { status?: number }) => {
switch (status) {
case KubePhase.Pending:
return (
<Badge variant="light" color="yellow" fw="normal" tt="none" size="md">
Pending
</Badge>
);
return <Badge text="Pending" state="warning" />;
case KubePhase.Running:
return (
<Badge variant="light" color="green" fw="normal" tt="none" size="md">
Running
</Badge>
);
return <Badge text="Running" state="success" />;
case KubePhase.Succeeded:
return (
<Badge variant="light" color="indigo" fw="normal" tt="none" size="md">
Succeeded
</Badge>
);
return <Badge text="Succeeded" state="info" />;
case KubePhase.Failed:
return (
<Badge variant="light" color="red" fw="normal" tt="none" size="md">
Failed
</Badge>
);
return <Badge text="Failed" state="danger" />;
case KubePhase.Unknown:
return (
<Badge variant="light" color="gray" fw="normal" tt="none" size="md">
Unknown
</Badge>
);
return <Badge text="Unknown" state="neutral" />;
default:
return (
<Badge variant="light" color="gray" fw="normal" tt="none" size="md">
Unknown
</Badge>
);
return <Badge text="Unknown" state="neutral" />;
}
};
32 changes: 32 additions & 0 deletions packages/app/src/components/__tests__/FormatPodStatus.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { screen } from '@testing-library/react';

import { FormatPodStatus } from '@/components/KubeComponents';
import { KubePhase } from '@/types';

// click-ui encodes state only in hashed CSS module class names, so the mock
// exposes the prop as an attribute to assert on.
jest.mock('@clickhouse/click-ui', () => ({
...jest.requireActual('@clickhouse/click-ui'),
Badge: ({ text, state }: { text: React.ReactNode; state?: string }) => (
<span data-testid="badge" data-state={state}>
{text}
</span>
),
}));

describe('FormatPodStatus', () => {
it.each([
[KubePhase.Pending, 'Pending', 'warning'],
[KubePhase.Running, 'Running', 'success'],
[KubePhase.Succeeded, 'Succeeded', 'info'],
[KubePhase.Failed, 'Failed', 'danger'],
[KubePhase.Unknown, 'Unknown', 'neutral'],
[undefined, 'Unknown', 'neutral'],
])('renders phase %s with the %s label', (status, label, badgeState) => {
renderWithMantine(<FormatPodStatus status={status} />);

const badge = screen.getByTestId('badge');
expect(badge).toHaveTextContent(label);
expect(badge).toHaveAttribute('data-state', badgeState);
});
});
Loading