Skip to content

Conversation

@MariaAga
Copy link
Member

Replaces the tests to RTL, removed the redux logic for modal rendering as I think it makes refactors and code reading more complicated.

Copy link

Copilot AI left a 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 replaces the existing ForemanModal system with PatternFly 5 modals, simplifying modal state management by removing Redux logic in favor of local state. The changes modernize the modal implementation and improve code maintainability by eliminating complex Redux-based modal rendering patterns.

  • Replaced ForemanModal components with PF5 Modal components throughout the application
  • Migrated from Redux-based modal state management to local useState hooks
  • Updated all tests from enzyme-based snapshot testing to React Testing Library

Reviewed Changes

Copilot reviewed 39 out of 39 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
webpack/mocks/foremanReact/components/ForemanModal/ Removed ForemanModal mock files no longer needed
webpack/ForemanTasks/Components/common/ClickConfirmation/ Migrated to PF5 Modal with local state and added UnlockModal components
webpack/ForemanTasks/Components/TasksTable/ Updated to use individual modal components with local state management
webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ Complete rewrite replacing Redux-connected component with individual modal components
webpack/ForemanTasks/Components/TaskDetails/ Updated Task and TaskButtons components to use new modal system
webpack/ForemanTasks/Components/TaskActions/ Removed UnlockModals file, functionality moved to ClickConfirmation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@MariaAga MariaAga force-pushed the modals-pf5 branch 3 times, most recently from f8d48f4 to 988ba15 Compare October 15, 2025 12:20
@MariaAga MariaAga added the breaks-robottelo Can be set via comment: /label breaks-robottelo label Oct 16, 2025
Comment on lines 147 to 168

describe('Modal Close Behavior', () => {
it('resets checkbox state when modal is closed via cancel', () => {
const setModalClosed = jest.fn();

render(
<ClickConfirmation {...defaultProps} setModalClosed={setModalClosed} />
);

const checkbox = screen.getByRole('checkbox');
const cancelButton = screen.getByRole('button', { name: 'Cancel' });

// Check the checkbox
fireEvent.click(checkbox);
expect(checkbox).toBeChecked();

// Close the modal
fireEvent.click(cancelButton);

// The checkbox should be reset (though we can't test this directly since modal closes)
expect(setModalClosed).toHaveBeenCalled();
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
describe('Modal Close Behavior', () => {
it('resets checkbox state when modal is closed via cancel', () => {
const setModalClosed = jest.fn();
render(
<ClickConfirmation {...defaultProps} setModalClosed={setModalClosed} />
);
const checkbox = screen.getByRole('checkbox');
const cancelButton = screen.getByRole('button', { name: 'Cancel' });
// Check the checkbox
fireEvent.click(checkbox);
expect(checkbox).toBeChecked();
// Close the modal
fireEvent.click(cancelButton);
// The checkbox should be reset (though we can't test this directly since modal closes)
expect(setModalClosed).toHaveBeenCalled();
});

If we can't test that the checkbox reset, we should delete this testcase. setModalClosed is already tested in calls setModalClosed when cancel button is clicked

id={id}
title={__('Unlock')}
body={__(
"This will unlock the resources that the task is running against. Please note that this might lead to inconsistent state and should be used with caution, after making sure that the task can't be resumed."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"This will unlock the resources that the task is running against. Please note that this might lead to inconsistent state and should be used with caution, after making sure that the task can't be resumed."
"This action will unlock the resources held by the task. Please note that this might lead to inconsistent database state and should be used with caution after making sure that the task can't be resumed."

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we should change the wording in this PR as its purpose is to update the modals, and this wording is the same as the old modal. Also maybe we need docs advice?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. Let's go without the string changes in this PR, then.

title={__('Force Unlock')}
body={sprintf(
__(
`Resources for %s task(s) will be unlocked and will not prevent other tasks from being run. As the task(s) might be still running, it should be avoided to use this unless you are really sure the task(s) got stuck.`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`Resources for %s task(s) will be unlocked and will not prevent other tasks from being run. As the task(s) might be still running, it should be avoided to use this unless you are really sure the task(s) got stuck.`
`Resources held by %s task(s) will be unlocked and will not prevent other tasks from being run. As the task(s) might be still running, you should avoid using this action unless you are certain that the task(s) are stuck.`

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

Labels

breaks-robottelo Can be set via comment: /label breaks-robottelo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants