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

Install PF5 libraries #213

Merged
merged 6 commits into from
Jan 8, 2024
Merged

Conversation

carma12
Copy link
Collaborator

@carma12 carma12 commented Dec 14, 2023

The project has been migrated to use the PatternFly 5 library. The code has been adapted by following the suggested steps mentioned in the guidelines.

Steps followed

  1. Upgrade the libraries to their latest version:
   $ npm install @patternfly/patternfly@latest @patternfly/react-core@latest @patternfly/react-table@latest

Affected libraries and its current version (as per the promoted package versions):

  • "@patternfly/patternfly": "^5.1.0"
  • "@patternfly/react-core": "^5.1.2"
  • "@patternfly/react-table": "^5.1.2"
  1. Run the codemods. This will auto-fix some simple errors and throw an error/warning on the ones that can't be handled.
   $ npx @patternfly/pf-codemods@latest <path-to-source-code> [--fix]
  1. Fix problems that arise when building the project via npm run start.
  2. Adapt the code to the new components.

How do I apply these changes?

To adapt these changes to your local project you just need to install and build the project via NodeJS.

   $ npm install
   $ npm run start

@carma12 carma12 added the WIP Work in Progress (do not merge) label Dec 14, 2023
@carma12 carma12 force-pushed the PF4-to-PF5-migration-lib branch 2 times, most recently from 0b6eb4a to 9ddf79e Compare December 18, 2023 10:06
The first step to migrate the project
to PF5 is install the libraries used
to its latest version.
- "@patternfly/patternfly": "^5.1.0"
- "@patternfly/react-core": "^5.1.2"
- "@patternfly/react-table": "^5.1.2"

Signed-off-by: Carla Martinez <carlmart@redhat.com>
@carma12 carma12 force-pushed the PF4-to-PF5-migration-lib branch from b3326a5 to 66a107e Compare December 18, 2023 16:33
@carma12 carma12 added needs-review This PR is waiting on a review and removed WIP Work in Progress (do not merge) labels Dec 19, 2023
@carma12
Copy link
Collaborator Author

carma12 commented Dec 19, 2023

It seems that the integration tests are not passing. Moving this into WIP to investigate what is happening

@carma12 carma12 added WIP Work in Progress (do not merge) and removed needs-review This PR is waiting on a review labels Dec 19, 2023
@carma12
Copy link
Collaborator Author

carma12 commented Dec 19, 2023

The Cypress tests have been adapted to the new version as well. Removing the 'WIP' tag and the code is ready to review.

@carma12 carma12 added needs-review This PR is waiting on a review and removed WIP Work in Progress (do not merge) labels Dec 19, 2023
.cache_1fmm0i3 Outdated Show resolved Hide resolved
The pf-codemods[1] is an eslint wrapper to
update @patternfly/react-core@4.x.x code
to 5.x.x via autofixers.

[1]- https://github.com/patternfly/pf-codemods/
Signed-off-by: Carla Martinez <carlmart@redhat.com>
After applying the changes, some
class names will need to be
updated via the `class-name-updater`
codemod[1]. This utility automatically
identifies Patternfly class names
that need to be updated after the
introduction of versioned class names
in Patternfly v5.

[1]- https://github.com/patternfly/pf-codemods/tree/main/packages/class-name-updater
Signed-off-by: Carla Martinez <carlmart@redhat.com>
As some parameters are now different
for some PatternFly components, those
needs to be fixed and adapted to the
new version.

Signed-off-by: Carla Martinez <carlmart@redhat.com>
As stated in the official docs[1], some
components have been updated in the major
release. To prevent these components to
be outdated any time soon, those need
to be adapted to the newer version.

[1]- https://www.patternfly.org/get-started/upgrade/#upgrade-deprecated-components
Signed-off-by: Carla Martinez <carlmart@redhat.com>
With the addition of new PF5 classes,
some Cypress tests need to be adapted
to work with the new `v5` classes.

