Skip to content

feat(ui): paginate glossary terms with cursor Prev/Next and paged expand-all - #32223

Merged
anuj-kumary merged 11 commits into
mainfrom
issue-29916-table
Aug 29, 2026
Merged

anuj-kumary merged 11 commits into
mainfrom
issue-29916-table

Conversation

@anuj-kumary

@anuj-kumary anuj-kumary commented Aug 28, 2026 •

Copy link
Copy Markdown
Member

Describe your changes:

Fixes #29916

Rework the glossary terms table (GlossaryTermTab) off infinite scroll and
add nested-load affordances:

  • Replace infinite scroll with cursor-based Previous/Next pagination.
  • Expand All now loads the tree a page at a time (50 nested terms) with a "Load more" bar showing "Showing x of y nested terms"; the bar only appears while more remain and is disabled while loading.

Type of change:

  • Bug fix
  • Improvement
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation

High-level design:

N/A — small change.

Tests:

Use cases covered

Unit tests

Backend integration tests

Ingestion integration tests

Playwright (UI) tests

Manual testing performed

UI screen recording / screenshots:

Not applicable.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed.
  • For UI changes: I attached a screen recording and/or screenshots above.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.

Greptile Summary

The PR replaces infinite glossary-term scrolling with explicit cursor-based Previous/Next pagination and adds paged Expand All loading.

  • Uses cursor pagination for normal glossary listings and offset pagination for search results.
  • Accumulates expand-all pages into a progressively rebuilt hierarchy.
  • Adds nested-term progress labels, localized strings, and updated Playwright coverage.

Confidence Score: 4/5

The PR is not yet safe to merge because changing search or status can leave a stale Expand All cursor that replaces filtered results with unfiltered tree data.

The filter-change path resets only ordinary pagination, while the expand-all mode, cursor, and accumulated terms survive and remain connected to the Load More action.

Files Needing Attention: openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx

Important Files Changed

Filename Overview
openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx Implements the pagination and paged expand-all state machine, but filter changes still leave the prior expand cursor and accumulated tree reachable.
openmetadata-ui/src/main/resources/ui/src/rest/glossaryAPI.ts Extends glossary listing requests to pass both forward and backward cursors.
openmetadata-ui/src/main/resources/ui/src/utils/GlossaryPureUtils.ts Updates tree construction to retain parentless descendants until their parent is loaded while allowing term-view direct children.
openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/Glossary/LargeGlossaryPerformance.spec.ts Reworks the large-glossary test to exercise explicit cursor pagination instead of infinite scrolling.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Glossary term table] --> B{View mode}
  B -->|Normal listing| C[Cursor Previous/Next]
  B -->|Search| D[Offset pagination]
  B -->|Expand All| E[Fetch 50 terms]
  E --> F[Accumulate flat pages]
  F --> G[Rebuild hierarchy]
  G -->|Cursor remains| E
Loading

Reviews (10): Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

@anuj-kumary anuj-kumary self-assigned this Aug 28, 2026
@anuj-kumary anuj-kumary added the safe to test Add this label to run secure Github workflows on PRs label Aug 28, 2026
@github-actions github-actions Bot added the UI UI specific issues label Aug 28, 2026
@github-actions

github-actions Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ UI Checkstyle passed — lint findings in changed files

🔍 ESLint findings in this PR's files — 0 error(s), 33 warning(s)

Errors block the build. Warnings do not yet — they are rules whose backlog is still
being worked down, listed so this PR does not add to it. See docs/ui-code-quality-gate.md.

0 error(s), 33 warning(s) across 4 changed file(s).

