chore(Label): Added enums for LabelColor and LabelStatus#12338
chore(Label): Added enums for LabelColor and LabelStatus#12338tlabaj wants to merge 4 commits intopatternfly:mainfrom
Conversation
WalkthroughAdds exported TypeScript enums Changes
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
| Title, | ||
| Icon | ||
| } from '@patternfly/react-core'; | ||
| import { LabelStatus } from '../../../components/Label/Label'; |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
Import LabelStatus from @patternfly/react-core for consistency.
Label is already imported from @patternfly/react-core on line 12, and this PR exports LabelStatus from the package. Using a deep relative path here (../../../components/Label/Label) is inconsistent with the rest of the example and bypasses the public entry point consumers will use.
♻️ Proposed fix
import {
Alert,
Card,
CardBody,
CardHeader,
Divider,
Flex,
FlexItem,
Grid,
GridItem,
Label,
+ LabelStatus,
NotificationDrawer,
NotificationDrawerBody,
NotificationDrawerGroup,
NotificationDrawerList,
NotificationDrawerListItem,
NotificationDrawerListItemBody,
NotificationDrawerListItemHeader,
Popover,
Title,
Icon
} from '@patternfly/react-core';
-import { LabelStatus } from '../../../components/Label/Label';🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/react-core/src/demos/examples/Card/CardStatus.tsx` at 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.
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