cockpit-project / cockpit

Cockpit is a web-based graphical interface for servers.
http://www.cockpit-project.org/
GNU Lesser General Public License v2.1
11.2k stars 1.11k forks source link

systemd: Fix state handling with creating repeating timers #20435

Closed martinpitt closed 5 months ago

martinpitt commented 5 months ago

When setting the time of a repeated timer with the mouse, this triggered both onChange() and setOpen() at the same time, both of which calling setRepeatPatterns(). Due to the async/deferred nature of React, these both worked on old data, so that the first callback was effectively ignored, and created timers ended up with the default "00:00" time. Fix that with a functional state update.

Also replace the weird JSON stringify/parse cycle with a spread, like all the other callbacks already did -- the only purpose of that was to copy the list.

This didn't happen when setting the time with the keyboard, because the dropdown wasn't opened then. So change TestTimers() to set the "Friday" repeat time with the mouse (keep the Monday one with the keyboard, to cover both cases). As we only have 30-minute granularity, change the time from 12:45 to 12:30.

The test uses select_PF5(), so drop it from the vulture suppressions. (c-machines also uses that function.)

Fixes #19278