Skip to content

Collapse long connector topic lists#1849

Open
rahulbsw wants to merge 6 commits into
kafbat:mainfrom
rahulbsw:issue-1306-collapse-connect-topics
Open

Collapse long connector topic lists#1849
rahulbsw wants to merge 6 commits into
kafbat:mainfrom
rahulbsw:issue-1306-collapse-connect-topics

Conversation

@rahulbsw

@rahulbsw rahulbsw commented May 12, 2026

Copy link
Copy Markdown

Resolves #1306

Summary

  • collapse long connector topic lists in the connectors table
  • collapse long connector topic lists on the connector topics details page
  • add expand-and-collapse coverage for both views

Testing

  • pnpm exec tsc --noEmit
  • pnpm exec eslint src/components/Connect/Details/Topics/Topics.tsx src/components/Connect/Details/Topics/Topics.styled.ts src/components/Connect/Details/Topics/tests/Topics.spec.tsx src/components/Connect/List/ConnectorsTable/connectorsColumns/cells/TopicsCell.tsx src/components/Connect/List/ConnectorsTable/connectorsColumns/cells/TopicsCell.styled.ts src/components/Connect/List/ConnectorsTable/connectorsColumns/cells/tests/TopicsCell.spec.tsx
  • pnpm exec jest --runInBand --runTestsByPath src/components/Connect/Details/Topics/tests/Topics.spec.tsx src/components/Connect/List/ConnectorsTable/connectorsColumns/cells/tests/TopicsCell.spec.tsx

Summary by CodeRabbit

  • New Features

    • Topics lists in multiple UI locations now collapse by default with a toggle to "show all" or "show less", improving readability for long topic lists.
  • Tests

    • Added comprehensive tests covering default collapsed state, toggle behavior, threshold cases (no toggle when at limit), and empty-state handling.

@rahulbsw rahulbsw requested a review from a team as a code owner May 12, 2026 03:29
@kapybro kapybro Bot added status/triage Issues pending maintainers triage status/triage/manual Manual triage in progress status/triage/completed Automatic triage completed and removed status/triage Issues pending maintainers triage labels May 12, 2026
@coderabbitai

coderabbitai Bot commented May 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e1e9de77-a0f5-432e-b2e5-5e2e9680029c

📥 Commits

Reviewing files that changed from the base of the PR and between ccd05fc and cffaa64.

📒 Files selected for processing (4)
  • frontend/src/components/Connect/Details/Topics/Topics.tsx
  • frontend/src/components/Connect/Details/Topics/__tests__/Topics.spec.tsx
  • frontend/src/components/Connect/List/ConnectorsTable/connectorsColumns/cells/TopicsCell.tsx
  • frontend/src/components/Connect/List/ConnectorsTable/connectorsColumns/cells/__tests__/TopicsCell.spec.tsx
🚧 Files skipped from review as they are similar to previous changes (4)
  • frontend/src/components/Connect/List/ConnectorsTable/connectorsColumns/cells/TopicsCell.tsx
  • frontend/src/components/Connect/Details/Topics/Topics.tsx
  • frontend/src/components/Connect/Details/Topics/tests/Topics.spec.tsx
  • frontend/src/components/Connect/List/ConnectorsTable/connectorsColumns/cells/tests/TopicsCell.spec.tsx

📝 Walkthrough

Walkthrough

Adds collapse/expand behavior for connector topic lists in the Topics detail view and the TopicsCell table cell, including ToggleButtonWrapper styled-components, configurable collapsed thresholds, toggle state, conditional rendering, and tests for collapsed, threshold, expanded, and empty cases.

Changes

Topic List Collapse/Expand Behavior

Layer / File(s) Summary
Topics detail view collapse/expand
frontend/src/components/Connect/Details/Topics/Topics.styled.ts, frontend/src/components/Connect/Details/Topics/Topics.tsx, frontend/src/components/Connect/Details/Topics/__tests__/Topics.spec.tsx
Add ToggleButtonWrapper styled component (8px margin-top), introduce COLLAPSED_TOPICS_COUNT and isExpanded state in Topics, derive visibleTopics and tableData, and conditionally render a toggle button. Tests cover collapsed default, expand/collapse interactions, threshold, and empty-state.
TopicsCell table component collapse/expand
frontend/src/components/Connect/List/ConnectorsTable/connectorsColumns/cells/TopicsCell.styled.ts, frontend/src/components/Connect/List/ConnectorsTable/connectorsColumns/cells/TopicsCell.tsx, frontend/src/components/Connect/List/ConnectorsTable/connectorsColumns/cells/__tests__/TopicsCell.spec.tsx
Add ToggleButtonWrapper styled component (4px margin-top), introduce COLLAPSED_TOPICS_COUNT and isExpanded state in TopicsCell, compute visibleTopics and hiddenTopicsCount, and conditionally render a toggle button with count. Tests verify collapsed default, expand/collapse interactions, threshold, and edge cases ([], undefined).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Suggested labels

