]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: fix snap schedule startDate 70603/head
authorPedro Gonzalez Gomez <pegonzal@ibm.com>
Tue, 28 Jul 2026 06:05:53 +0000 (08:05 +0200)
committerPedro Gonzalez Gomez <pegonzal@ibm.com>
Tue, 28 Jul 2026 06:05:53 +0000 (08:05 +0200)
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 <pegonzal@ibm.com>
src/pybind/mgr/dashboard/frontend/src/app/shared/components/date-time-picker/date-time-picker.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/components/date-time-picker/date-time-picker.component.ts

index 5cac6c1cf579220b595720af4c091507be585916..a50b15424fd7c3e1772049e048348c9d1f6e99d3 100644 (file)
@@ -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;
index 8689a623efcb3e91dd7237f940f04a818a6f3944..b74059ef7ab21cc50e220b429d9b35ca16b62cff 100644 (file)
@@ -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) {