Count Rule
13 react-hooks/exhaustive-deps
5 sonarjs/no-duplicate-string
4 sonarjs/cyclomatic-complexity
3 openmetadata-imports/no-rest-ui-imports
3 openmetadata-imports/no-impure-pure-utils
2 sonarjs/expression-complexity
1 openmetadata-imports/review-sequential-api-calls
1 sonarjs/cognitive-complexity
1 openmetadata-imports/no-internal-barrel-imports
All findings
Location Rule Message
🟡 src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx:161:25 sonarjs/no-duplicate-string Define a constant instead of duplicating this literal 3 times.
🟡 src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx:162:23 sonarjs/no-duplicate-string Define a constant instead of duplicating this literal 3 times.
🟡 src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx:186:10 sonarjs/expression-complexity Reduce the number of conditional operators (4) used in the expression (maximum allowed 3).
🟡 src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx:211:75 sonarjs/cyclomatic-complexity {"message":"Function has a complexity of 19 which is greater than 10 authorized.","cost":9,"secondaryLocations":[{"line":211,"column":74,"endLine":211,"endColum
🟡 src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx:313:34 react-hooks/exhaustive-deps React Hook useCallback received a function whose dependencies are unknown. Pass an inline function instead.
🟡 src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx:317:9 react-hooks/exhaustive-deps The 'fetchChildTerms' function makes the dependencies of useCallback Hook (at line 780) change on every render. To fix this, wrap the definition of 'fetchChildT
🟡 src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx:368:9 react-hooks/exhaustive-deps The 'fetchAllTerms' function makes the dependencies of useCallback Hook (at line 1152) change on every render. To fix this, wrap the definition of 'fetchAllTerm
🟡 src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx:372:6 sonarjs/cyclomatic-complexity {"message":"Function has a complexity of 16 which is greater than 10 authorized.","cost":6,"secondaryLocations":[{"line":372,"column":5,"endLine":372,"endColumn
🟡 src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx:436:31 openmetadata-imports/review-sequential-api-calls Review these sequential API requests. If they are independent, start them together with Promise.all/Promise.allSettled; keep sequencing only when data-dependent
🟡 src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx:468:9 react-hooks/exhaustive-deps The 'fetchExpadedTree' function makes the dependencies of useCallback Hook (at line 1152) change on every render. To fix this, wrap the definition of 'fetchExpa
🟡 src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx:602:6 react-hooks/exhaustive-deps React Hook useEffect has missing dependencies: 'fetchAllTerms', 'handlePagingChange', and 'setGlossaryChildTerms'. Either include them or remove the dependency
🟡 src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx:614:6 react-hooks/exhaustive-deps React Hook useEffect has a missing dependency: 'setGlossaryChildTerms'. Either include it or remove the dependency array.
🟡 src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx:676:7 sonarjs/cognitive-complexity Refactor this function to reduce its Cognitive Complexity from 19 to the 15 allowed.
🟡 src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx:676:7 sonarjs/cyclomatic-complexity {"message":"Function has a complexity of 12 which is greater than 10 authorized.","cost":2,"secondaryLocations":[{"line":676,"column":6,"endLine":676,"endColumn
🟡 src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx:752:5 react-hooks/exhaustive-deps React Hook useCallback has missing dependencies: 'setGlossaryChildTerms', 't', and 'updateGlossaryTermStatus'. Either include them or remove the dependency arra
🟡 src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx:792:29 sonarjs/cyclomatic-complexity {"message":"Function has a complexity of 14 which is greater than 10 authorized.","cost":4,"secondaryLocations":[{"line":792,"column":28,"endLine":792,"endColum
🟡 src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx:1034:31 sonarjs/no-duplicate-string Define a constant instead of duplicating this literal 4 times.
🟡 src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx:1071:6 react-hooks/exhaustive-deps React Hook useMemo has missing dependencies: 'currentUser', 'onAddGlossaryTerm', 'onEditGlossaryTerm', and 't'. Either include them or remove the dependency arr
🟡 src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx:1211:5 react-hooks/exhaustive-deps React Hook useMemo has missing dependencies: 'handleCheckboxChange' and 't'. Either include them or remove the dependency array.
🟡 src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx:1305:6 react-hooks/exhaustive-deps React Hook useMemo has missing dependencies: 'handleEditGlossary', 'handleSearchChange', 'permissions.EditAll', and 't'. Either include them or remove the depen
🟡 src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx:1375:11 sonarjs/expression-complexity Reduce the number of conditional operators (4) used in the expression (maximum allowed 3).
🟡 src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx:1380:5 react-hooks/exhaustive-deps React Hook useMemo has unnecessary dependencies: 'glossaryChildTerms', 'glossaryTerms', and 'setGlossaryChildTerms'. Either exclude them or remove the dependenc
🟡 src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx:1453:6 react-hooks/exhaustive-deps React Hook useMemo has an unnecessary dependency: 'movedGlossaryTerm'. Either exclude it or remove the dependency array.
🟡 src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx:1666:6 react-hooks/exhaustive-deps React Hook useEffect has missing dependencies: 'activeGlossary', 'fetchAllTerms', 'handlePagingChange', and 'previousGlossaryFQN'. Either include them or remove
🟡 src/components/common/RichTextEditor/RichTextEditorPreviewNew.tsx:93:37 sonarjs/no-duplicate-string Define a constant instead of duplicating this literal 3 times.
🟡 src/components/common/RichTextEditor/RichTextEditorPreviewNew.tsx:95:37 sonarjs/no-duplicate-string Define a constant instead of duplicating this literal 3 times.
🟡 src/rest/glossaryAPI.ts:17:1 openmetadata-imports/no-rest-ui-imports REST clients must not import UI or state-layer modules. Move shared request/response types to the interface layer.
🟡 src/rest/glossaryAPI.ts:18:1 openmetadata-imports/no-rest-ui-imports REST clients must not import UI or state-layer modules. Move shared request/response types to the interface layer.
🟡 src/rest/glossaryAPI.ts:19:1 openmetadata-imports/no-rest-ui-imports REST clients must not import UI or state-layer modules. Move shared request/response types to the interface layer.
🟡 src/rest/glossaryAPI.ts:35:1 openmetadata-imports/no-internal-barrel-imports Import the internal module directly instead of its index barrel so unrelated siblings do not enter the bundle graph.
🟡 src/utils/GlossaryPureUtils.ts:14:1 openmetadata-imports/no-impure-pure-utils Pure utilities must not depend on React, UI, state, hooks, pages, or REST clients. Move orchestration/rendering out or move shared types to a lower layer.
🟡 src/utils/GlossaryPureUtils.ts:15:1 openmetadata-imports/no-impure-pure-utils Pure utilities must not depend on React, UI, state, hooks, pages, or REST clients. Move orchestration/rendering out or move shared types to a lower layer.
🟡 src/utils/GlossaryPureUtils.ts:16:1 openmetadata-imports/no-impure-pure-utils Pure utilities must not depend on React, UI, state, hooks, pages, or REST clients. Move orchestration/rendering out or move shared types to a lower layer.

Fix locally (fast - only checks files changed in this branch):

make ui-checkstyle-changed

anuj-kumary and others added 2 commits August 28, 2026 14:24
Addresses the gitar-bot review finding: a parent with one nested term
rendered '1 terms'. Pick label.count-term (singular) vs
label.count-term-plural based on the count. Adds count-term across locales.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
The large-glossary test asserted infinite-scroll behaviour (scroll to
bottom, expect the directChildrenOf+after fetch, then 100 appended rows).
Cursor pagination replaced infinite scroll, so that fetch never fires on
scroll and the test timed out. Rewrite it to click Next (which triggers
the directChildrenOf+after fetch), assert the page is replaced (still 50
rows, Previous now enabled), then Prev back to the first page.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Two defects flagged in review on the paginated glossary terms table:

1. buildTree promoted parentless descendants to roots. Progressive
   expand-all paginates all levels by name (backend orders by name,id),
   so a nested term can arrive on an earlier page than its parent term.
   buildTree then rendered that orphan as a top-level row, corrupting the
   hierarchy. Hold such orphans back until the page carrying their parent
   loads, at which point they attach correctly.

2. The Expand/Collapse-All control desynced on partial loads. The action
   was chosen by an expandedRowKeys === expandableKeys equality that a
   partially loaded tree never satisfies, and toggleExpandBtn was blindly
   flipped. So a second click (or one after a manual row collapse) re-ran
   the expand path, reset the accumulated pages, and hid the only Load
   More control. Drive the action, label, and icon off the explicit
   expand-all mode flag instead.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@gitar-bot

gitar-bot Bot commented Aug 29, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 6 resolved / 6 findings

Cursor-based pagination replaces infinite scroll in the glossary-term table with paged expand-all loading (50 nested terms per page) and a "Load more" progress bar. Fixed search paging to use offset pagination correctly, eliminated redundant term-count recomputation, addressed grammatical singular/plural term-count labels, corrected tree construction to preserve 3rd-level terms, tightened parent-type validation in orphan hold-back logic, and fixed useCallback dependency list. No issues remain.

✅ 6 resolved
✅ Bug: Search paging uses pageSize for offset but fixed limit

📄 openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx:328-337 📄 openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx:1673-1674
In search mode the request window size is hardcoded to limit: PAGE_SIZE_LARGE, while the page offset is computed as (nextPage - 1) * pageSize. They coincide today because usePaging(PAGE_SIZE_LARGE) initializes pageSize to the same value, but if pageSize ever changes (e.g. a page-size selector is wired into NextPrevious), offsets and the fetched window will diverge, skipping or duplicating results. Use pageSize for the limit as well so the two always stay in sync.

✅ Performance: countLoadedNestedTerms recomputed per row on every render

📄 openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx:147-157 📄 openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx:752-753
The name-column renderer calls countLoadedNestedTerms(record) for every row on each render, and that helper recurses the entire subtree. Summed across rows this is O(nodes × subtree size), i.e. up to O(n^2) per render for a large expanded tree. Pages are capped at 50 nested terms so impact is limited today, but consider memoizing the per-FQN counts (or computing them once when the tree data changes) to avoid the repeated traversal during frequent re-renders (drag, hover, etc.).

✅ Quality: Plural term counts won't grammatically handle count=1

📄 openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx:784-789 📄 openmetadata-ui/src/main/resources/ui/src/locale/languages/en-us.json:537
count-term-plural ("{{count}} terms") is passed a count but is a single fixed string, so a term with one nested child renders "1 terms". i18next supports plural resolution via _one/_other suffixed keys; if singular/plural correctness matters here, split the key into plural forms rather than relying on a single hardcoded plural string. Minor and consistent with some existing keys, so low priority.

✅ Bug: buildTree can drop 3rd-level terms when parent has no inline children

📄 openmetadata-ui/src/main/resources/ui/src/utils/GlossaryPureUtils.ts:39-53
buildTree pushes a shallow snapshot {...current, type:'glossaryTerm'} into its parent's children, then creates missing children arrays lazily with ??=. If an intermediate node is snapshotted into its parent while its own children is still undefined (line 37 only pre-creates an array when obj.children?.length is truthy), a later nodes[intermediate].children ??= [] creates a NEW array on the original node, not on the snapshot already placed in the tree. The grandchild then attaches to an orphaned node and disappears from the rendered hierarchy. This is reachable in the progressive expand-all flow, where FQN-sorted flat pages deliver parents before children and immediate children fields may be empty. Push into parentNode by reference (or ensure the child array is shared) rather than pushing a snapshot copy.

✅ Edge Case: Orphan hold-back relies on parent.type being GLOSSARY_TERM

📄 openmetadata-ui/src/main/resources/ui/src/utils/GlossaryPureUtils.ts:58-63
isOrphanOfUnloadedParent only holds a term back when obj.parent?.type === EntityType.GLOSSARY_TERM. If the API returns a parent reference without a populated type (only fqn/id), the term is treated as a genuine root and promoted to a spurious top-level entry — the exact corruption this commit aims to prevent. Consider gating on presence of parentFqn alone (a missing node in the current dataset already implies not-yet-loaded), or verify the expand-all response always populates parent.type.

...and 1 more resolved from earlier reviews

Options

Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@sonarqubecloud

Copy link
Copy Markdown

This branch was previously deployed

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

Labels

safe to test Add this label to run secure Github workflows on PRs UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove high limit usage of API_RES_MAX_SIZE in GlossaryTermTab

2 participants