scope/frontend

Suggested reviewers

  • Leshe4ka

Poem

🐰 Topics now fold like a nap,
Narrow at first, then widen the map,
A tiny button, polite and neat,
Shows more when asked, then tucks away sweet.
Hop, click, expand — then rest your feet.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Collapse long connector topic lists' clearly and specifically summarizes the main objective of the PR, which implements collapse/expand behavior for connector topic lists in two views.
Linked Issues check ✅ Passed The PR implementation fully addresses issue #1306's requirements: it collapses long topic lists in both the connectors table (TopicsCell) and connector details page (Topics), adds expand/collapse mechanism, and includes comprehensive test coverage for the collapse/expand behavior.
Out of Scope Changes check ✅ Passed All code changes are directly related to implementing the collapse/expand feature for connector topic lists as required by issue #1306. No unrelated modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
frontend/src/components/Connect/List/ConnectorsTable/connectorsColumns/cells/__tests__/TopicsCell.spec.tsx (1)

34-53: ⚡ Quick win

Consider adding edge-case test coverage.

Similar to the Topics test, consider adding tests for:

  • When topics.length <= COLLAPSED_TOPICS_COUNT (button should not appear)
  • When topics is empty or undefined

This would ensure the component handles all states gracefully.

🧪 Proposed additional test cases
it('does not show toggle button when topics count is below threshold', () => {
  const cellPropsSmall = {
    row: {
      original: {
        ...connectors[0],
        topics: ['topic-1', 'topic-2', 'topic-3'],
      },
    },
  } as CellContext<FullConnectorInfo, unknown>;

  render(
    <WithRoute path={clusterConnectorsPath()}>
      <TopicsCell {...cellPropsSmall} />
    </WithRoute>,
    { initialEntries: [clusterConnectorsPath(clusterName)] }
  );

  expect(screen.getByText('topic-1')).toBeInTheDocument();
  expect(screen.queryByRole('button')).not.toBeInTheDocument();
});

