Skip to content
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

Fixes #36050 - DiffRadioButtons PF4 Refactor #9615

Merged

Conversation

LiorKGOW
Copy link
Contributor

@LiorKGOW LiorKGOW commented Feb 8, 2023

  • Changing the ButtonGroup to a PF4 ToggleGroup
  • Changing the name of the component DiffRadioButtons to DiffToggle
  • Refactoring DiffContainer component from being a class component to be a functional component
  • Changing the div id wrapping the ButtonGroup to match the name of the new component, and assigning it to the ToggleGroup instead, while removing the unnecessary div
  • Updating DiffContainer test
  • Updating the appropriate Snapshots
  • Keeping used functionalities

Screenshots:

For instance, removing some text

Should was removed, then changes appears

"Split" option is selected

"Unified" option is selected

@theforeman-bot
Copy link
Member

Can one of the admins verify this patch?

2 similar comments
@theforeman-bot
Copy link
Member

Can one of the admins verify this patch?

@theforeman-bot
Copy link
Member

Can one of the admins verify this patch?

@theforeman-bot
Copy link
Member

Issues: #36050

@LiorKGOW
Copy link
Contributor Author

LiorKGOW commented Feb 8, 2023

@MariaAga @Ron-Lavi
What do you think?

@LiorKGOW LiorKGOW force-pushed the DiffView-DiffToggleButtons-PF4 branch 4 times, most recently from f20e008 to ef969fb Compare February 9, 2023 07:58
@MariaAga MariaAga self-assigned this Feb 9, 2023
@LiorKGOW LiorKGOW force-pushed the DiffView-DiffToggleButtons-PF4 branch from ef969fb to e7117ce Compare February 9, 2023 13:27
Copy link
Member

@MariaAga MariaAga left a comment

Choose a reason for hiding this comment

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

Thank Lior, works well!
needs some css adjustments so there will be equal space between the toggle group, the divider, and the revert button.
We're trying to move away from snapshot testing, can you make a small react testing library test for this instead?

@LiorKGOW
Copy link
Contributor Author

Thank Lior, works well! needs some css adjustments so there will be equal space between the toggle group, the divider, and the revert button. We're trying to move away from snapshot testing, can you make a small react testing library test for this instead?

Sure, I'll update you when it's ready 👍🏼
Thank you @MariaAga 🙏🏼

@LiorKGOW
Copy link
Contributor Author

Thank Lior, works well! needs some css adjustments so there will be equal space between the toggle group, the divider, and the revert button. We're trying to move away from snapshot testing, can you make a small react testing library test for this instead?

Regarding the css adjustments you mentioned, I think now there is an equal space between the elements, wouldn't mind another eye taking a look 😶‍🌫️
WYT? @MariaAga
image

@LiorKGOW LiorKGOW force-pushed the DiffView-DiffToggleButtons-PF4 branch from 7c9e5e0 to 3774bf5 Compare February 12, 2023 09:02
@LiorKGOW
Copy link
Contributor Author

LiorKGOW commented Feb 12, 2023

Thank Lior, works well! needs some css adjustments so there will be equal space between the toggle group, the divider, and the revert button. We're trying to move away from snapshot testing, can you make a small react testing library test for this instead?

@MariaAga I am working on the DiffContainer test (which broke because it used enzime).
Since DiffContainer already contains DiffToggle, Do you think I should create another test for DiffToggle,
eg. a wrapper component, with a useState, which returns DiffToggle ?
I was wandering since DiffContainer is doing exactly the same

UPDATE
I have changed the test in DiffContainer to also check the buttons of DiffToggle

@LiorKGOW LiorKGOW force-pushed the DiffView-DiffToggleButtons-PF4 branch 2 times, most recently from 7cb6a22 to b801c3a Compare February 12, 2023 15:36
@LiorKGOW LiorKGOW force-pushed the DiffView-DiffToggleButtons-PF4 branch 3 times, most recently from 76a0bc5 to 7ed2bdb Compare February 14, 2023 12:28
Copy link
Member

@MariaAga MariaAga left a comment

Choose a reason for hiding this comment

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

Tested in report_templates and audits and it looks good, just needs a few code changes

this.setState({ viewType });
}
const DiffContainer = ({ patch, oldText, newText, className }) => {
const [viewType, setViewType] = useState(SPLIT);
Copy link
Member

Choose a reason for hiding this comment

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

Nice refactor!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you @MariaAga :)



// unmnount the component from the DOM
unmount();
Copy link
Member

Choose a reason for hiding this comment

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

Nice test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks 🙏🏼

package.json Outdated Show resolved Hide resolved
@LiorKGOW LiorKGOW marked this pull request as draft March 6, 2023 12:50
@LiorKGOW LiorKGOW force-pushed the DiffView-DiffToggleButtons-PF4 branch from 4e31ce7 to ae40b7b Compare March 6, 2023 14:15
@LiorKGOW LiorKGOW force-pushed the DiffView-DiffToggleButtons-PF4 branch from ae40b7b to c6e4048 Compare March 6, 2023 14:24
@LiorKGOW LiorKGOW force-pushed the DiffView-DiffToggleButtons-PF4 branch from c6e4048 to c208b36 Compare March 6, 2023 14:31
@LiorKGOW LiorKGOW requested a review from MariaAga March 6, 2023 14:41
@LiorKGOW LiorKGOW marked this pull request as ready for review March 6, 2023 14:42
@LiorKGOW
Copy link
Contributor Author

LiorKGOW commented Mar 6, 2023

Removed any unrelated snapshot updates 👍🏼
Hopefully I have fixed all of your comments @MariaAga 🙏🏼
I think it is ready to merge

Copy link
Member

@MariaAga MariaAga left a comment

Choose a reason for hiding this comment

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

Thanks for the refactor!

@MariaAga MariaAga merged commit 51172da into theforeman:develop Mar 9, 2023
8 checks passed
@LiorKGOW LiorKGOW deleted the DiffView-DiffToggleButtons-PF4 branch March 12, 2023 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants