From fd1fe0e74e6a8c61f9d2796d0f88989f030003c1 Mon Sep 17 00:00:00 2001 From: Alex Karpov Date: Mon, 1 Jul 2024 17:43:49 +0300 Subject: [PATCH 1/2] NAS-129774: UI task manager shows "Invalid date" for running jobs --- .../ix-cell-date/ix-cell-date.component.html | 7 ++++ .../ix-cell-date.component.spec.ts | 32 ++++++++++++++----- .../ix-cell-date/ix-cell-date.component.ts | 5 ++- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/app/modules/ix-table/components/ix-table-body/cells/ix-cell-date/ix-cell-date.component.html b/src/app/modules/ix-table/components/ix-table-body/cells/ix-cell-date/ix-cell-date.component.html index f4ee0616ac9..5ec16b61110 100644 --- a/src/app/modules/ix-table/components/ix-table-body/cells/ix-cell-date/ix-cell-date.component.html +++ b/src/app/modules/ix-table/components/ix-table-body/cells/ix-cell-date/ix-cell-date.component.html @@ -1,4 +1,11 @@ + + + + {{ 'N/A' | translate }} + + diff --git a/src/app/modules/ix-table/components/ix-table-body/cells/ix-cell-date/ix-cell-date.component.spec.ts b/src/app/modules/ix-table/components/ix-table-body/cells/ix-cell-date/ix-cell-date.component.spec.ts index 837b93c67bd..a556d0a7ab6 100644 --- a/src/app/modules/ix-table/components/ix-table-body/cells/ix-cell-date/ix-cell-date.component.spec.ts +++ b/src/app/modules/ix-table/components/ix-table-body/cells/ix-cell-date/ix-cell-date.component.spec.ts @@ -25,15 +25,31 @@ describe('IxCellDateComponent', () => { ], }); - beforeEach(() => { - spectator = createComponent(); - spectator.component.propertyName = 'dateField'; - spectator.component.setRow({ dateField: new Date('2023-07-12 09:10:00') }); - spectator.component.rowTestId = () => ''; - spectator.detectChanges(); + describe('date provided', () => { + beforeEach(() => { + spectator = createComponent(); + spectator.component.propertyName = 'dateField'; + spectator.component.setRow({ dateField: new Date('2023-07-12 09:10:00') }); + spectator.component.rowTestId = () => ''; + spectator.detectChanges(); + }); + + it('shows default format datetime in template', () => { + expect(spectator.element.textContent.trim()).toBe('2023-07-11 23:10:00'); + }); }); - it('shows default format datetime in template', () => { - expect(spectator.element.textContent.trim()).toBe('2023-07-11 23:10:00'); + describe('no date provided', () => { + beforeEach(() => { + spectator = createComponent(); + spectator.component.propertyName = 'dateField'; + spectator.component.setRow({ dateField: null }); + spectator.component.rowTestId = () => ''; + spectator.detectChanges(); + }); + + it('shows default format datetime in template', () => { + expect(spectator.element.textContent.trim()).toBe('N/A'); + }); }); }); diff --git a/src/app/modules/ix-table/components/ix-table-body/cells/ix-cell-date/ix-cell-date.component.ts b/src/app/modules/ix-table/components/ix-table-body/cells/ix-cell-date/ix-cell-date.component.ts index 49ec98628e6..a732456430c 100644 --- a/src/app/modules/ix-table/components/ix-table-body/cells/ix-cell-date/ix-cell-date.component.ts +++ b/src/app/modules/ix-table/components/ix-table-body/cells/ix-cell-date/ix-cell-date.component.ts @@ -8,7 +8,10 @@ import { Column, ColumnComponent } from 'app/modules/ix-table/interfaces/table-c changeDetection: ChangeDetectionStrategy.OnPush, }) export class IxCellDateComponent extends ColumnComponent { - get date(): number | Date { + get date(): number | null | Date { + if (this.value === null) { + return null; + } if ((this.value as ApiTimestamp)?.$date) { return (this.value as ApiTimestamp).$date; } From ad278562f0bcadec4c19a7899963d7267ddbaed2 Mon Sep 17 00:00:00 2001 From: Alex Karpov Date: Wed, 3 Jul 2024 11:59:42 +0300 Subject: [PATCH 2/2] NAS-129774: PR update --- .../cells/ix-cell-date/ix-cell-date.component.html | 2 +- .../ix-table-body/cells/ix-cell-date/ix-cell-date.component.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/modules/ix-table/components/ix-table-body/cells/ix-cell-date/ix-cell-date.component.html b/src/app/modules/ix-table/components/ix-table-body/cells/ix-cell-date/ix-cell-date.component.html index 5ec16b61110..07c0a369bed 100644 --- a/src/app/modules/ix-table/components/ix-table-body/cells/ix-cell-date/ix-cell-date.component.html +++ b/src/app/modules/ix-table/components/ix-table-body/cells/ix-cell-date/ix-cell-date.component.html @@ -1,5 +1,5 @@ diff --git a/src/app/modules/ix-table/components/ix-table-body/cells/ix-cell-date/ix-cell-date.component.ts b/src/app/modules/ix-table/components/ix-table-body/cells/ix-cell-date/ix-cell-date.component.ts index a732456430c..edf992eceae 100644 --- a/src/app/modules/ix-table/components/ix-table-body/cells/ix-cell-date/ix-cell-date.component.ts +++ b/src/app/modules/ix-table/components/ix-table-body/cells/ix-cell-date/ix-cell-date.component.ts @@ -9,7 +9,7 @@ import { Column, ColumnComponent } from 'app/modules/ix-table/interfaces/table-c }) export class IxCellDateComponent extends ColumnComponent { get date(): number | null | Date { - if (this.value === null) { + if (!this.value) { return null; } if ((this.value as ApiTimestamp)?.$date) {