From baaeb60ff4fe019f58d9cd311a23b189d8d349f0 Mon Sep 17 00:00:00 2001 From: Nizamudeen A Date: Fri, 8 Jan 2021 13:07:27 +0530 Subject: [PATCH] mgr/dashboard: Fix for datatable item not showing details after getting selected **Regression in nautilus** Datatable items are not showing the details even if an item in the list is selected. This is happening because of this backport (https://github.com/ceph/ceph/pull/37756/files) which backports the line this.selection.selected = $event['selected']; but this feature was not implemented in the nautilus branch originally. Fixes: https://tracker.ceph.com/issues/48796 Signed-off-by: Nizamudeen A --- .../datatable/table/table.component.spec.ts | 15 +++++++++++++++ .../app/shared/datatable/table/table.component.ts | 1 + 2 files changed, 16 insertions(+) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.spec.ts index 40f85b7d61ecd..682a9386fc693 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.spec.ts @@ -295,6 +295,21 @@ describe('TableComponent', () => { }); }); + describe('select row', () => { + beforeEach(() => { + component.ngOnInit(); + component.data = []; + }); + + it('should select the row item', () => { + spyOn(component, 'onSelect').and.callThrough(); + component.data = createFakeData(3); + component.selection.selected = [_.clone(component.data[1])]; + component.onSelect(new Event('click')); + expect(component.selection.hasSelection).toBeTruthy(); + }); + }); + describe('reload data', () => { beforeEach(() => { component.ngOnInit(); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts index 57fa7aad76801..b3e5eb41a56a7 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts @@ -460,6 +460,7 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O if (_.has($event, 'selected')) { this.selection.selected = $event['selected']; } + this.selection.update(); this.updateSelection.emit(_.clone(this.selection)); } -- 2.47.3