Repository navigation
refactor: change KubernetesDashboardPage to use click-ui badges #3363
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
Changes from all commits
6374b4f
e027ff7
29b47f9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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. |
| 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, | ||
|
|
@@ -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" /> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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" /> | ||
| ) | ||
| } | ||
| /> | ||
|
|
||
| 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 { | ||
|
|
@@ -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'; | ||
|
|
@@ -152,13 +153,10 @@ const renderKubeEvent = (source: TLogSource) => (event: KubeEvent) => { | |
| </Text> | ||
| {event['object.type'] && ( | ||
| <Badge | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ( 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
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! |
||
| )} | ||
| </Group> | ||
| <Text size="xs">{event['object.note'] || event['object.message']}</Text> | ||
|
|
@@ -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" />; | ||
| } | ||
| }; | ||
| 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); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The replacement
BadgeusesNot Ready, but the repository requires sentence case for static user-facing text. Change it toNot readyhere 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!