Signed-off-by: Carla Martinez <carlmart@redhat.com>
@carma12 carma12 force-pushed the PF4-to-PF5-migration-lib branch from 59ced17 to d966a94 Compare December 21, 2023 11:02
@carma12
Copy link
Collaborator Author

carma12 commented Dec 21, 2023

@pvoborni - Code updated and fixed.

Copy link
Member

@pvoborni pvoborni left a comment

Choose a reason for hiding this comment

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

I speed read through the changes. I didn't see anything concerning. But that doesn't mean that everything is correct :).

Was also testing a bit manually seems to behave the same as before but I didn't test certificate workflows on user page.

I noticed the following weird behavior, but it might be present even in current code:

  • In IpaCalendar component, first setting of time tends to reset date.
  • In user add dialog, I cannot unset GID when I selected some, also the GID field should allow to enter arbitrary integer.

Overall, I'd be OK with merging this. Maybe even before merging all the "actions" PRs so that the actions PRs can be also modified to PF5 if needed (seems easier than modifying this after they are merged).

There will probably be some regressions but it might be easier to fix them in smaller separate PRs when they are found.

Will wait for yours and @mreynolds389 thoughts before adding the approval.

Comment on lines +96 to +97
setOptionsToSelect(optionsTemp || []);
optionsTemp.unshift(NO_SELECTION_OPTION);
Copy link
Member

Choose a reason for hiding this comment

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

Not sure, but shouldn't these two lines be swapped? It's a bit weird to modify something which was set a line before. It probably works because the reference to the object is the same, but still...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You are right - Actually, line 97 can be removed as the addition of the empty element is being managed directly from the other useEffect (lines 85-90). I will create a new PR to amend that.

<Icon status="warning" size="xl" className="pf-u-mt-4xl">
<ExclamationTriangleIcon size="lg" />
<Icon status="warning" size="xl" className="pf-v5-u-mt-4xl">
<ExclamationTriangleIcon sizes="lg" />
Copy link
Collaborator

Choose a reason for hiding this comment

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

@carma12 are you sure this is "sizes" and not "size", I can not not find "sizes" anywhere in the PF5 icon code

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@ mreynolds389 - I think the IDE suggested the sizes property, but I can't find this in the PF documentation either. It seems that the icons are based on the createIcon component (available under node_modules/@patternfly/react-icons/src/createIcon.tsx).

In any case, I will check this with the PF team via slack to gather further information.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Update: I got a response from the PF team and it seems that the sizes prop is not necessary. The size of any icon should be set from the Icon wrapper component. E.g.:

const MyIconComponent = () => {
  return (
    <Icon status="warning" size="xl" className="pf-v5-u-mt-4xl">
      <ExclamationTriangleIcon />
    </Icon>
  );
}

I have created a new issue to track and remove the sizes bit: #238

@mreynolds389
Copy link
Collaborator

Overall this looks fine to me (besides the current comments). If something else is missing/wrong I'm sure we will spot it soon enough. So I think this is good to go, as current and future PRs will need this merged.

@carma12
Copy link
Collaborator Author

carma12 commented Jan 8, 2024

@pvoborni and @mreynolds389 - Thanks for reviewing the code :)

Some clarifications:

I noticed the following weird behavior, but it might be present even in current code:

* In IpaCalendar component, first setting of time tends to reset date.

I checked this and this behavior only happens when the first value set is the time (when the date and time values are set the first time and those are empty). This behavior is expected and was present in the code (not affected by the PF5 migration).

* In user add dialog, I cannot unset GID when I selected some, also the GID field should allow to enter arbitrary integer.

This is the behavior that can be found in the current WebUI as well (not directly related to the PF5 migration). The numbers correspond with the GID identification numbers that are assigned when those are selected. I agree with you with the fact that it would be nice to have the No selection option. I have created this issue to track it.

@carma12 carma12 merged commit bf93d01 into freeipa:main Jan 8, 2024
2 checks passed
@carma12 carma12 removed the needs-review This PR is waiting on a review label Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants