From: Pedro Gonzalez Gomez Date: Tue, 28 Jul 2026 06:05:53 +0000 (+0200) Subject: mgr/dashboard: fix snap schedule startDate X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a11f0e3d4e8bd00edd682af06101f7c77d5b0b64;p=ceph.git mgr/dashboard: fix snap schedule startDate Fixes date time picker that was wrongly setting the form date Fixes: https://tracker-origin.ceph.com/issues/78742 Signed-off-by: Pedro Gonzalez Gomez --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/date-time-picker/date-time-picker.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/date-time-picker/date-time-picker.component.spec.ts index 5cac6c1cf579..a50b15424fd7 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/date-time-picker/date-time-picker.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/date-time-picker/date-time-picker.component.spec.ts @@ -39,6 +39,23 @@ describe('DateTimePickerComponent', () => { expect(component.control.value).toBe('2022-02-22 00:00:00'); })); + it('should update control value if datetime is in the past', fakeAsync(() => { + component.control = new FormControl('2022-02-20 15:30:00'); + fixture.detectChanges(); + tick(); + expect(component.control.value).toBe('2022-02-22 00:00:00'); + })); + + it('should keep past datetime when disabled', fakeAsync(() => { + component.control = new FormControl('2022-02-20 15:30:00'); + component.disabled = true; + fixture.detectChanges(); + tick(); + expect(component.control.value).toBe('2022-02-20 15:30:00'); + expect(component.time).toBe('03:30'); + expect(component.ampm).toBe('PM'); + })); + it('should init with only date enabled', () => { component.control = new FormControl(); component.hasTime = false; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/date-time-picker/date-time-picker.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/date-time-picker/date-time-picker.component.ts index 8689a623efcb..b74059ef7ab2 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/date-time-picker/date-time-picker.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/date-time-picker/date-time-picker.component.ts @@ -57,7 +57,7 @@ export class DateTimePickerComponent implements OnInit { let mom = moment(this.control?.value, this.format); - if (!mom.isValid() || mom.isBefore(moment())) { + if (!mom.isValid() || (!this.disabled && mom.isBefore(moment()))) { mom = moment(); } if (this.defaultDate) {