Skip to content

refactor(ui): migrate StatusBadge to core Badge + Storybook - #33884

Closed
shah-harshit wants to merge 3 commits into
mainfrom
fix/statusbadge-core-migration
Closed

shah-harshit wants to merge 3 commits into
mainfrom
fix/statusbadge-core-migration

Conversation

@shah-harshit

@shah-harshit shah-harshit commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Migrate legacy StatusBadge and StatusBadgeV2 off the div + status-badge.less implementation onto the core @openmetadata/ui-core-components Badge — the go-forward design system.
  • Public API unchanged (label/status/dataTestId/className/externalIcon/showIcon), so all 14 call sites stay untouched; v1 keeps label-keyed icons, v2 keeps status-keyed icons + showIcon/externalIcon.
  • New STATUS_TYPE_TO_BADGE_COLOR map: each StatusType → nearest core Badge (utility-scale) color. The utility palette auto-flips in dark, so every status gains dark-mode support with no per-status CSS (supersedes the interim .less dark turnaround in fix(ui-core): dark-mode support for features empty-placeholder gradient #33876).
  • Preserve status-badge / status-badge-v2 / status-badge-label + per-status hook classes so existing consumer LESS overrides (Explore DataQualityTab, ContractDetailTab, GlossaryHeader) and Playwright locators keep matching.
  • Delete status-badge.less (−149 lines).
  • Add a core Storybook StatusBadge story (status → color reference, verifiable light/dark) and a unit test (label, testid, hook classes, color mapping).

Light mode

Legacy pills used border-radius: md, so the migration uses Badge type="color" (rounded-md), not pill-color (rounded-full), to stay close to the original shape. Colors shift to the design-system utility palette by design (that is the point of the migration); the closest hue is chosen per status to minimize the shift.

Notes / follow-ups

  • Consumer overrides in Explore/.../DataQualityTab.less and ContractDetailTab.less re-color specific badges with raw @red-9/@green-9 at higher specificity — these keep winning (unchanged light), but carry pre-existing dark gaps (raw palette, static). Out of scope here; separate cleanup.
  • StatusBadgeV2's old .status-badge-v2.success .anticon { color: transparent } hack is dropped with the .less; success now shows its colored icon.

Testing

  • yarn test StatusBadge.test.tsx — 3 passed (label, testid, hook classes, status→utility-color mapping).
  • yarn test on consumers (EntityStatusBadge, Explore + Profiler DataQualityTab) — 79 passed.
  • eslint --fix + prettier on changed files — 0 errors.
  • App/core tsc --noEmit — no errors in changed files.

RetriggerConfidence Score: 4/5

The PR appears safe to merge after a non-blocking visual compatibility issue with retained consumer border overrides is addressed.

Findings

  1. P2 Consumer Borders Double Up ▶
Summary

This PR migrates both legacy status-badge variants to the core Badge component, centralizes status-to-utility-color mapping, removes the legacy LESS implementation, and adds unit and Storybook coverage.

  • Preserves legacy hook classes and public component inputs.
  • Adds dark-mode-aware utility colors for every declared StatusType.
  • Existing consumer border overrides need adjustment because core Badge uses an outline rather than a border.

Reviews (1) · Last reviewed commit: "refactor(ui): migrate StatusBadge to cor..."

Replace the legacy div + status-badge.less implementation of StatusBadge
and StatusBadgeV2 with the core `@openmetadata/ui-core-components` Badge,
keeping the exact public API so all call sites stay untouched. Each
StatusType maps to the nearest core Badge (utility-scale) color via a new
STATUS_TYPE_TO_BADGE_COLOR map; the utility palette auto-flips in dark, so
every status gains dark-mode support with no per-status CSS.

- v1 keeps label-keyed icons, v2 keeps status-keyed icons + showIcon/externalIcon
- Preserve `status-badge`/`status-badge-v2`/`status-badge-label` + status hook
  classes so existing consumer LESS overrides and Playwright locators keep working
- Delete status-badge.less (-149 lines)
- Add core Storybook StatusBadge story (status -> color reference, light/dark)
- Add StatusBadge unit test (label, testid, hook classes, color mapping)

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@shah-harshit shah-harshit added the UI UI specific issues label Sep 23, 2026
@shah-harshit shah-harshit added safe to test Add this label to run secure Github workflows on PRs skip-pr-checks Bypass PR metadata validation check labels Sep 23, 2026
@shah-harshit shah-harshit self-assigned this Sep 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

ExploreSearchCard's @openmetadata/ui-core-components mock returns an explicit
subset, so after StatusBadge moved onto the core Badge it resolved undefined
("Element type is invalid"). Pass the real Badge through, matching the
existing toOwnerRef passthrough.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@gitar-bot

gitar-bot Bot commented Sep 24, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 1 closed / 1 findings

🟡 Medium risk · Migrates shared status badges, changing colors, icon rendering, and dark-mode styling.

Migrates legacy StatusBadge and StatusBadgeV2 to the core Badge component with a STATUS_TYPE_TO_BADGE_COLOR map that brings dark-mode support to all statuses. Public API and call sites remain unchanged; legacy hook classes and consumer LESS overrides are preserved. The outline-color adjustment resolves the Badge outline interaction with existing border overrides. No open issues.

✅ 1 closed
✅ Edge Case: Badge's inset outline paints over consumer border-color overrides

📄 openmetadata-ui/src/main/resources/ui/src/components/common/StatusBadge/StatusBadgeV2.component.tsx:33-42 📄 openmetadata-ui/src/main/resources/ui/src/components/common/StatusBadge/StatusBadge.component.tsx:35-40
The core Badge is bordered by default. It draws its edge with tw:outline-1 tw:-outline-offset-1 in utility-*-200 colors, and that outline sits on top of the element's 1px border. The consumer overrides the PR says still apply only restyle border: .status-badge-v2.success { border: 1px solid @green-16 } in contract-detail.less, and border: 1px solid @grey-15 / border-color: @grey-15 in DataQualityTab.less. The less rules still win over the layered utilities, but their border color is now hidden under the Badge's outline, so those badges show the utility outline color instead of the intended edge. You can fix this in the consumer rules by setting outline-color (or outline: none) next to the border. Another option is to pass bordered={false} and keep the legacy border on the status-badge hook classes.

Review coverage

📋 Rules No rules evaluated

🧪 Functional validation Not enabled · Set up

🤖 Auto-approval Not enabled · Set up

Options

Display: compact → Counting what did not apply, without listing it.

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

@github-actions

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 72%
72.84% (105349/144628) 58.21% (64545/110875) 59.15% (21153/35758)

@sonarqubecloud

Copy link
Copy Markdown

@shah-harshit

Copy link
Copy Markdown
Contributor Author

Moved into #33987 (merged this branch there; the external LESS overrides on StatusBadge in contract-detail.less / DataQualityTab.less were replaced by className at the render sites). Closing in favour of #33987.

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 skip-pr-checks Bypass PR metadata validation check UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant