Skip to content

Conversation

@MariaAga
Copy link
Member

The original task states:
Deprecate the 3 components: TimePicker, DatePicker and DateTimePicker
Investigate where the components are used so we can plan the work to replace their usage

But the components are used in erb forms, so they should still be wrapped.
I only found them being used in the generate report erb. but in the future we might need to reuse the datetime picker, which PF doesnt supply directly.
foreman_remote_job_execution uses a different type of a datetime picker, thats because in there users can select a date and a time separately, but in some form, it might be necessary to have the date and time in the same text field, like in the generate page.

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 modernizes the DateTimePicker, DatePicker, and TimePicker components by migrating from custom implementations to PatternFly 5 native components. The changes simplify the codebase significantly by removing numerous custom date/time handling components and replacing them with PF5's built-in functionality.

Key Changes

  • Replaced custom date/time pickers with PatternFly 5 components (CalendarMonth, DatePicker, TimePicker)
  • Migrated test suite from Enzyme to React Testing Library
  • Removed over 1000 lines of custom date handling logic and components
  • Added helper functions for date/time formatting

Reviewed changes

Copilot reviewed 54 out of 54 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
dateTimeHelpers.js New utility file with formatTime and formatDate helper functions
DateTimePicker.js Converted to functional component using PF5 CalendarMonth and custom TimePicker
DatePicker.js Simplified to wrap PF5 DatePicker component
TimePicker.js Simplified to wrap PF5 TimePicker component
*.test.js files Migrated from Enzyme to React Testing Library
date-time-picker.scss Removed legacy styles, added minimal wrapper styles
DateComponents/* Deleted custom date picker components (MonthView, YearView, DecadeView, etc.)
TimeComponents/* Deleted custom time picker components
form_helper.rb Added time_local_f helper method

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@MariaAga
Copy link
Member Author

TODO: fix
image
and add a validator to allow only future date (if prop is passed)

@MariaAga
Copy link
Member Author

Fixed review comments, added isFutureOnly prop, fixed the extra 0 bug

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

Copilot reviewed 54 out of 54 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [valueDate, valueTime, value, required, isFutureOnly]);
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

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

The interval cleanup is missing onChange in the dependency array but uses it. The useEffect at line 43 uses the onChange callback (line 54) but doesn't include it in the dependency array (line 70). This violates the rules of hooks and could lead to calling a stale onChange function. Either add onChange to the dependency array or wrap it with useCallback in the parent component.

Copilot uses AI. Check for mistakes.
Comment on lines +33 to +34
const [valueDate, setValueDate] = useState(formatDate(initialValue));
const [valueTime, setValueTime] = useState(formatTime(initialValue));
Copy link
Member

Choose a reason for hiding this comment

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

I don't mean to block the review here and certainly not block, but I notice you store a formatted date in the store. Isn't it possible to store a Date object instead of a string? My main concern is that you can't deal with timezones this way which can be important.

Copy link
Member Author

Choose a reason for hiding this comment

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

Can you give an example? formatDate and formatTime use a New Date( object

Copy link
Member

Choose a reason for hiding this comment

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

When I read the flow you take initialValue (which could be timezone aware) deconstruct that into simple strings for both date and time. Then reuse that into a string value. Could the TextInput itself be fed a Date instance with a format function? Effectively removing the formatDate and formatTime helpers.

Out of my interest I tried to read up on what HTML can do. https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/datetime-local uses the value 2018-06-12T19:30 which is the ISO 8601 format. So perhaps pass that around as much as possible?

Then I don't know what PatternFly does, but I noticed https://www.patternfly.org/components/forms/text-input/ supports datetime-local too (instead of text). Is that only in PF6?

And this is still for me to understand how we deal with dates, not a formal review.

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 will say that from my tests by editing the field with a different timezone all worked as expected, and the server respected the correct timezone (set the generate report to 3 mins in the future and it only downloaded 3 mins later)

@pondrejk
Copy link
Contributor

Heya, looked at packit, not sure how much in progress this is, but here are some observations anyway:

  • there's one downstream test related, the way it is written now doesn't break robottelo, though not sure if it would make sense for users to display time and date in one field and then time again in a separate field
image
  • if we drop time from the first field I'd need to make some adjustments in airgun which is ok, but I'd need unique id for the time input field as well

  • I cant select from the calendar popup and the popup doesn't disappear if I click away from it (have to click calendar icon again to roll it up)

image
  • clear all button clears the first field only
image

@MariaAga
Copy link
Member Author

MariaAga commented Dec 17, 2025

@pondrejk

clear all button clears the first field only

Bug in PF patternfly/patternfly-react#6569
There is no way to empty the time field. I'll take a look if I can workaround it.

I cant select from the calendar popup

Fixed

and the popup doesn't disappear if I click away from it (have to click calendar icon again to roll it up)

I based my work on the PF design, and it doesnt disappear on click away as well
https://v5-archive.patternfly.org/components/date-and-time/date-and-time-picker

@pondrejk
Copy link
Contributor

https://v5-archive.patternfly.org/components/date-and-time/date-and-time-picker

strangely that second example there with Date and time range picker doesn't have this problem, not sure why

@MariaAga
Copy link
Member Author

strangely that second example there with Date and time range picker doesn't have this problem, not sure why

@pondrejk
Is there a preference to close on clickout side? I can add it if thats what we expect

@MariaAga
Copy link
Member Author

todo: editing the time when date is empty should populate the date

@pondrejk
Copy link
Contributor

Is there a preference to close on clickout side? I can add it if thats what we expect

I suspect users could see it as a bug, for example if they change focus without changing date and the popover will prevent interaction with another field/dropdown, something like here with time select:

image

@MariaAga
Copy link
Member Author

Fixed: calendar close on clickout side and on date select, selecting a time when there is no date sets the date to today.

</InputGroupItem>
<InputGroupItem className="date-picker-input-item">
<TimePicker
value={valueTime}
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick, maybe some ouiaId here as well?, because right now the time picker input has id=""

Copy link
Member Author

Choose a reason for hiding this comment

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

there is no ouiaId prop for timepicker, instead I gave it

id={`${id}-time-picker`}

Copy link
Contributor

@pondrejk pondrejk left a comment

Choose a reason for hiding this comment

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

ack from the functional side, UI works nice, the time offset is honored when creating a report. Also positive PRT result in SatelliteQE/robottelo#20541 proves the automation is not affected and the tested scenario still works

ofedoren
ofedoren previously approved these changes Dec 18, 2025
Copy link
Member

@ofedoren ofedoren left a comment

Choose a reason for hiding this comment

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

Thanks, @MariaAga and @pondrejk !

Just for future reference sake:

  1. Why is the time shown twice? In patternfly docs there are examples where it's either shown together or completely separate. We currently have it mixed.
  2. The old UI had a Today button, but it doesn't seem to be present now. Does clear button do it instead?

@MariaAga
Copy link
Member Author

Why is the time shown twice? In patternfly docs there are examples where it's either shown together or completely separate. We currently have it mixed.

I didnt like that the PF docs created a new time selector which was just a dropdown with times, and I wanted to reuse existing components, so I put the timepicker component as it is.
The time needs to be in the date-time field so the form will have a date-time value, the second time field is mostly for comfort and editing.

The old UI had a Today button, but it doesn't seem to be present now. Does clear button do it instead?

No, clear only removes the date, PF example just have buttons outside the date picker to reset and clear the date https://v5-archive.patternfly.org/components/date-and-time/date-picker#controlled-required
Not sure if we want more buttons on the form, but what about something like this? (only for the date time picker)
image

@ofedoren
Copy link
Member

what about something like this? (only for the date time picker)

Honestly, I'm not sure if this button is being used by the users, but at least it would feel the same since we already have such button.

@MariaAga
Copy link
Member Author

Added a today button inside the datepicker. Moved the clear button for consistency, and also since the clear only clears the date
Screenshot From 2025-12-19 16-16-53

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants