-
Notifications
You must be signed in to change notification settings - Fork 426
feat(consumers): migrate consumer groups to UI Registry #2545
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
Open
jvorcak
wants to merge
13
commits into
master
Choose a base branch
from
UX-1371-move-consumer-groups-to-ui-registry
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
388bcd6
feat(consumers): migrate consumer groups to UI Registry
jvorcak 30ca302
fix(consumers): show human-readable labels in Edit modal selects
jvorcak bb3929a
fix(consumers): tidy Protocol stats for empty groups
jvorcak 05f9f28
fix(consumers): shrink stats-bar height on group detail
jvorcak 6a5bf6d
test(e2e): fix consumer-group tooltip selector after registry migration
jvorcak 8a616e3
test(e2e): resolve shadow backend URL from dynamic ports (enterprise)
jvorcak 06f67b7
refactor(consumers): extract DisabledReasonButton to shared ui
jvorcak 9fcb41a
fix(consumers): correct consumer-group list pagination layout
jvorcak 9398543
fix(consumers): move full-width utility to call site to avoid registr…
jvorcak bbfce35
chore(redpanda-ui): bump dialog + tabs to registry 2.3.0
jvorcak 42fd63a
fix(consumers): add tooltip role and simplify e2e assertions
jvorcak 5b0f131
Merge branch 'master' into UX-1371-move-consumer-groups-to-ui-registry
jvorcak 94c4594
fix(consumers): assert the actual disabled-reason text in e2e
jvorcak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
769 changes: 398 additions & 371 deletions
769
frontend/src/components/pages/consumers/group-details.tsx
Large diffs are not rendered by default.
Oops, something went wrong.
460 changes: 315 additions & 145 deletions
460
frontend/src/components/pages/consumers/group-list.tsx
Large diffs are not rendered by default.
Oops, something went wrong.
1,031 changes: 502 additions & 529 deletions
1,031
frontend/src/components/pages/consumers/modals.tsx
Large diffs are not rendered by default.
Oops, something went wrong.
87 changes: 87 additions & 0 deletions
87
frontend/src/components/ui/consumer-group/consumer-group-state-cell.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| /** | ||
| * Copyright 2026 Redpanda Data, Inc. | ||
| * | ||
| * Use of this software is governed by the Business Source License | ||
| * included in the file https://github.com/redpanda-data/redpanda/blob/dev/licenses/bsl.md | ||
| * | ||
| * As of the Change Date specified in that file, in accordance with | ||
| * the Business Source License, use of this software will be governed | ||
| * by the Apache License, Version 2.0 | ||
| */ | ||
|
|
||
| import { CheckCircleIcon, FlameIcon, HelpIcon, HourglassIcon, WarningIcon } from 'components/icons'; | ||
| import type { ReactNode } from 'react'; | ||
|
|
||
| import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../../redpanda-ui/components/tooltip'; | ||
|
|
||
| type StateIconKey = 'stable' | 'completingrebalance' | 'preparingrebalance' | 'empty' | 'dead' | 'unknown'; | ||
|
|
||
| const stateIcons: Record<StateIconKey, ReactNode> = { | ||
| stable: <CheckCircleIcon className="text-success" size={16} />, | ||
| completingrebalance: <HourglassIcon className="text-success" size={16} />, | ||
| preparingrebalance: <HourglassIcon className="text-warning" size={16} />, | ||
| empty: <WarningIcon className="text-warning" size={16} />, | ||
| dead: <FlameIcon className="text-destructive" size={16} />, | ||
| unknown: <HelpIcon size={16} />, | ||
| }; | ||
|
|
||
| export const consumerGroupStateNames: Record<StateIconKey, string> = { | ||
| stable: 'Stable', | ||
| completingrebalance: 'Completing Rebalance', | ||
| preparingrebalance: 'Preparing Rebalance', | ||
| empty: 'Empty', | ||
| dead: 'Dead', | ||
| unknown: 'Unknown', | ||
| }; | ||
|
|
||
| /** | ||
| * All possible consumer group states, used to populate the State faceted filter so every | ||
| * option is available even when no group is currently in that state. `value` is the raw | ||
| * state string returned by the backend (must match `GroupDescription.state` exactly). | ||
| */ | ||
| export const consumerGroupStateFilterOptions: { label: string; value: string }[] = [ | ||
| { label: 'Stable', value: 'Stable' }, | ||
| { label: 'Completing Rebalance', value: 'CompletingRebalance' }, | ||
| { label: 'Preparing Rebalance', value: 'PreparingRebalance' }, | ||
| { label: 'Empty', value: 'Empty' }, | ||
| { label: 'Dead', value: 'Dead' }, | ||
| { label: 'Unknown', value: 'Unknown' }, | ||
| ]; | ||
|
|
||
| const stateDescriptions: Record<StateIconKey, string> = { | ||
| stable: 'Consumer group has members which have been assigned partitions', | ||
| completingrebalance: 'Kafka is assigning partitions to group members', | ||
| preparingrebalance: 'A reassignment of partitions is required, members have been asked to stop consuming', | ||
| empty: 'Consumer group exists, but does not have any members', | ||
| dead: 'Consumer group does not have any members and its metadata has been removed', | ||
| unknown: 'Group state is not known', | ||
| }; | ||
|
|
||
| const normalizeStateKey = (state: string): StateIconKey => { | ||
| const key = state.toLowerCase().replace(/\s+/g, '') as StateIconKey; | ||
| return key in stateIcons ? key : 'unknown'; | ||
| }; | ||
|
|
||
| /** | ||
| * Renders a consumer group's state as an icon + label, with a tooltip describing what | ||
| * the state means. Shared between the consumer groups list and detail pages. | ||
| */ | ||
| export const ConsumerGroupStateCell = ({ state }: { state: string }) => { | ||
| const key = normalizeStateKey(state); | ||
|
|
||
| return ( | ||
| <TooltipProvider> | ||
| <Tooltip> | ||
| <TooltipTrigger | ||
| render={ | ||
| <span className="inline-flex items-center gap-2"> | ||
| {stateIcons[key]} | ||
| <span>{state}</span> | ||
| </span> | ||
| } | ||
| /> | ||
| <TooltipContent>{stateDescriptions[key]}</TooltipContent> | ||
| </Tooltip> | ||
| </TooltipProvider> | ||
| ); | ||
| }; |
63 changes: 63 additions & 0 deletions
63
frontend/src/components/ui/disabled-reason-button.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| /** | ||
| * Copyright 2025 Redpanda Data, Inc. | ||
| * | ||
| * Use of this software is governed by the Business Source License | ||
| * included in the file https://github.com/redpanda-data/redpanda/blob/dev/licenses/bsl.md | ||
| * | ||
| * As of the Change Date specified in that file, in accordance with | ||
| * the Business Source License, use of this software will be governed | ||
| * by the Apache License, Version 2.0 | ||
| */ | ||
|
|
||
| import { render, screen, waitFor } from '@testing-library/react'; | ||
| import userEvent from '@testing-library/user-event'; | ||
| import { describe, expect, test } from 'vitest'; | ||
|
|
||
| import { DisabledReasonButton } from './disabled-reason-button'; | ||
|
|
||
| describe('DisabledReasonButton', () => { | ||
| test('renders an enabled button when no reason is given', async () => { | ||
| const user = userEvent.setup(); | ||
| let clicked = false; | ||
|
|
||
| render( | ||
| <DisabledReasonButton onClick={() => (clicked = true)} testId="edit"> | ||
| Edit | ||
| </DisabledReasonButton> | ||
| ); | ||
|
|
||
| await user.click(screen.getByTestId('edit')); | ||
|
|
||
| expect(clicked).toBe(true); | ||
| }); | ||
|
|
||
| test('exposes the reason via a tooltip on hover when disabled', async () => { | ||
| const user = userEvent.setup(); | ||
|
|
||
| render( | ||
| <DisabledReasonButton iconOnly reason="No committed offset" testId="edit"> | ||
| Edit | ||
| </DisabledReasonButton> | ||
| ); | ||
|
|
||
| await user.hover(screen.getByTestId('edit')); | ||
|
|
||
| // role=tooltip is what the E2E assertions rely on; Base UI's popup does not set it itself. | ||
| await waitFor(() => expect(screen.getByRole('tooltip')).toHaveTextContent('No committed offset')); | ||
| }); | ||
|
|
||
| test('does not fire onClick when disabled', async () => { | ||
| const user = userEvent.setup(); | ||
| let clicked = false; | ||
|
|
||
| render( | ||
| <DisabledReasonButton onClick={() => (clicked = true)} reason="No committed offset" testId="edit"> | ||
| Edit | ||
| </DisabledReasonButton> | ||
| ); | ||
|
|
||
| await user.click(screen.getByTestId('edit')); | ||
|
|
||
| expect(clicked).toBe(false); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| /** | ||
| * Copyright 2025 Redpanda Data, Inc. | ||
| * | ||
| * Use of this software is governed by the Business Source License | ||
| * included in the file https://github.com/redpanda-data/redpanda/blob/dev/licenses/bsl.md | ||
| * | ||
| * As of the Change Date specified in that file, in accordance with | ||
| * the Business Source License, use of this software will be governed | ||
| * by the Apache License, Version 2.0 | ||
| */ | ||
|
|
||
| import { Button, type ButtonProps } from 'components/redpanda-ui/components/button'; | ||
| import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from 'components/redpanda-ui/components/tooltip'; | ||
| import { cn } from 'components/redpanda-ui/lib/utils'; | ||
| import type { ReactNode } from 'react'; | ||
|
|
||
| type DisabledReasonButtonProps = Pick<ButtonProps, 'variant' | 'size' | 'className'> & { | ||
| reason?: string; | ||
| testId?: string; | ||
| onClick?: (e: React.MouseEvent<HTMLElement>) => void; | ||
| children: ReactNode; | ||
| iconOnly?: boolean; | ||
| }; | ||
|
|
||
| /** | ||
| * Renders a button that is disabled with an explanatory tooltip when `reason` is set. | ||
| * For `iconOnly` (table/heading action) buttons the disabled state renders as a `<span>` | ||
| * (matching the legacy IconButton behavior the tests rely on); otherwise a disabled Button. | ||
| */ | ||
| export const DisabledReasonButton = ({ | ||
| reason, | ||
| testId, | ||
| onClick, | ||
| children, | ||
| variant = 'ghost', | ||
| size = 'icon-sm', | ||
| iconOnly = false, | ||
| className, | ||
| }: DisabledReasonButtonProps) => { | ||
| if (!reason) { | ||
| return ( | ||
| <Button className={className} data-testid={testId} onClick={onClick} size={size} variant={variant}> | ||
| {children} | ||
| </Button> | ||
| ); | ||
| } | ||
|
|
||
| // Use a hoverable element (span / aria-disabled button) rather than a real `disabled` | ||
| // button — disabled elements don't emit pointer events, so the tooltip would never show. | ||
| const trigger = iconOnly ? ( | ||
| <span | ||
| className={cn( | ||
| 'inline-flex h-8 w-8 cursor-not-allowed items-center justify-center text-muted-foreground opacity-50', | ||
| className | ||
| )} | ||
| data-testid={testId} | ||
| > | ||
| {children} | ||
| </span> | ||
| ) : ( | ||
| <Button | ||
| aria-disabled | ||
| className={cn('cursor-not-allowed opacity-50', className)} | ||
| data-testid={testId} | ||
| onClick={(e) => e.preventDefault()} | ||
| size={size} | ||
| variant={variant} | ||
| > | ||
| {children} | ||
| </Button> | ||
| ); | ||
|
|
||
| return ( | ||
| <TooltipProvider> | ||
| <Tooltip> | ||
| <TooltipTrigger render={trigger} /> | ||
| <TooltipContent role="tooltip">{reason}</TooltipContent> | ||
| </Tooltip> | ||
| </TooltipProvider> | ||
| ); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
it looks like we are still using this despite console v3 being released a long time ago, should we clean it up?
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.
There is a separate ticket for this.