chore(Label): Added enums for LabelColor and LabelStatus#12338
chore(Label): Added enums for LabelColor and LabelStatus#12338wise-king-sullyman merged 5 commits intopatternfly:mainfrom
Conversation
WalkthroughAdds exported TypeScript enums ChangesLabel enums + consumption across examples/tests/demos
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
Preview: https://pf-react-pr-12338.surge.sh A11y report: https://pf-react-pr-12338-a11y.surge.sh |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/react-core/src/components/Label/Label.tsx`:
- Around line 25-36: Tests for Label currently use a hardcoded color array that
can drift from the exported LabelColor enum; update the tests in Label.test.tsx
to derive test cases from the LabelColor enum by importing LabelColor and using
Object.values(LabelColor) (or Object.keys/values as appropriate) to drive the
color matrix/snapshots so any new member (e.g., orangered) is automatically
covered, and replace the existing hardcoded color list with that derived list in
the relevant test loops/assertions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 784925fe-fd63-4540-a120-e1b53a16bb93
📒 Files selected for processing (15)
packages/react-core/src/components/Label/Label.tsxpackages/react-core/src/components/Label/examples/LabelCompact.tsxpackages/react-core/src/components/Label/examples/LabelCustomRender.tsxpackages/react-core/src/components/Label/examples/LabelEditable.tsxpackages/react-core/src/components/Label/examples/LabelFilled.tsxpackages/react-core/src/components/Label/examples/LabelGroupBasic.tsxpackages/react-core/src/components/Label/examples/LabelGroupCategory.tsxpackages/react-core/src/components/Label/examples/LabelGroupCategoryRemovable.tsxpackages/react-core/src/components/Label/examples/LabelGroupEditableAdd.tsxpackages/react-core/src/components/Label/examples/LabelGroupEditableAddDropdown.tsxpackages/react-core/src/components/Label/examples/LabelGroupEditableAddModal.tsxpackages/react-core/src/components/Label/examples/LabelGroupEditableLabels.tsxpackages/react-core/src/components/Label/examples/LabelGroupOverflow.tsxpackages/react-core/src/components/Label/examples/LabelGroupVerticalCategoryOverflowRemovable.tsxpackages/react-core/src/components/Label/examples/LabelOutline.tsx
thatblindgeye
left a comment
There was a problem hiding this comment.
Following files will need to be updated as well:
Files with color string literals:
- demos/RTL/examples/PaginatedTable.tsx
- demos/examples/Card/CardHorizontalGrid.tsx
- demos/examples/Tabs/TabsOpen.tsx
- demos/examples/Tabs/TabsOpenWithSecondaryTabs.tsx
Files with status string literals:
5. demos/examples/Card/CardStatus.tsx
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/react-core/src/demos/examples/Card/CardStatus.tsx`:
- Line 24: The file imports LabelStatus via a deep relative path; update the
imports to use the public package export instead: import Label and LabelStatus
from '@patternfly/react-core' (replace the '../../../components/Label/Label'
import). Locate the import statements in CardStatus.tsx (where Label is already
imported) and change them to a single named import that includes LabelStatus so
the demo uses the public API.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 639d3d8d-c1db-4e62-b4ef-3e173a5c4ca9
⛔ Files ignored due to path filters (3)
packages/react-core/src/components/Compass/__tests__/__snapshots__/CompassMainHeader.test.tsx.snapis excluded by!**/*.snappackages/react-core/src/components/Compass/__tests__/__snapshots__/CompassPanel.test.tsx.snapis excluded by!**/*.snappackages/react-core/src/components/Label/__tests__/__snapshots__/Label.test.tsx.snapis excluded by!**/*.snap
📒 Files selected for processing (6)
packages/react-core/src/components/Label/__tests__/Label.test.tsxpackages/react-core/src/demos/RTL/examples/PaginatedTable.tsxpackages/react-core/src/demos/examples/Card/CardHorizontalGrid.tsxpackages/react-core/src/demos/examples/Card/CardStatus.tsxpackages/react-core/src/demos/examples/Tabs/TabsOpen.tsxpackages/react-core/src/demos/examples/Tabs/TabsOpenWithSecondaryTabs.tsx
✅ Files skipped from review due to trivial changes (4)
- packages/react-core/src/demos/examples/Tabs/TabsOpenWithSecondaryTabs.tsx
- packages/react-core/src/demos/RTL/examples/PaginatedTable.tsx
- packages/react-core/src/demos/examples/Card/CardHorizontalGrid.tsx
- packages/react-core/src/demos/examples/Tabs/TabsOpen.tsx
There was a problem hiding this comment.
Do we want to add the enums to the props?
| MenuToggle, | ||
| MenuToggleElement | ||
| } from '@patternfly/react-core'; | ||
| import { LabelColor } from '../../../components/Label/Label'; |
There was a problem hiding this comment.
Also +1 to the comment about changing the imports in the demos to be from @patternfly/react-core.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/react-core/src/components/Label/Label.tsx (1)
48-48:⚠️ Potential issue | 🟡 Minor | ⚡ Quick win
statusprop is missingLabelStatusfrom its union type.
LabelProps.color(line 44) was updated to includeLabelColorin its union, butLabelProps.statuswas not updated to includeLabelStatus. Per the PR objectives, both props should include the enum in their union so generated docs and IDE tooling surface it.🛠️ Proposed fix
- status?: 'success' | 'warning' | 'danger' | 'info' | 'custom'; + status?: 'success' | 'warning' | 'danger' | 'info' | 'custom' | LabelStatus;🤖 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 `@packages/react-core/src/components/Label/Label.tsx` at line 48, The LabelProps.type for the status prop currently uses a string union ('success' | 'warning' | 'danger' | 'info' | 'custom') but omits the exported LabelStatus enum type; update the status declaration on the LabelProps interface (the status prop in Label.tsx / LabelProps) to include LabelStatus in the union (e.g., add | LabelStatus) so IDEs and generated docs surface the enum values the same way LabelProps.color does with LabelColor.
🤖 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.
Outside diff comments:
In `@packages/react-core/src/components/Label/Label.tsx`:
- Line 48: The LabelProps.type for the status prop currently uses a string union
('success' | 'warning' | 'danger' | 'info' | 'custom') but omits the exported
LabelStatus enum type; update the status declaration on the LabelProps interface
(the status prop in Label.tsx / LabelProps) to include LabelStatus in the union
(e.g., add | LabelStatus) so IDEs and generated docs surface the enum values the
same way LabelProps.color does with LabelColor.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c3707b45-34ad-4f67-b367-69418847b68c
📒 Files selected for processing (6)
packages/react-core/src/components/Label/Label.tsxpackages/react-core/src/demos/RTL/examples/PaginatedTable.tsxpackages/react-core/src/demos/examples/Card/CardHorizontalGrid.tsxpackages/react-core/src/demos/examples/Card/CardStatus.tsxpackages/react-core/src/demos/examples/Tabs/TabsOpen.tsxpackages/react-core/src/demos/examples/Tabs/TabsOpenWithSecondaryTabs.tsx
✅ Files skipped from review due to trivial changes (4)
- packages/react-core/src/demos/examples/Tabs/TabsOpenWithSecondaryTabs.tsx
- packages/react-core/src/demos/examples/Card/CardStatus.tsx
- packages/react-core/src/demos/examples/Tabs/TabsOpen.tsx
- packages/react-core/src/demos/examples/Card/CardHorizontalGrid.tsx
|
Your changes have been released in:
Thanks for your contribution! 🎉 |
What: Closes #11835
Adds LabelStatus and
LabelColorstring enums onLabel, exports them from@patternfly/react-core, and uses them inside the component for default color,colorStyles, andstatusIcons.LabelPropskeeps an explicit string union for color and status and includes the enum in each union (same idea asToolbarGroup/Pagination) so generated docs list both literals and the enum.Docs examples under
Label/examples were updated to import and useLabelColor/LabelStatusinstead of raw strings, consistent with other components (e.g.ButtonVariant,PaginationVariant). Dynamic color cases use asLabelColorwhere a string is cast for the color prop.Summary by CodeRabbit