it('handles undefined topics gracefully', () => {
  const cellPropsEmpty = {
    row: {
      original: {
        ...connectors[0],
        topics: undefined,
      },
    },
  } as CellContext<FullConnectorInfo, unknown>;

  render(
    <WithRoute path={clusterConnectorsPath()}>
      <TopicsCell {...cellPropsEmpty} />
    </WithRoute>,
    { initialEntries: [clusterConnectorsPath(clusterName)] }
  );

  expect(screen.queryByRole('button')).not.toBeInTheDocument();
});
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@frontend/src/components/Connect/List/ConnectorsTable/connectorsColumns/cells/__tests__/TopicsCell.spec.tsx`
around lines 34 - 53, Add edge-case tests for TopicsCell: when topics.length <=
COLLAPSED_TOPICS_COUNT and when topics is undefined/empty. In the
TopicsCell.spec.tsx add two tests using the existing render helper (or
renderComponent) that render TopicsCell with row.original.topics set to a short
array (<= COLLAPSED_TOPICS_COUNT) and to undefined/[] and assert that topic
items render but the toggle button (role='button' or label 'Show X more') does
not exist; reference TopicsCell and COLLAPSED_TOPICS_COUNT to construct the test
inputs and assertions.
frontend/src/components/Connect/Details/Topics/__tests__/Topics.spec.tsx (1)

46-67: ⚡ Quick win

Consider adding edge-case test coverage.

The current test validates the happy path well, but consider adding tests for:

  • When topics.length <= COLLAPSED_TOPICS_COUNT (button should not appear)
  • When topics is empty or undefined

These would improve confidence that the component handles all states correctly.

🧪 Proposed additional test cases
it('does not show toggle button when topics count is below threshold', () => {
  (useConnector as jest.Mock).mockImplementation(() => ({
    data: {
      ...connector,
      topics: Array.from({ length: 5 }, (_, i) => `topic-${i + 1}`),
    },
  }));

  render(
    <WithRoute path={clusterConnectConnectorTopicsPath()}>
      <Topics />
    </WithRoute>,
    {
      initialEntries: [
        clusterConnectConnectorTopicsPath(
          clusterName,
          connectName,
          connectorName
        ),
      ],
    }
  );

  expect(screen.queryByRole('button')).not.toBeInTheDocument();
});

it('handles empty topics gracefully', () => {
  (useConnector as jest.Mock).mockImplementation(() => ({
    data: {
      ...connector,
      topics: [],
    },
  }));

  render(
    <WithRoute path={clusterConnectConnectorTopicsPath()}>
      <Topics />
    </WithRoute>,
    {
      initialEntries: [
        clusterConnectConnectorTopicsPath(
          clusterName,
          connectName,
          connectorName
        ),
      ],
    }
  );

  expect(screen.getByText('No topics found')).toBeInTheDocument();
  expect(screen.queryByRole('button')).not.toBeInTheDocument();
});
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/src/components/Connect/Details/Topics/__tests__/Topics.spec.tsx`
around lines 46 - 67, Add two edge-case tests for the Topics component: (1)
verify that when topics.length <= COLLAPSED_TOPICS_COUNT the toggle button is
not rendered by mocking useConnector to return a small topics array and
asserting no button appears (reference: Topics component and
COLLAPSED_TOPICS_COUNT, test file Topics.spec.tsx), and (2) verify that when
topics is empty or undefined the component renders the empty-state text (e.g.,
"No topics found") and does not render the toggle button by mocking useConnector
to return topics: [] or undefined and asserting the empty-state message and
absence of the button (reference: useConnector mock and Topics component).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@frontend/src/components/Connect/Details/Topics/__tests__/Topics.spec.tsx`:
- Around line 46-67: Add two edge-case tests for the Topics component: (1)
verify that when topics.length <= COLLAPSED_TOPICS_COUNT the toggle button is
not rendered by mocking useConnector to return a small topics array and
asserting no button appears (reference: Topics component and
COLLAPSED_TOPICS_COUNT, test file Topics.spec.tsx), and (2) verify that when
topics is empty or undefined the component renders the empty-state text (e.g.,
"No topics found") and does not render the toggle button by mocking useConnector
to return topics: [] or undefined and asserting the empty-state message and
absence of the button (reference: useConnector mock and Topics component).

In
`@frontend/src/components/Connect/List/ConnectorsTable/connectorsColumns/cells/__tests__/TopicsCell.spec.tsx`:
- Around line 34-53: Add edge-case tests for TopicsCell: when topics.length <=
COLLAPSED_TOPICS_COUNT and when topics is undefined/empty. In the
TopicsCell.spec.tsx add two tests using the existing render helper (or
renderComponent) that render TopicsCell with row.original.topics set to a short
array (<= COLLAPSED_TOPICS_COUNT) and to undefined/[] and assert that topic
items render but the toggle button (role='button' or label 'Show X more') does
not exist; reference TopicsCell and COLLAPSED_TOPICS_COUNT to construct the test
inputs and assertions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c6bd91a6-7a13-4a54-a646-c186b1539ac6

📥 Commits

Reviewing files that changed from the base of the PR and between 4bf06dd and ccd05fc.

📒 Files selected for processing (6)
  • frontend/src/components/Connect/Details/Topics/Topics.styled.ts
  • frontend/src/components/Connect/Details/Topics/Topics.tsx
  • frontend/src/components/Connect/Details/Topics/__tests__/Topics.spec.tsx
  • frontend/src/components/Connect/List/ConnectorsTable/connectorsColumns/cells/TopicsCell.styled.ts
  • frontend/src/components/Connect/List/ConnectorsTable/connectorsColumns/cells/TopicsCell.tsx
  • frontend/src/components/Connect/List/ConnectorsTable/connectorsColumns/cells/__tests__/TopicsCell.spec.tsx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/triage/completed Automatic triage completed status/triage/manual Manual triage in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FE: UX Improvement Request: Collapse Topic List in Kafka Connect

1 participant