-
Notifications
You must be signed in to change notification settings - Fork 1k
Refs #38822: update pf3 buttons to pf5 #10726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
12b46df to
5d9ee95
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR upgrades button components from PatternFly 3 to PatternFly 5 and replaces Enzyme-based tests with React Testing Library tests. The changes ensure consistent button styling and improve test quality across the application.
- Migrated ActionButtons, DeleteButton, DiffModal, ForemanModalFooter, ExportButton, SubmitOrCancel, and other button components from PF3 to PF5
- Replaced deprecated
bsStyleprops withvariantprops and updated button styling properties - Converted all component tests from Enzyme snapshot testing to React Testing Library with proper assertions
Reviewed Changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| ActionButtons.js | Replaced SplitButton with Dropdown and MenuToggle components for PF5 compatibility |
| ExportButton.js | Updated Button import and props, added ouiaId for testing |
| PersonalAccessToken.js | Migrated button styling from className to variant/size props |
| DeleteButton.js | Updated Button props and added ouiaId |
| Actions.js | Updated form action buttons with PF5 props and ouiaIds |
| DiffModal.js | Updated close button styling |
| ForemanModalFooter.js | Updated close button with PF5 variant |
| SubmitBtn.js/CancelBtn.js | Updated button variants and added ouiaIds |
| Test files | Converted from Enzyme snapshots to RTL with proper assertions and interactions |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
...sets/javascripts/react_app/components/ForemanModal/subcomponents/SubmitOrCancel/CancelBtn.js
Outdated
Show resolved
Hide resolved
webpack/assets/javascripts/react_app/components/common/ActionButtons/ActionButtons.js
Outdated
Show resolved
Hide resolved
webpack/assets/javascripts/react_app/components/common/ActionButtons/ActionButtons.js
Show resolved
Hide resolved
c23a763 to
46df6d4
Compare
Lukshio
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thanks,
I only found some things to change.
webpack/assets/javascripts/react_app/components/common/ActionButtons/ActionButtons.js
Show resolved
Hide resolved
webpack/assets/javascripts/react_app/components/common/ActionButtons/ActionButtons.js
Show resolved
Hide resolved
webpack/assets/javascripts/react_app/components/common/ActionButtons/ActionButtons.fixtures.js
Show resolved
Hide resolved
MariaAga
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a duplication of webpack/assets/javascripts/react_app/components/PF4/TableIndexPage/ActionButtons.js
Since common/actionButtons is used in plugins, I think the best way would be to move TableIndexPage/ActionButtons import to import from common, and combine the two components
b254470 to
a0d88ee
Compare
a0d88ee to
730069a
Compare
It's not a duplicate, the foreman_tasks/tasks also uses this change from import |
|
@MariSvirik Is it ok that in PF5 we will have 2 types of action buttons in the table? (kebab and button) or should we choose one, and which? |
|
I think that this PR with reduced scope of only one item in the list is safe to progress. |
|
I talked to Maria S, who talked to other designers as well, and its ok to have the 2 different table buttons, so I will review this task as it is |
730069a to
8396807
Compare
8396807 to
de5a3db
Compare
webpack/assets/javascripts/react_app/components/common/ActionButtons/ActionButtons.js
Outdated
Show resolved
Hide resolved
| {...firstButton.action} | ||
| bsSize="small" | ||
| <Dropdown | ||
| ouiaId="action-buttons-dropdown" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably need to check if theres an ID we can use, so every table row button wont have the same ouiaId
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's correct. Good catch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not been implemented
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right, correct, I changed the top most button id. The DropDown though it could be relying on any random id, it doesn't rely on any action, I can put random or the first of the collection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
webpack/assets/javascripts/react_app/components/common/ActionButtons/ActionButtons.js
Outdated
Show resolved
Hide resolved
webpack/assets/javascripts/react_app/components/common/ActionButtons/ActionButtons.js
Outdated
Show resolved
Hide resolved
webpack/assets/javascripts/react_app/components/common/ActionButtons/ActionButtons.js
Outdated
Show resolved
Hide resolved
| <Button | ||
| ouiaId="action-button" | ||
| size="sm" | ||
| variant="primary" | ||
| isDisabled={buttons[0].action?.disabled} | ||
| {...buttons[0].action} | ||
| > | ||
| {buttons[0].title} | ||
| </Button> | ||
| ); | ||
| const firstButton = buttons.shift(); | ||
|
|
||
| const [firstButton, ...restButtons] = buttons; | ||
|
|
||
| return ( | ||
| <SplitButton | ||
| title={firstButton.title} | ||
| {...firstButton.action} | ||
| bsSize="small" | ||
| <Dropdown | ||
| ouiaId="action-buttons-dropdown" | ||
| isOpen={isOpen} | ||
| onOpenChange={openState => setIsOpen(openState)} | ||
| toggle={toggleRef => ( | ||
| <MenuToggle | ||
| ref={toggleRef} | ||
| onClick={onToggleClick} | ||
| isExpanded={isOpen} | ||
| splitButtonOptions={{ | ||
| variant: 'action', | ||
| items: [ | ||
| <MenuToggleAction | ||
| id={`split-button-action-${firstButton.action?.id}}-toggle-button`} | ||
| key="split-action" | ||
| aria-label={firstButton.title} | ||
| onClick={firstButton.action?.onClick} | ||
| > | ||
| {firstButton.title} | ||
| </MenuToggleAction>, | ||
| ], | ||
| }} | ||
| aria-label="Menu toggle with action split button" | ||
| /> | ||
| )} | ||
| shouldFocusToggleOnSelect | ||
| > | ||
| {buttons.map(button => ( | ||
| <MenuItem key={button.title} title={button.title} {...button.action}> | ||
| {button.title} | ||
| </MenuItem> | ||
| ))} | ||
| </SplitButton> | ||
| <DropdownList className="action-buttons"> | ||
| {restButtons.map(button => ( | ||
| <DropdownItem | ||
| ouiaId={`${button.action?.id}-dropdown-item-id`} | ||
| key={`${button.action?.id}-dropdown-item-key`} | ||
| title={button.title} | ||
| onClick={button.action?.onClick} | ||
| isDisabled={button.action?.disabled} | ||
| > | ||
| {button.title} | ||
| </DropdownItem> |
Copilot
AI
Nov 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Buttons with href attributes (like the 'second' button in fixtures) may not render correctly. PatternFly 5's Button component requires the component="a" prop to render as an anchor tag. The single button case should be updated:
<Button
ouiaId="action-button"
size="sm"
variant="primary"
component={buttons[0].action?.href ? 'a' : undefined}
isDisabled={buttons[0].action?.disabled}
{...buttons[0].action}
>For DropdownItem, PatternFly 5 uses the to prop for the href value and also may need component="a" depending on the version. Verify the correct API usage for links in dropdown items.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure this is a valid point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a generic component, it needs to be able to handle onClick but href as well.
<DropdownItem
ouiaId={`${button.action?.id}-dropdown-item-id`}
key={`${button.action?.id}-dropdown-item-key`}
title={button.title}
onClick={button.action?.onClick}
isDisabled={button.action?.disabled}
to={button.action?.to}
component={button.action?.href ? 'a' : undefined}
{...button.action}
>There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And the same for the MenuToggleAction probably
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no url for href
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't be the test changed to accept getByRole('link')?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, but onClick is typically used for safe, controlled actions like API calls, while a standard a tag is a simple link. These can be different use cases where the 'a' tag is a simple link to somewhere, but onClick connected to only to safe actions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kfamilonidis How does that effect changing the test to accept getByRole('link') so we can have both urls and onclick?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are links that perform certain actions, in this use cases (one, many buttons) all buttons are triggering a modal. Considering that these actions are safe, it would be safe to say and is very easy to change all the buttons to a tag and tested by getByRole('link').
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the request is for the split button to support urls, is for future needs not the current ones, and we can have buttons that need to just be an a tag that open a new tab. Or do you suggest to implement opening in a new tab in a different way?
Example of usage with the other type of table action dropdown: https://github.com/theforeman/foreman_remote_execution/blob/master/webpack/JobInvocationDetail/TemplateInvocationComponents/TemplateActionButtons.js#L22
de5a3db to
bd735de
Compare
|
All comments have been implemented. |
bd735de to
7053ac0
Compare
kfamilonidis
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To @MariaAga credit, id was found missing.
bcc58ac to
f46578a
Compare
Upgrade ActionButtons and replace Enzyme tests with RTL. Fix styling an replace bgStyle with equivalent variant props.
f46578a to
6fa41ff
Compare


Upgrade common/ActionButtons and replace Enzyme tests with React Testing Library. Fix styling and replace bgStyle with equivalent variant props.
Acceptance Criteria:
ActionButtons: actions should appear in dropdown list when more than 1./webhooks-> index table./foreman_tasks/tasks-> index tablefollowed by #10766